You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hardening follow-ups split out of the vMCP authz-gate PR (#5841, fixes #5827) so they don't hold up the 403 fix. All three are reviewer notes that don't affect current correctness.
1. Unify the gate's parse source with the enforced parse (argument-conditional policies)
pkg/vmcp/server/call_gate.go authorizes tools/call on parsed.Arguments (decoded by pkg/mcp's parser), while dispatch re-authorizes on the SDK's decode of the same request bytes. Both are encoding/json over identical bytes, so they agree for plain JSON today. If the decoders ever diverge (json.Number vs float64, a future typed-params path, duplicate-key handling), an argument-conditional Cedar policy could have the gate ALLOW while the call path DENIES — re-introducing the exact 200 + IsError this PR removed (or a spurious 403). Make the gated decision and the enforced decision derive from a single parse (e.g. carry the gate's decision forward, or share one decoded argument map). Raised by @rdimitrov.
2. Fail-loud collision check for the execute_tool_script reserved name
pkg/vmcp/codemode/decorator.go's CheckToolCall admits execute_tool_script unconditionally by name. If a backend ever advertised a real tool literally named execute_tool_script, it would be shadowed at ListTools/LookupTool and its Cedar policy would never run. The name is effectively reserved for the codemode virtual tool, but nothing enforces that. Add a fail-loud collision check at aggregation/ListTools time so a real backend tool with that name is a loud error, not a silent shadow. Raised by @jhrozek.
3. Verb parity between the vMCP gate and thv run's authz middleware
thv run's authz middleware denies elicitation/create, sampling/createMessage, and tasks/* by default (pkg/authz/middleware.go). The vMCP pre-dispatch gate admits them, because the core admission seam has no Cedar entity for these method kinds yet (its default is deliberately fail-open — see the gate's default case). When vMCP grows an admission decision for these verbs, add the matching gate cases so the two paths share one posture. Raised by @jhrozek.
Item 1 is the one I would not leave as a "if the decoders ever diverge" — they already do, and the divergence is cheap to trigger.
Go's encoding/json decodes every JSON number into float64 unless the decoder is explicitly put into UseNumber() mode. Two decode paths over identical bytes therefore disagree the moment a policy compares a numeric argument, because one side has a json.Number carrying the literal and the other has a float that has already lost it. 10000000000000001 round-trips through float64 as 10000000000000000; an argument-conditional Cedar policy with a threshold between those two values gates on one number and enforces on another. Duplicate keys are the second one: encoding/json keeps the last occurrence, and a parser that keeps the first gives the gate a different object than the dispatcher sees, from the same bytes.
That is not theoretical for me — I hit it 48 hours ago writing an RFC 8785 canonicalizer, where the whole reason the spec exists is that two conforming JSON parsers do not agree on a canonical form without being told to.
So the structural fix you propose is the right one, and I would state the invariant slightly more strongly than "share one decoded argument map": the decision and the effect must derive from the same object, not from two parses of the same bytes. The failure mode when they do not is not a wrong answer, it is a consistent-looking wrong answer — the gate's log says ALLOW, the dispatcher's says DENY, both are internally correct, and nothing in either record shows the two were reasoning about different values. I shipped that defect in my own enforcement point: a policy refusal was persisted as an allow because a cache path built the record separately from the path that enforced. Both paths were individually right.
On item 3, the asymmetry is the part I would prioritise over the parity work itself. thv run denies elicitation/create, sampling/createMessage and tasks/*; the vMCP gate admits them by default. That means the newer path is the permissive one, and server-initiated requests are exactly the surface where the trust direction inverts — a server asking the client's model to run a completion is not a tool call and no tool-call gate sees it. Worth a test that asserts the two paths report the same posture for the same verb, so the next verb added does not quietly land on the fail-open side.
On item 2, a byte-equality collision check on execute_tool_script catches the honest collision and not the interesting one. A backend advertising execute_tool_scrіpt — Cyrillic і, U+0456 — is not equal to the reserved name under ==, so it passes the guard, and then it is indistinguishable from the real thing to a model reading a list. Folding the name to a confusable skeleton before comparing catches both cases with the same check. I flag that class at discovery and it is one of the few rules that fires on real-world catalogs rather than only on crafted ones.
Activity
Harden vMCP authz gate: single parse source and reserved-name check (#…
Santoshkumarpuppala commentedon Sep 2, 2026
Item 1 is the one I would not leave as a "if the decoders ever diverge" — they already do, and the divergence is cheap to trigger.
Go's
encoding/jsondecodes every JSON number intofloat64unless the decoder is explicitly put intoUseNumber()mode. Two decode paths over identical bytes therefore disagree the moment a policy compares a numeric argument, because one side has ajson.Numbercarrying the literal and the other has a float that has already lost it.10000000000000001round-trips throughfloat64as10000000000000000; an argument-conditional Cedar policy with a threshold between those two values gates on one number and enforces on another. Duplicate keys are the second one:encoding/jsonkeeps the last occurrence, and a parser that keeps the first gives the gate a different object than the dispatcher sees, from the same bytes.That is not theoretical for me — I hit it 48 hours ago writing an RFC 8785 canonicalizer, where the whole reason the spec exists is that two conforming JSON parsers do not agree on a canonical form without being told to.
So the structural fix you propose is the right one, and I would state the invariant slightly more strongly than "share one decoded argument map": the decision and the effect must derive from the same object, not from two parses of the same bytes. The failure mode when they do not is not a wrong answer, it is a consistent-looking wrong answer — the gate's log says ALLOW, the dispatcher's says DENY, both are internally correct, and nothing in either record shows the two were reasoning about different values. I shipped that defect in my own enforcement point: a policy refusal was persisted as an allow because a cache path built the record separately from the path that enforced. Both paths were individually right.
On item 3, the asymmetry is the part I would prioritise over the parity work itself.
thv rundenieselicitation/create,sampling/createMessageandtasks/*; the vMCP gate admits them by default. That means the newer path is the permissive one, and server-initiated requests are exactly the surface where the trust direction inverts — a server asking the client's model to run a completion is not a tool call and no tool-call gate sees it. Worth a test that asserts the two paths report the same posture for the same verb, so the next verb added does not quietly land on the fail-open side.On item 2, a byte-equality collision check on
execute_tool_scriptcatches the honest collision and not the interesting one. A backend advertisingexecute_tool_scrіpt— Cyrillicі, U+0456 — is not equal to the reserved name under==, so it passes the guard, and then it is indistinguishable from the real thing to a model reading a list. Folding the name to a confusable skeleton before comparing catches both cases with the same check. I flag that class at discovery and it is one of the few rules that fires on real-world catalogs rather than only on crafted ones.