fix(security): boundary-aware Capability.resourceCovers + fail-closed empty with (#585)#589
Merged
Merged
Conversation
… empty `with` (#585) Capability.resourceCovers matched a granted resource against a requested one with a raw string startsWith and no path-segment boundary, so a grant on `w/notes` also covered siblings like `w/notesSECRET` / `w/report-confidential` — a UCAN attenuation / delegation escape (cross-tenant over-read/over-write where delegation is used). Separately, a null/empty `with` was treated as "covers every resource" (fail-open), turning a malformed or truncated capability into a superuser grant. Fix: - resourceCovers now requires a path-segment boundary on the prefix branch (mirroring the already-correct abilityCovers): the prefix matches only when the grant ends with '/' or the next char in the request is '/'. Exact match and trailing-slash-parent are preserved; genuine children (`w/notes/x`) still match. - Both resourceCovers and covers now fail closed on null/empty grant or request `with`. An absent resource pointer is never a wildcard. Tests (CapabilityTest): adversarial sibling-escape and empty/null-`with` superuser cases, plus genuine-child/exact regressions. The five existing tests that asserted the fail-open behaviour are flipped to expect fail-closed. Confirmed all seven adversarial assertions fail against the pre-fix code. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes #585.
Vulnerability
Capability.resourceCoversmatched a granted resource against a requested one with a rawstartsWithand no path-segment boundary, so a grant onw/notesalso covered siblings likew/notesSECRET/w/report-confidential— a UCAN attenuation / delegation escape (cross-tenant over-read/over-write where delegation is used). Separately, a null/emptywithwas treated as "covers every resource" (fail-open), turning a malformed or truncated capability into a superuser grant.This is the companion to #586 (the JWT issuer-spoofing fix): #586 made the token layer sound; this makes the authorization-decision layer underneath it sound.
Fix
resourceCoversnow requires a path-segment boundary on the prefix branch (mirroring the already-correctabilityCovers): the prefix matches only when the grant ends with/or the next char in the request is/. Exact-match and trailing-slash-parent are preserved; genuine children (w/notes/x) still match.resourceCoversandcoversnow fail closed on null/empty grant or requestwith. An absent resource pointer is never a wildcard.w/notesw/notes/childw/notesw/notesSECRET""/ nullw/anythingTests
CapabilityTestgains adversarial sibling-escape and empty/null-withsuperuser cases, plus genuine-child/exact regressions. The five existing tests that asserted the fail-open behaviour are flipped to expect fail-closed. Confirmed all seven adversarial assertions fail against the pre-fix code.convex-core: 2135 pass.
🤖 Generated with Claude Code