Repository navigation
fix(rules): one finding per leaking endpoint, deduped after the site pass (#2082) - #2164
Merged
Merged
Conversation
…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]>
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.
Closes #2082. Follow-up to #1886. Hold tier (security rule): Nik decides the merge after planning's review.
What changed
security/unauthenticated-apino longer hands a leaking current-user endpoint tosecurity/auth-endpoint-disclosure. It reports every endpoint it finds. TheunreadByAuth/authRuleLeftUnreadbookkeeping and thedeferredToAuthcount 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 (v1runRulesOnStorage, v2 streaming) call this method, so the dedupe sits in the runner rather than inpackages/audit-engine. It runs beforechecksandruleResultsare assembled, so nothing downstream (store, tallies, score) ever sees the dropped finding.anonymousGetUrl(probe-http.ts:147): the normalised URL (query and fragment dropped) that both rules already request throughbuildAnonymousGet.dropEndpointsReportedElsewhere(unauthenticated-api.ts:1098) rebuilds a tier check from its remaining items (count, message,details.endpoints) through the sametierCheckthe rule uses. A tier check with nothing left is removed. A run with no finding left that verified every endpoint reads clean, withdetails.reportedBy/reportedElsewhere. An incomplete run stays not-checked. The only pre-dedupe count is theSQUIRREL_RULE_PROFILEdebug 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 theexception thrown/runner timeoutcases 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.tsdescribe "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-disclosurerun aborted, api rule first/auth rule first: by auth-endpoint-disclosureexception thrown, api rule first/auth rule first: by unauthenticated-apirunner timeout, api rule first/auth rule first: by unauthenticated-apiEach also asserts that
/api/mewas requested once and that the flatcheckslist matchesruleResults.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.tssends both rules' results throughdedupeEndpointFindings(throughDedupe), and a disabled auth rule no longer runs (as in the runner). Expectation changed in one place:deferredToAuth: 1becamereportedBy+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.mdGates (all local, foreground)
bun run format:checkexit 0,bun run lintexit 0,bun run typecheckexit 0bun run scripts/test-suites.ts --check: test suites cover every test filebun 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 passAgent skill
No change needed: no CLI flags or output format changed. One JSON detail did change: the unauthenticated-api pass row's
deferredToAuthis nowreportedBy/reportedElsewhere. No report schema field was added.