Repository navigation
feat(rules): security/json-sensitive-fields flags credentials and bulk PII in JSON API responses (repo#1956) - #1882
Merged
Merged
Conversation
Contributor
Author
|
Review requirement for this rule: add or point to a test with a fixture JSON response that holds real-looking secrets (API keys, tokens, passwords) and email addresses, and assert that none of those values appear in any finding, finding detail, report output or log line. Only field names, counts and the endpoint may appear. Please also say in the PR body whether a fix round pushes the diff past about 1,500 lines. |
…k PII in JSON API responses (repo#1956) A site-scoped probing rule. On an active or aggressive run it sends one cookie-less GET (redirects not followed, 1 MB decoded read cap, shared probe budget) to each same-origin endpoint the discovery pass found whose call site uses GET or states no method, at most ten. GraphQL paths, state-changing paths or queries, and robots-disallowed paths below aggressive are skipped. A passive run or no budget sends nothing. A 2xx JSON answer is walked (bounded depth and nodes). Password hashes by format, server-side keys the leaked-secrets matchers recognise, and tokens, secrets, SSNs, Luhn-valid card numbers or CVVs under fields named for them fail. Five or more distinct emails or phones, or records with an address or date of birth, warn. Items carry the field path, kind and length, never the value. Docs page, security tables and counts (25 Security rules), probing table, changelog and the canonical goldens (one skipped check) are updated. Signed-off-by: Nik Cubrilovic <[email protected]>
… value (repo#1956) One response can carry a public Firebase apiKey and a server apiKey. The memo keyed only by field name let whichever was checked first decide the other, so the public key could be reported as a secret, or the server key hidden as public. The memo now keys on the normalized name and the value. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
boat/json-sensitive-fields-1956
branch
from
November 14, 2026 23:33
550597a to
5005961
Compare
nc9
marked this pull request as ready for review
November 14, 2026 23:51
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/json-sensitive-fields, a site-scoped probing rule for squirrelscan/repo#1956 (part of the API and data exposure epic, repo#1952). It builds on the endpoint discovery pass (repo#1953) and the shared probe budget and levels (repo#1931, repo#1945).activeoraggressiverun, one quietGETto each same-origin endpoint that discovery found, at most ten. Only call sites that useGETor state no method qualify. Requests carry no cookies (credentials: "omit"), do not follow redirects (redirect: "manual"), read at most 1 MB of decoded body through the GraphQL probe's capped reader (so a compression bomb is never inflated), and are bounded by the shared probe budget plus a 10 s timeout. Skipped: GraphQL paths, paths or queries that name a state-changing action (isStateChangingPath), robots-disallowed paths below aggressive, and anything cross-origin (origin re-checked,probeEligiblenot trusted). No path is guessed.json-sensitive-fields): password hashes by format (bcrypt, argon2, scrypt, PBKDF2, crypt), server-side keys the leaked-secrets matchers recognise (high confidence or a server-only type, never publishable keys), and passwords, salts, secrets, API keys, tokens, SSNs, Luhn-valid card numbers or CVVs under fields named for them. Placeholders, label dictionaries, CSRF and pagination tokens, and public-by-design keys (such as a FirebaseapiKey) are not flagged.json-bulk-pii): 5 or more distinct emails or phone numbers, or 5 or more records with an address or date of birth. Role and admin fields are counted in the message. A single email is not flagged.$[].passwordHash), the kind, the record count and the value length. Paths are clamped to 160 chars, at most 20 items per endpoint.The only change to shared code is that
readCappedingraphql-probe.tsis now exported.Closes squirrelscan/repo#1956 (private tracker).
Acceptance criteria
scanJsonValue/scanJsonResponse; tests "card numbers, SSNs and plaintext passwords in user records are a fail" and "labels, placeholders, CSRF tokens, cursors and publishable keys are not flagged" (packages/rules/tests/json-sensitive-fields-1956.test.ts).failcheck and the rule severity iserror. Tests "password hashes are a fail, by shape and by key, with no value in the output" and "tokens, secrets and leaked-secrets provider keys are a fail" (leaked-secrets reuse catches a Postgres connection string under an unnamed key).grep -cfor the hash and for an email in the JSON report both returned 0.--disable-discovery-probesalready forces the budget to passive in the CLI controller.Verification
bun test packages/rules/tests/json-sensitive-fields-1956.test.ts: 18 passbun testrule-check-declarations, docs-index-rule-counts, docs-category-table, docs-rule-pages (with the new test file): 78 passtsgotypecheck for packages/rules (src and tests), packages/audit-engine and apps/cli: clean. oxlint (CLI config) on the new files: cleanmake validatein docs/: all checks passed (rule-checks block generated, hub regenerated)squirrel audit http://localhost:4799/ --probe activeagainst a local fixture whose page callsfetch("/api/users"), which returns 8 users with bcrypt hashes. Result:json-sensitive-fieldsfail ($[].passwordHash: bcrypt hash (8 records)) andjson-bulk-piiwarn (8 distinct emails), with no value in the report.Agent skill
The squirrelscan agent skill does not need a change. It describes rule categories and probing levels in general terms, and this rule adds no flag or config key.