Skip to content

Bind consent round-trips to request data via a stable key - #20

Merged
daniloc merged 1 commit into
mainfrom
consent-key-binding
Jul 4, 2026
Merged

Bind consent round-trips to request data via a stable key#20
daniloc merged 1 commit into
mainfrom
consent-key-binding

Conversation

@daniloc

@daniloc daniloc commented Jul 4, 2026

Copy link
Copy Markdown
Owner

What

The MCP consent round-trip armed/confirmed on a key built inline in session.ts as consent:${pattern}:${op}:${JSON.stringify(data)}. Two gaps:

  1. No tested home — the key construction was an inline expression; an edit to it was invisible to the suite.
  2. Property-order sensitivityJSON.stringify is 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

  • Extract consentKey(pattern, op, data) into mutate-gate.ts (the pure consent-decision home, alongside mutateGate/findGatedBatchOp).
  • 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.

Provenance

Surfaced by a max-effort /code-review of 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

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
@daniloc
daniloc merged commit bcd2bb4 into main Jul 4, 2026
4 of 5 checks passed
@daniloc
daniloc deleted the consent-key-binding branch July 4, 2026 15:45
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.

1 participant