Skip to content

fix(rules): one finding per leaking endpoint, deduped after the site pass (#2082) - #2164

Merged
nc9 merged 2 commits into
mainfrom
fix/auth-endpoint-runner-dedupe-2082
Nov 20, 2026
Merged

nc9 merged 2 commits into
mainfrom
fix/auth-endpoint-runner-dedupe-2082

Conversation

@nc9

@nc9 nc9 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Closes #2082. Follow-up to #1886. Hold tier (security rule): Nik decides the merge after planning's review.

What changed

  • security/unauthenticated-api no longer hands a leaking current-user endpoint to security/auth-endpoint-disclosure. It reports every endpoint it finds. The unreadByAuth / authRuleLeftUnread bookkeeping and the deferredToAuth count are gone.
  • RuleRunner.runSiteRules (packages/rules/src/runner.ts:1081-1091) keeps one finding per endpoint after every site rule has settled. It keeps the auth rule's finding when that rule reported the endpoint, otherwise unauthenticated-api's. Both audit-engine site passes (v1 runRulesOnStorage, v2 streaming) call this method, so the dedupe sits in the runner rather than in packages/audit-engine. It runs before checks and ruleResults are assembled, so nothing downstream (store, tallies, score) ever sees the dropped finding.
  • The key is anonymousGetUrl (probe-http.ts:147): the normalised URL (query and fragment dropped) that both rules already request through buildAnonymousGet.
  • No orphan counts: dropEndpointsReportedElsewhere (unauthenticated-api.ts:1098) rebuilds a tier check from its remaining items (count, message, details.endpoints) through the same tierCheck the rule uses. A tier check with nothing left is removed. A run with no finding left that verified every endpoint reads clean, with details.reportedBy / reportedElsewhere. An incomplete run stays not-checked. The only pre-dedupe count is the SQUIRREL_RULE_PROFILE debug log line, which records what the rule returned.

Acceptance criteria

  • unauthenticated-api reports every leaking endpoint, no hand-off: unauthenticated-api.ts:977-1000. Tests: probe-dedupe-1886.test.ts "with auth-endpoint-disclosure disabled ..." and the exception thrown / runner timeout cases below, where unauthenticated-api's finding is the one kept.

  • Runner keeps one finding per endpoint (auth's when reported, else api's): runner.ts:1081-1091, endpoint-dedupe.ts:52. Tests: endpoint-dedupe-2082.test.ts describe "dropEndpointsReportedElsewhere": partial rebuild, wholly covered reads clean, incomplete stays not-checked, untouched when not covered, query and fragment normalisation, auth rule reported nothing.

  • Both orders × each auth exit, endpoint reported exactly once, through the real RuleRunner.runSiteRules (8 tests, endpoint-dedupe-2082.test.ts:243):

    • probe deadline, api rule first / auth rule first: by auth-endpoint-disclosure
    • run aborted, api rule first / auth rule first: by auth-endpoint-disclosure
    • exception thrown, api rule first / auth rule first: by unauthenticated-api
    • runner timeout, api rule first / auth rule first: by unauthenticated-api

    Each also asserts that /api/me was requested once and that the flat checks list matches ruleResults.
    Fail-before on origin/main (trimmed copy, runner cases only): all 4 throw and timeout cases lose the finding (expected ["security/unauthenticated-api"], received []). The deadline and abort cases report once on main too, as Nik's comment says. They fail on main only on the new clean-row details.
    The runner's budget bounds only a rule's synchronous work (runWithinBudget), which for the auth rule is choosing its candidates. So the timeout case stalls there, which is where a real runner timeout lands.

  • Dedupe: one finding per endpoint across security/unauthenticated-api and security/user-endpoint-overexposure #1886 tests pass through the dedupe:

    • probe-dedupe-1886.test.ts sends both rules' results through dedupeEndpointFindings (throughDedupe), and a disabled auth rule no longer runs (as in the runner). Expectation changed in one place: deferredToAuth: 1 became reportedBy + reportedElsewhere: 1, because the deferral no longer exists and the count now comes from the dedupe. Both orders and the 429 path are unchanged.
    • audit-engine/tests/auth-endpoint-dedupe-1886-e2e.test.ts (v1 and v2, real crawler and runner): the same one-field change.

Docs and changelog

  • docs/rules/security/unauthenticated-api.mdx, "One finding per endpoint", now describes the runner dedupe instead of the hand-off. The auth rule page never described it.
  • changelog.d/2082-auth-endpoint-runner-dedupe.fixed.md

Gates (all local, foreground)

  • bun run format:check exit 0, bun run lint exit 0, bun run typecheck exit 0
  • bun run scripts/test-suites.ts --check: test suites cover every test file
  • bun run scripts/test-suites.ts --run rules: 12518 pass, 0 fail (407 files)
  • bun run scripts/test-suites.ts --run audit-engine: 2365 pass, 0 fail (247 files)
  • bun scripts/changelog.ts check: changelog.d/ OK (3 entries)
  • docs/ make validate: links all good, 71 pass

Agent skill

No change needed: no CLI flags or output format changed. One JSON detail did change: the unauthenticated-api pass row's deferredToAuth is now reportedBy / reportedElsewhere. No report schema field was added.

nc9 added 2 commits November 20, 2026 20:26
…pass (#2082)

security/unauthenticated-api no longer hands a leaking current-user endpoint
to security/auth-endpoint-disclosure: it reports every endpoint it finds.
RuleRunner.runSiteRules then keeps one finding per endpoint, keyed on the
normalised URL both rules request (anonymousGetUrl): the auth rule's when
it reported the endpoint, otherwise unauthenticated-api's. The dropped
finding is removed before checks are collected, stored or scored; a tier
check is rebuilt from its remaining items, and a run left with no finding
reads clean (details.reportedBy / reportedElsewhere).

Before, an auth rule that threw or ran past the runner's budget after the
hand-off left the endpoint with no finding at all.

Signed-off-by: Nik Cubrilovic <[email protected]>
…edElsewhere for JSON consumers (#2082)

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 marked this pull request as ready for review November 20, 2026 21:13
@nc9
nc9 merged commit 2671433 into main Nov 20, 2026
8 of 15 checks passed
@nc9
nc9 deleted the fix/auth-endpoint-runner-dedupe-2082 branch November 20, 2026 21:14
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.

auth-endpoint-disclosure: a deadline or abort before a deferred endpoint loses the finding (#1886 follow-up)

1 participant