Repository navigation
fix(mcp): hash _meta, and re-baseline instead of alerting on every server - #144
Merged
Merged
Conversation
…rver Closes #142. `_VOLATILE` held `_meta`, so it was stripped before hashing and a listing with instructions planted in a tool's `_meta` hashed identically to a clean one. Not a weakened signal, an absent one: neither the listing digest nor the per-tool digests added in 0.6.0 moved at all. baseline 4b40e8ff9183c727 with poisoned _meta 4b40e8ff9183c727 `_meta` rides on the tool object, reaches clients, and whether it reaches the model is client-dependent. That makes it the obvious place to move behaviour-bearing text once descriptions are being watched. The rules here are public on purpose, so the exemptions were public too, and an exemption in a published detector is a published bypass. The exemption was not careless. A test pinned it, and its docstring said servers stamp `_meta` per call so hashing it would alert on every reconnect. That conflated the `_meta` on a request or result envelope, which can carry per-call bookkeeping, with the `_meta` on a tool definition inside tools/list, which describes the tool. Only the second is hashed here. Same shape as the trait bug and the pydantic bug: a reasonable-looking decision that removed signal and passed its tests because the tests shared its assumption. The migration is the half that could have done real damage. Changing what is hashed invalidates every stored baseline, so shipping this alone would report a rug pull on every server every user had ever observed, on upgrade day, and teach them the alert is noise. FINGERPRINT_VERSION is stamped on each record and a baseline computed under an older version re-baselines as `new` rather than reporting `changed`. A fix that causes a fleet-wide false positive is not a fix. _VOLATILE is now empty and documented to stay that way. Adding a key needs evidence that it genuinely varies per call on a real server, naming the server. "It looks like metadata" is how the last entry got in. Store format 2 -> 3. Ruleset fingerprint unchanged at 15846a0915769d4a, since core/diagnostics is not part of it. Reported by @Santoshkumarpuppala, who noted the same defect exists by design in their own implementation. Co-Authored-By: Claude Opus 5 <[email protected]>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Closes #142.
The bypass
_VOLATILEheld_meta, so it was stripped before hashing. A listing with instructions planted in a tool's_metahashed identically to a clean one:Not a weakened signal. An absent one. Neither the listing digest nor the per-tool digests added in 0.6.0 moved at all.
_metarides on the tool object, reaches clients, and whether it reaches the model is client-dependent. So it is the obvious place to move behaviour-bearing text once descriptions are being watched. The rules here are public on purpose, which means the exemptions were public too, and an exemption in a published detector is a published bypass.How it got in
Not carelessly. A test pinned it, and its docstring read:
That conflated two different things called
_meta: the one on a request or result envelope, which can carry per-call bookkeeping, and the one on a tool definition insidetools/list, which describes the tool. Only the second is hashed here.Same shape as the trait bug and the pydantic bug this repository already documents: a reasonable-looking decision that removed signal and passed its tests because the tests shared its assumption.
The migration is the half that could have done damage
Changing what is hashed invalidates every stored baseline. Shipping the fix alone would have reported a rug pull on every server every user had ever observed, on upgrade day, and taught them the alert is noise.
FINGERPRINT_VERSIONis stamped per record. A baseline computed under an older version re-baselines asnewrather than reportingchanged. A fix that causes a fleet-wide false positive is not a fix.Tested both directions: an old-format store re-baselines, and a genuine
_metapoison after that re-baseline is still caught aschanged._VOLATILEis now empty, deliberatelyThe bar for adding a key is evidence that it genuinely varies per call on a real server, naming the server. "It looks like metadata" is how the last entry got in, and it cost the detection. A test asserts the set stays empty.
Residual risk, stated rather than assumed away: a server that really does stamp varying data into a tool's
_metawill now churn the digest. The remedy is a specific path exemption with evidence, not a blanket one.Verification
15846a0915769d4a, sincecore/diagnosticsis not part of it, so the dogfood clock is untouchedReported by @Santoshkumarpuppala, who noted the same defect exists by design in their own implementation. Reporting a hole you also have is the useful kind of review.
🤖 Generated with Claude Code