Repository navigation
fix(mcp-client): refuse a secret variable in mcp.json - #3133
Merged
Merged
Conversation
Windows reads environment names without regard to case, so
${rig_secret_crypt} read RIG_SECRET_CRYPT there.
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.
fix(mcp-client): refuse a secret variable in mcp.json
Description
An
mcp.json(project.rig/mcp.jsonor the user's) could name a rig secret, such as${RIG_SECRET_CRYPT}, in a server'sheaders,env,args,command,cwdorurl. rig expanded it and sent the secret to that server. A project'smcp.jsoncomes with the checkout, so a cloned repository could ship a server that receives the secret.Now
${VAR}and${VAR:-default}whoseVARstarts with the harness's secret prefix (rig_harness_protocol::env::SECRET_PREFIX,RIG_SECRET_) are refused by name, in any letter case (Windows reads${rig_secret_crypt}asRIG_SECRET_CRYPT), whether or not the variable is set. The server does not start, and the error names the field and the variable:Every other variable expands as before. A lower or mixed-case
rig_secret_*name, a distinct variable on Linux and macOS, is refused too.The README's
envrow also said a server gets rig's environment "without rig's secrets (API keys)". OnlyRIG_SECRET_*and agent-only variables are removed; provider API keys from the shell do reach the server. The row now says that.${RIG_SECRET_*}inmcp.jsonsends the secretconfig::tests::a_secret_variable_is_refused_by_name_and_never_expanded(fails on the test commit: the variable expands or is reported unset)Changelog
${RIG_SECRET_*}in anmcp.jsonis refused, naming the field and the variable, in any letter case, instead of being expanded and sent to the server.Migration
An
mcp.jsonthat named aRIG_SECRET_*variable now fails to start that server; pass the value through a variable of its own instead.Type of change
Testing
cargo nextest run -p rig-mcp-client a_secret_variable_is_refused_by_name_and_never_expanded: fails on the test commit, passes on the headcargo xtask verify --affected --base origin/mainChecklist:
CHANGELOG.mdorMIGRATING.md(they are generated at release)Notes
rig_harness::harness_protocol::env::SECRET_PREFIX, through the existingrig-harnessdependency; no new dependency, no public API change.config.rs), README +2 −2, tests +24.${rig_secret_crypt:-none}case for the letter-case refusal (no new test).rigagainst logging HTTP and stdio MCP servers on main and this PR (headers, url, env, args, command, user and project scope,/mcp add): leaked on main, refused here;${HOME}and defaults unchanged.