Skip to content

fix(rules): one finding per leaked field across json-sensitive-fields and auth-endpoint-disclosure, deduped by the runner #2083 - #2154

Merged
nc9 merged 2 commits into
mainfrom
boat/dedupe-sensitive-fields-2083
Nov 20, 2026
Merged

nc9 merged 2 commits into
mainfrom
boat/dedupe-sensitive-fields-2083

Conversation

@nc9

@nc9 nc9 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2083

The approach moved to the runner dedupe (#2164, #2082). The earlier version used a hand-off: json-sensitive-fields skipped the fields auth-endpoint-disclosure reported. That is gone. Now json-sensitive-fields reports every field on its own, and the cross-rule dedupe that runs after the site pass drops the one overlapping finding.

What changed

  • packages/rules/src/security/endpoint-dedupe.ts: there is now one CROSS_RULE_PAIRS list. It holds the existing pair (auth-endpoint-disclosure over unauthenticated-api, matched per endpoint) and the new one (auth-endpoint-disclosure over json-sensitive-fields, matched per field). Both key endpoints with anonymousGetUrl. dedupeCrossRuleFindings applies every pair. dedupeEndpointFindings is kept as a thin wrapper for unauthenticated-api, so the fix(rules): one finding per leaking endpoint, deduped after the site pass (#2082) #2164 and Dedupe: one finding per endpoint across security/unauthenticated-api and security/user-endpoint-overexposure #1886 tests did not need any changes.
  • packages/rules/src/runner.ts: applies whatever the dedupe returns, for any rule. The UNAUTHENTICATED_API_RULE_ID special case is removed and no new one is added.
  • packages/rules/src/security/field-key.ts (new): turns the auth path (users[0].password, masked *) and the json path ($.users[].password, quoted keys) into one key. A path cut at the length cap matches nothing, so its finding is kept.
  • json-sensitive-fields.ts: an endpoint the auth rule also probes (same path, no query string) is read from the shared anonymous GET, so the audit requests it once. An answer over 256 KB is requested again with the rule's 1 MB cap. dropFieldsReportedElsewhere removes only the overlapping items, then rebuilds the check's kinds, message and fields count. If nothing is left the check is removed. A run left with no finding reads clean (reportedBy, reportedElsewhere) unless it was incomplete. json-bulk-pii is never touched.

Acceptance criteria

  • One finding per field, the auth rule's (the more specific one). This is written down in the endpoint-dedupe.ts header, the json-sensitive-fields.ts header and both rule pages. Tests in packages/rules/tests/json-auth-dedupe-2083.test.ts: "a plaintext password on /api/account is one finding (auth-endpoint-disclosure) and one request (json rule first / auth rule first)", which runs the real RuleRunner.runSiteRules.
  • The endpoint is requested once per audit. The same tests assert accountRequests === 1. So does the e2e test packages/audit-engine/tests/json-auth-dedupe-2083-e2e.test.ts (real crawler, store, discovery and runner, v1 and v2).
  • /api/account fixture: one finding and one request, in either rule order. Covered by the tests above, both orders.
  • Neither rule's other findings change. "json-sensitive-fields keeps the fields auth-endpoint-disclosure does not report (both orders)": the auth result equals the auth rule run alone, and the json items equal the json rule alone minus $.encrypted_password, with fields reduced by 1. Also "bulk personal data on the endpoint stands" and "a field on another endpoint, or another field, is untouched".
  • The json finding is kept when the auth rule did not report. "exception thrown" and "runner timeout", both orders, assert the json rule reports the password. With "probe deadline" and "run aborted" the auth rule still reads the shared answer and reports it, so the finding is the auth rule's. Every exit asserts one request and exactly one finding. Further tests cover an auth rule absent from the run, an answer over the shared cap, a waived auth finding, an incomplete run staying not-checked, and the query-normalised key.
  • Fail before. On origin/main the e2e test fails: 2 requests to /api/account (Expected length: 1, Received length: 2), both engines. With the json pair removed from CROSS_RULE_PAIRS, 10 of the 24 rule tests fail.

Gates (at 2bdc3dd)

  • bun run format:check, bun run lint, bun run typecheck: exit 0
  • bun run scripts/test-suites.ts --check: "test suites cover every test file"
  • Touched and related tests by path: 132 pass, 0 fail (2083, 2082, 1886, json-sensitive-fields-1956, auth-endpoint-disclosure, unauthenticated-api, runner-*, the 1886 and 2083 e2e, probe-deadline-1327)
  • bun run scripts/test-suites.ts --run rules: 12542 pass, 24 todo, 0 fail
  • bun run scripts/test-suites.ts --run audit-engine: 2368 pass, 3 skip, 0 fail
  • bun scripts/changelog.ts check and scripts/check-changelog-entries.sh: OK
  • docs/ make validate: exit 0

Residual risk

  • The auth rule lists at most MAX_FIELDS_PER_ENDPOINT items. A field beyond that cap is not matched, so it stays a duplicate. Nothing is ever orphaned by this.
  • A key with control characters is masked by the auth rule but only stripped by the json rule. Those two keys do not match, so both findings are kept (the safe direction).

Agent skill: no change needed (rule output shape unchanged except the clean row's reportedBy/reportedElsewhere details, as on unauthenticated-api).

Hold-list (security rules): planning-gated, stays draft.

@nc9
nc9 marked this pull request as ready for review November 20, 2026 20:43
… and auth-endpoint-disclosure, deduped by the runner #2083

json-sensitive-fields reports every field on its own and reads an endpoint
auth-endpoint-disclosure also probes from the shared anonymous GET (one
request per audit). The runner's cross-rule dedupe gains a second pair in
CROSS_RULE_PAIRS (endpoint-dedupe.ts): a field the auth rule reported on the
same endpoint (anonymousGetUrl key) leaves json-sensitive-fields' check, which
is rebuilt from the fields left. runner.ts applies every pair generically.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the boat/dedupe-sensitive-fields-2083 branch from 658eea6 to 2bdc3dd Compare November 20, 2026 21:34
@nc9 nc9 changed the title fix(rules): one finding and one request when json-sensitive-fields and auth-endpoint-disclosure read the same field #2083 fix(rules): one finding per leaked field across json-sensitive-fields and auth-endpoint-disclosure, deduped by the runner #2083 Nov 20, 2026
…n-sensitive-fields keeps its finding #2083

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 merged commit 8935250 into main Nov 20, 2026
8 of 15 checks passed
@nc9
nc9 deleted the boat/dedupe-sensitive-fields-2083 branch November 20, 2026 22:55
nc9 added a commit that referenced this pull request Nov 21, 2026
* origin/main:
  test(audit-engine): carriedCheckAsFailure keeps the continuation mark #2098 (#2166)
  fix(rules): correct zoom-disabled 1.4.4 wording, related criteria for wcagNone rules #2115 (#2174)
  refactor(cli): list bash completion flags one per line #2116 (#2175)
  feat(rules): waive a public Supabase table by bare name in security/supabase-rls #2103 (#2177)
  test(rules): every site rule emits a check on a clean site, with a shrinking baseline #1741 (#2179)
  feat(rules): report each 5xx page as its own crawl/server-errors finding #2130 (#2181)
  fix(rules): one finding per leaked field across json-sensitive-fields and auth-endpoint-disclosure, deduped by the runner #2083 (#2154)
  fix(cli): report --input keeps meta.partialAudit and publishes with it #2102 (#2153)
  fix(cli): local incremental re-audit counts carried findings in the full audit's check units (#2159)
  fix(crawler): cap stored entity refs and edges, skip corrupt refs rows #2135 (#2158)
  fix(crawler): a quick crawl fetches the start URL when a sitemap lists it past maxPages #2127 (#2157)
  fix(rules): security/exposed-actuator reads a 5xx through isUnverifiedReply, never part of a pass #2101 (#2151)
  fix(rules): hold large text to 3:1 in a11y/color-contrast #2105 (#2155)
  fix(cli): size the report list date column from rendered dates #2095 (#2152)

Signed-off-by: Nik Cubrilovic <[email protected]>
nc9 added a commit that referenced this pull request Nov 21, 2026
* origin/main:
  test(audit-engine): carriedCheckAsFailure keeps the continuation mark #2098 (#2166)
  fix(rules): correct zoom-disabled 1.4.4 wording, related criteria for wcagNone rules #2115 (#2174)
  refactor(cli): list bash completion flags one per line #2116 (#2175)
  feat(rules): waive a public Supabase table by bare name in security/supabase-rls #2103 (#2177)
  test(rules): every site rule emits a check on a clean site, with a shrinking baseline #1741 (#2179)
  feat(rules): report each 5xx page as its own crawl/server-errors finding #2130 (#2181)
  fix(rules): one finding per leaked field across json-sensitive-fields and auth-endpoint-disclosure, deduped by the runner #2083 (#2154)
  fix(cli): report --input keeps meta.partialAudit and publishes with it #2102 (#2153)
  fix(cli): local incremental re-audit counts carried findings in the full audit's check units (#2159)
  fix(crawler): cap stored entity refs and edges, skip corrupt refs rows #2135 (#2158)
  fix(crawler): a quick crawl fetches the start URL when a sitemap lists it past maxPages #2127 (#2157)
  fix(rules): security/exposed-actuator reads a 5xx through isUnverifiedReply, never part of a pass #2101 (#2151)
  fix(rules): hold large text to 3:1 in a11y/color-contrast #2105 (#2155)
  fix(cli): size the report list date column from rendered dates #2095 (#2152)

Signed-off-by: Nik Cubrilovic <[email protected]>
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.

Cross-rule dedupe: json-sensitive-fields and auth-endpoint-disclosure both report one leaked password field

1 participant