Treat stdio server env variables as secrets like HTTP headers - #342
Draft
jancurn wants to merge 1 commit into
Draft
Treat stdio server env variables as secrets like HTTP headers#342jancurn wants to merge 1 commit into
jancurn wants to merge 1 commit into
Conversation
jancurn
force-pushed
the
claude/security-issue-341-k4fjo3
branch
from
August 2, 2026 11:45
47b8799 to
b91021f
Compare
A config entry's `env` routinely holds API tokens — directly or via `${VAR}`
substitution — but only `headers` were protected. Resolved `env` values were
written to `sessions.json` in plaintext, printed verbatim by `mcpc --json
@session` / `connect --json`, and passed to the bridge in its command line,
where `ps` exposed them.
They now follow the exact same path as headers: stored in the OS keychain
(`session:<name>:env`), redacted to `<redacted>` in `sessions.json` and all
`--json` output, and delivered to the bridge over IPC after spawn. The bridge
merges them back into the stdio transport config, so servers still get their
environment unchanged. Sessions written before this change keep working —
their on-disk plaintext is used as is; recreate a session to move its values
into the keychain.
Rebuilt on main after the draft branch was squashed in as #316.
Fixes #341
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rmdd458q2Bx68bPxuUtQGa
jancurn
force-pushed
the
claude/security-issue-341-k4fjo3
branch
from
August 6, 2026 09:58
b91021f to
2aaa415
Compare
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.
A stdio server's
envroutinely holds API tokens (directly or via${VAR}substitution), but onlyheaderswere protected. Resolvedenvvalues were written tosessions.jsonin plaintext, printed verbatim bymcpc --json @session, and — not in the issue but worse — passed in the bridge's command line, wherepsexposed them. They now follow the exact same path as headers.session:{name}:env), removed with the sessionsessions.jsonand every--jsonoutput (documented in the help and docs/REFERENCE.md)stdio/env-securitye2e suite proves the secret is absent fromps,sessions.json, both--jsonshapes, the bridge log and verbose output, while anecho-envtool confirms it still reaches the serverFixes #341
https://claude.ai/code/session_01Rmdd458q2Bx68bPxuUtQGa