mcpproxy-go icon indicating copy to clipboard operation
mcpproxy-go copied to clipboard

Tool approval hash: unescaped '|' field joins let two different contracts share a hash (rug-pull bypass)

Open Dumbris opened this issue 1 month ago • 0 comments

Summary

The tool-approval (rug-pull) hash calculateToolApprovalHashWithOutputSchema (internal/runtime/tool_quarantine.go) joins name, description and the normalized input schema with an unescaped |, and appends the output schema only when it is present. Different contracts can therefore share a hash:

  • A = description D, input schema I, output schema O
  • B = description D|norm(I), input schema O, no output schema

Both hash name|D|norm(I)|norm(O).

Impact

An approved tool on a trusted server can switch from A to B (new description, the input schema replaced) and stay approved: the approved branch of checkToolApprovals sees ApprovedHash == currentHash, refreshes Current* to B and never marks the record changed. That is a rug-pull bypass.

Reproduced on the Spec 117 PR-2 branch (#1605) with a throwaway runtime test: baseline A on a trusted server, capture B → status=approved, CurrentDescription="Read a note|{\"type\":\"object\"}", CurrentSchema={"type":"string"}.

Scope note

Found during the Sol round-2 review of #1605. That PR fixes only the review fingerprint (rv2, every field length-prefixed), so a review-bound approval can no longer approve B with A's binding. As Spec 117 requires, it leaves the rug-pull hash unchanged. This issue covers the rug-pull hash itself.

Suggested fix

Give the approval hash an unambiguous encoding (length-prefixed fields, or a marker for an absent output schema), with a new ToolApprovalHashSchemaVersion and the existing version-gated migration. The migration must re-baseline only records whose stored contract still matches, the way the output-schema backfill does, and must not force a mass re-review.

Dumbris avatar Oct 12 '26 21:10 Dumbris