fix(agent): const-time bearer + scope gates#389
Merged
Conversation
Closes #301, #304, #305, #311. - server.rs:235 bearer compare now uses subtle::ConstantTimeEq with length pre-check (timing-side-channel safe). - server.rs:166 read_resource gates on scope.allows_resource before delegating, matching call_tool's rejection pattern. - main.rs adds --scope {messaging,read,full}, defaulting to Messaging (least privilege) instead of Full via Default. Verified: cargo check / fmt / clippy -D warnings (willow-agent).
This was referenced Apr 27, 2026
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
==#301 + [SEC-A-01] Bearer token compared with non-constant-time equality #304 —crates/agent/src/server.rs:235bearer compare now usessubtle::ConstantTimeEqwith length pre-check. No early-exit on length mismatch, no byte-by-byte timing leak.read_resourcedoes not enforceallows_resourcescope #305 —crates/agent/src/server.rs:166read_resourcegates onscope.allows_resource(&request.uri)before delegating, mirroringcall_tool's rejection (ErrorCode::INVALID_REQUEST).crates/agent/src/main.rs:156adds--scope {messaging,read,full}(clapValueEnum), defaulting toMessaging(least privilege) instead ofDefault::default()(which wasFull). Threaded intoserve_http.closes #301 #304 #305 #311
Test plan
cargo check -p willow-agent— passcargo fmt -p willow-agent— cleancargo clippy -p willow-agent -- -D warnings— passGenerated by Claude Code