Repository navigation
fix(cli): the MCP guard refuses a field it cannot read instead of reading it as absent (TASK-069) - #1915
Merged
Conversation
…ding it as absent (TASK-069) The row asks `auditDeclaredMcp` to judge the whole ENTRY rather than selected fields. The two shapes it names are already refused on main: #1744 refuses an http/sse entry that carries a command and refuses a shipped command carrying NODE_OPTIONS / npm_config_registry / PATH, and #1764 makes the adapters classify by the declared transport. What is left of the class is the TYPE of a field: the entry is admitted on the strength of the fields that read as expected, and a field the guard cannot read is silently read as absent instead of refused. Measured on main, accepted before this commit: env as a string ('NODE_OPTIONS=--import=data:...') -> accepted as "the shipped entry" args as a string -> accepted headers as a string (with ${COMMONLY_AGENT_TOKEN}) -> accepted env value undefined (CANONICAL_STDIO_ENV[k] === v) -> accepted, undefined === undefined Every reader spreads those fields, so the adapters I read mangle the value rather than honour it: deliverSeatCredential does { ...server.env }, which turns a string into single-character keys, and claude/codex emit that object verbatim. So no live execution was found through the shapes above - the defect is that the predicate is unsound, which is what a future consumer (or a runtime this CLI does not ship) would need to be to turn it back into one. Fail closed instead.
…ch drops Vera's hold on #1915. `executionShape` reads cwd as `typeof server.cwd === 'string' ? server.cwd : null`, so an unreadable cwd normalised to the installed entry's absent cwd, the two shapes compared equal, and the entry was admitted as one the operator already installed. Measured on the previous head against an installed allow-list: cwd 1, ['/tmp/evil'], { dir: … } and true were all ACCEPTED; a string cwd was refused only because it differed from the installed one. Now refused with the same shape message as env/headers/args. A string cwd is still judged by value, not banned: the same string on both sides is the installed entry and is admitted, a different string is refused by the whole-entry match — the control that keeps this a shape rule rather than a ban on the field. No adapter forwards a declared cwd (buildMcpConfig emits type/url/command/args/env/ headers), so this is unsound-and-unreachable, as the env cases were unsound-and-mangled: the guard is the layer that has to hold when the layer above changes.
…must move with it connector-ops (74373): main and npm latest are both 0.1.74, so the shape rule would have reached the repo and zero seats. Folded into the push that carries Vera's cwd fix, so the head is green in one round.
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
cli/src/lib/declared-mcp-guard.js— a declared MCP entry whoseenv,headersorargscannot be read is now refused, instead of being read as absent.The row's two named shapes are already refused on main — measured
maintoday{transport:'http', command:[…]}, no urlhttp entry carries a command{transport:'sse', command:[…]}{transport:'HTTP' | 'https' | 'websocket', command:[…]}unknown transport(fail-closed; the guard compares the string exactly)env.NODE_OPTIONScarries env/args/cwd beyond the shipped server's own (NODE_OPTIONS)env.npm_config_registryenv.PATHProbe:
auditDeclaredMcpcalled directly on each shape.#1744(merged 2026-09-19T15:09) is the PR this row already links, and its merged guard refuses both —#1764(12:54) added the adapter half (an entry declaring a non-stdio transport is skipped even when it carries a command, Vera 69774, plus the pi rule that an unknown transport is never normalised into an admitted one). So the row text describes the defect those two fixed.What is left of the class, and what this changes
The entry was admitted on the strength of the fields that read as expected, while a field the guard cannot read was read as absent:
mainbeforeenv: 'NODE_OPTIONS=--import=data:text/javascript,1'env is a string, not an objectheaders: 'X-Token: ${COMMONLY_AGENT_TOKEN}'headers is a string, not an objectargs: '--import=data:text/javascript,1'args is a string, not an arrayenv: { NODE_OPTIONS: undefined }undefined === undefinedinCANONICAL_STDIO_ENV[key] === value)env.NODE_OPTIONS is not a stringcwd: 1/['/tmp/evil']/{…}/trueexecutionShapereads cwd astypeof === 'string' ? … : null, so it normalised to the installed entry's absent cwd)cwd is of type number, not a stringenv: null;args: []Severity, stated honestly: no live execution was found. Every reader spreads these fields —
deliverSeatCredentialdoes{ ...server.env }, which turns a string into single-character keys, and claude/codex emit that object verbatim — so the shapes above are mangled rather than honoured by the adapters I read. The defect is that the predicate is unsound: it admits an entry whose meaning it did not establish, and the consumer that parses the string instead of spreading it is the one that would honour it. That is the same reading as the row's title, one field type further out.Witness (mutation ledger)
Each branch removed in turn, whole file run, one run per arm:
unreadableFieldcall removedcwdcwdbranch disabledcwd(the string-cwdcontrol stays green)cwdbanned outright rather than type-checkedcwdcontrolThe controls stay green in arms 1–5, which is what makes the reds attributable; arm 6 reds a control on purpose, because that is the arm that would turn this into a ban on
cwdrather than a rule about values it cannot read.The
cwdfield (Vera's hold, measured on the previous head)executionShapenormalised an unreadablecwdtonull, which equals the installed entry's absentcwd, so the entry was admitted as one the operator already installed. Against an installed allow-list:cwd: '/tmp/evil'refused (by value), and1/['/tmp/evil']/{ dir: … }/trueaccepted. Now all four are refused with the shape message. A stringcwdis judged by value, not banned: the same string on both sides is the installed entry and is admitted, a different string is refused by the whole-entry match. No adapter forwards a declaredcwd(buildMcpConfigemitstype/url/command/args/env/headers), so this was unsound-and-unreachable where the env cases were unsound-and-mangled — held anyway because the guard is the layer that has to hold when the layer above changes. Restored: 20/20 in the file, 49 suites / 876 passed / 10 skipped / 0 failed across the CLI suite, eslint clean.Not done
backend/utils/environmentSpecValidation.ts. The daemon's layer is the one that holds when the server is wrong (the guard's own header says so), so the shape rule belongs here first; say the word if you want the writer gated too.prUrlstill points at#1744; this is the residual of that row rather than a new one.Gate
@vera — security-adjacent CLI guard, so you by default. Her hold landed on
e7e26c37; thecwdfix is61743d0band the version bumpdb37a1b6(cli0.1.74 → 0.1.75, connector-ops 74373: the guard'ssrcmoved, so the published version has to move with it).