Bind consent round-trips to request data via a stable key - #20
Merged
Conversation
The MCP consent round-trip armed/confirmed on a key built inline in
session.ts as `consent:${pattern}:${op}:${JSON.stringify(data)}`. Two gaps:
the construction had no tested home (an edit to it was invisible to the
suite), and JSON.stringify is property-order sensitive — an agent re-issuing
the identical call with reconstructed data in a different key order would arm
a fresh round-trip instead of confirming, and a benign arming could be
redeemed by a differently-ordered call that happens to match.
Extract `consentKey(pattern, op, data)` into mutate-gate.ts (the pure
consent-decision home) and serialize data with sorted keys at every nesting
level (`stableStringify`), so semantically-identical re-issues confirm
regardless of property order. consent-key.test.ts locks the binding: the key
depends on pattern, operation, and data, and is order-insensitive at the top
level and nested.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BaKTAGEWWToMvX3xzgHFZC
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.
What
The MCP consent round-trip armed/confirmed on a key built inline in
session.tsasconsent:${pattern}:${op}:${JSON.stringify(data)}. Two gaps:JSON.stringifyis insertion-order dependent. An agent re-issuing the identical call with data reconstructed in a different key order would arm a fresh round-trip instead of confirming; separately, a benign arming could be redeemed by a differently-ordered call that happens to serialize to the same string.Change
consentKey(pattern, op, data)intomutate-gate.ts(the pure consent-decision home, alongsidemutateGate/findGatedBatchOp).stableStringify), so semantically-identical re-issues confirm regardless of property order.consent-key.test.tslocks the binding: the key depends on pattern, operation, and data, and is order-insensitive at the top level and nested.Provenance
Surfaced by a max-effort
/code-reviewof the working tree (the consentKey ordering bug was the one security-relevant finding across 11 finder angles). This is the review→ratchet loop: review caught it, the property test makes it durable.🤖 Generated with Claude Code