Skip to content

security/unauthenticated-api and json-sensitive-fields miss an open JSON endpoint called from an inline script #1920

Closed

Description

@nc9

Found in a true-positive smoke test on our own test site, which ran a CLI build from main with --aggressive --offline (40 pages).

The page /about contains an inline <script> with fetch("/api/users") and fetch("/api/account"). GET /api/users returned a 200 JSON list with fake email addresses, and GET /api/account returned a 200 JSON object with a password field. Both endpoints were same-origin, unauthenticated and live during the run. Both rules finished as passed (passedRules, pages 0) with no finding. In the same run security/exposed-files did detect the planted /.env, so probing was active and the site was reachable.

A likely cause, unconfirmed: the inline-script fetch call sites never become ctx.endpointSurface candidates on a plain (non-rendered) crawl. packages/rules/src/endpoint-surface.ts collects inline scripts "from a live page DOM".

Acceptance Criteria

  • A fixture page with an inline <script> calling fetch("/api/users") produces a same-origin, probe-eligible endpoint candidate on a plain crawl, not only a rendered one.
  • With that fixture serving an unauthenticated JSON list of user records, security/unauthenticated-api reports the endpoint (no field values in the finding).
  • With a fixture JSON response containing a password field, security/json-sensitive-fields reports the field name and count, never the value.
  • A test runs both rules end to end through the engine (crawl, then endpoint surface, then probe) rather than with a hand-built candidate list.
  • This blocks the next CLI release that ships these rules.
  • When security/unauthenticated-api or security/json-sensitive-fields finds zero candidate endpoints, the rule reports not_checked with a reason (for example "no API endpoints found in page code"), never passed. A pass with 0 pages is a false all-clear on a security rule. Test: a page with no fetch call sites gives not_checked, not passed.

Activity

  1. added
    bug
    rules
    security
    release-blocker
    on Nov 15, 2026
  2. nc9 commented on Nov 15, 2026

    @nc9
    ContributorAuthor

    Root cause, found after the lane couldn't reproduce locally: it reproduces only behind Cloudflare. In security/unauthenticated-api (classify ~line 801), any non-2xx status, including 429, 403 or a bot challenge, and any HTML response, which is what challenge pages are, is classified no-records, so the endpoint counts as not exposed and the rule passes. json-sensitive-fields similarly skips any non-success or non-JSON response. During the smoke our zone rate-limited the probe burst (security/exposed-files reported a 429 after 8 of 20 paths), so the API probes most likely got 429s or challenges and the rules gave a false pass. exposed-files already handles this correctly as not checked. Local runs have no rate limiter, so they detect.

  3. added theissue type on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugrelease-blockerrulessecurity

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions