Skip to content

feat(rules): flag unauthenticated API endpoints returning data (repo#1955) - #1880

Merged
nc9 merged 1 commit into
mainfrom
boat/unauth-api-endpoint-1955
Nov 14, 2026
Merged

nc9 merged 1 commit into
mainfrom
boat/unauth-api-endpoint-1955

Conversation

@nc9

@nc9 nc9 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds security/unauthenticated-api, a site-scoped probing rule for API endpoints that answer an anonymous request with records (squirrelscan/repo#1955, part of the API and data exposure epic repo#1952). Closes squirrelscan/repo#1955 once merged and the private gitlink is bumped.

  • Activation: runs only when ctx.probe allows quiet probes (active or aggressive). Passive, or no probe budget: one skipped check (probing-passive), nothing sent. Cloud stays passive until ownership is verified; --disable-discovery-probes keeps it passive (the existing fix(rules): content/reading-level skips code blocks (repo#1639) #1931 policy, the same path the GraphQL probes use).
  • Selection: endpoint discovery candidates only (no guessed paths), strict same origin re-checked, a path whose call sites only state POST/PUT/PATCH/DELETE never probed, state-changing or session words (logout, delete, login, auth, callback, verify, token, webhook, ...) never probed, GraphQL / _next/data / health / metrics / spec paths left to their own rules, robots.txt respected below aggressive, max 10, call sites first.
  • Request: one GET, query and fragment dropped, credentials: "omit", no Cookie or Authorization header, redirect: "manual", 10 s timeout plus the shared budget, at most 256 KB decoded (compression bombs cut, GraphQL probes still let the runtime inflate a compressed response before the cap #722).
  • Grading by field names only: credential, personal or internal fields -> unauthenticated-api-sensitive fail (details.severity: "high"); user-identity or unclassified -> unauthenticated-api-data warn (medium); only published content (title, slug, price, ...) -> unauthenticated-api-public info (low).
  • Finding: endpoint URL, record count, field names (sensitive first), a redacted shape sample ({id: number, email: string}). No response value is ever reported; data-like field names (emails, numbers, hex ids used as map keys) are counted, not listed.
  • Budget cut short or every probe errored: skipped (probe-budget / probe-errors), never a pass.
  • readCapped moved unchanged from graphql-probe.ts to a shared probe-http.ts.

Acceptance criteria

  • rule probes discovered endpoints unauthenticated and flags 200 + record data. Evidence: unauthenticated-api.test.ts "one GET per endpoint, no cookies, no Authorization, no redirects, no query", "user records with PII and internal fields fail, ...", "records with no telling fields warn; ...".
  • responses containing user/PII/internal fields are high severity; plainly-public data is low/none. Evidence: "user records with PII and internal fields fail" (severity high), "plainly public content is info, not a failure" (severity low), "public content with an author email nested inside is sensitive", "the WordPress users endpoint enumerates accounts: warn, not public", and "auth refusals, redirects, HTML, health and error bodies are not flagged".
  • finding names the endpoint and what was returned (bounded, redacted). Evidence: item id/label/meta assertions plus JSON.stringify(checks) not containing any returned value; "a map keyed by email or id does not leak its keys"; "an answer over the read cap is read from its prefix, with lower confidence".
  • runs only per fix(rules): content/reading-level skips code blocks (repo#1639) #1931; same-origin only. Evidence: "passive or no probe budget: skipped, nothing sent", "a cross-origin endpoint is never probed, whatever it claims", "selection: methods, side-effect paths, owned paths, robots and the cap", "aggressive probes a robots-disallowed path; ...".

Scope note: the issue's "PII/user/internal fields raise confidence; obviously public content lowers it" is implemented as three tiers by field name. Values are never inspected, so a sensitive field under an unusual name grades as data (warn), not sensitive. The rule copy states the honest limit from repo#1952: an anonymous probe cannot prove cross-user (IDOR) access.

Gates

  • packages/rules: bun run typecheck (src + tests) OK.
  • packages/audit-engine, packages/utils: bun run typecheck OK.
  • oxlint (apps/cli/oxlint.config.mjs) on the new and changed rule files: clean. apps/cli: bun run lint clean. packages have no format script.
  • Tests (explicit paths, at most 5 per run): tests/unauthenticated-api.test.ts 18 pass; graphql-probe, graphql-introspection, graphql-get-mutations, graphql-probe-decoding-722, rule-check-declarations 66 pass; 20 rule-wide suites (docs-category-table, docs-index-rule-counts, docs-rule-pages, max-rules-limit, meta-string-limits, opt-in-rules, private-target-skip, rule-verdict-scope, plugin-rule-ids-1599, rule-filter-core-3785, discovery-probes, ignore-1262, noindex-skip, page-type-skip-841, unread-page-gate-1570, template-verdict-inputs, template-verdict-page-independence, token-storage, broken-forms, content-dev-leakage) 1160 pass, 0 fail.
  • packages/audit-engine/tests/streaming-rules-canonical-golden.test.ts 1 pass (findings 109735 -> 109736, tally 328 -> 329: one passive skipped check); golden-finding-messages-229.test.ts 3 pass after UPDATE_GOLDEN=1 (adds the one passive skip line).
  • docs/: make validate passes (tangly strict, links, glossary/hubs, rule-checks blocks, 62 script tests).

Docs

New page docs/rules/security/unauthenticated-api.mdx (nav in docs.json), row in configuration/security.mdx "Rules that probe", Security counts 24 -> 25 in README.md, docs/index.mdx, docs/rules/index.mdx, docs/rules/security/index.mdx (hub table regenerated), CHANGELOG Unreleased entry (329 rules, 25 in Security), ENDPOINT-DISCOVERY.md consumer note.

Agent skill

Yes, the squirrelscan agent skill needs a change: its probing section names security/graphql-introspection and security/graphql-get-mutations as the rules that probe and are skipped on a passive run; it should add security/unauthenticated-api. The maintainer files that as a private skills issue.

Hold-list (security probing): draft for review at Opus depth.

…1955)

Add security/unauthenticated-api, a site-scoped probing rule. On an active
or aggressive run it sends one GET with no cookies, no Authorization header
and no query string to each same-origin endpoint from the endpoint discovery
pass (at most ten, call sites first), and flags a 2xx JSON answer that
carries records. On a passive run, or with no probe budget, it records one
skipped check and sends nothing.

Selection re-checks the origin, never probes a path whose call sites only
state POST, PUT, PATCH or DELETE, never a path naming a state-changing or
session action, leaves GraphQL, _next/data, health, metrics and API-spec
paths to their own rules, and respects robots.txt below aggressive.

Records are graded by field names only: credential, personal or internal
fields fail (high), user-identity or unclassified fields warn (medium),
published content such as titles, slugs and prices is info (low). The
finding names the endpoint, the record count and the field names, with a
redacted shape sample; no value from the response is ever reported, and a
field name that looks like data is counted, not listed. A body over the
256 KB read cap is read from its prefix with lower confidence. A run the
budget cut short, or where every probe errored, is skipped, never a pass.

The capped, decoded body read moves from graphql-probe.ts to probe-http.ts
so both probes share it. Docs page, security config table, category counts
(329 rules, 25 in Security), changelog and the engine goldens are updated.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 marked this pull request as ready for review November 14, 2026 23:27
@nc9
nc9 merged commit 0c5eca4 into main Nov 14, 2026
16 checks passed
@nc9
nc9 deleted the boat/unauth-api-endpoint-1955 branch November 14, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant