Repository navigation
feat(rules): flag unauthenticated API endpoints returning data (repo#1955) - #1880
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.ctx.probeallows quiet probes (activeoraggressive). Passive, or no probe budget: one skipped check (probing-passive), nothing sent. Cloud stays passive until ownership is verified;--disable-discovery-probeskeeps it passive (the existing fix(rules): content/reading-level skips code blocks (repo#1639) #1931 policy, the same path the GraphQL probes use).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.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).unauthenticated-api-sensitivefail (details.severity: "high"); user-identity or unclassified ->unauthenticated-api-datawarn (medium); only published content (title, slug, price, ...) ->unauthenticated-api-publicinfo (low).{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.probe-budget/probe-errors), never a pass.readCappedmoved unchanged fromgraphql-probe.tsto a sharedprobe-http.ts.Acceptance criteria
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; ...".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".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), notsensitive. 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 typecheckOK.apps/cli/oxlint.config.mjs) on the new and changed rule files: clean.apps/cli:bun run lintclean. packages have no format script.tests/unauthenticated-api.test.ts18 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.ts1 pass (findings 109735 -> 109736, tally 328 -> 329: one passive skipped check);golden-finding-messages-229.test.ts3 pass afterUPDATE_GOLDEN=1(adds the one passive skip line).docs/:make validatepasses (tangly strict, links, glossary/hubs, rule-checks blocks, 62 script tests).Docs
New page
docs/rules/security/unauthenticated-api.mdx(nav indocs.json), row inconfiguration/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-introspectionandsecurity/graphql-get-mutationsas the rules that probe and are skipped on a passive run; it should addsecurity/unauthenticated-api. The maintainer files that as a privateskillsissue.Hold-list (security probing): draft for review at Opus depth.