`Client::Stdio` passes the whole parent environment to the server process
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 55/100
Rechercherichtung
Read lib/mcp/client/stdio.rb at lines 169–170 and the transport documentation in docs/_client/transports.md; compare the environment behavior with the TypeScript and Python SDKs mentioned in the issue. Reproduce the leak with the provided Ruby script, then add coverage for the intended inheritance behavior. Done when only the documented environment reaches the server and the compatibility behavior is documented.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Client::Stdio#start spawns the server with Open3.popen3(@env || {}, @command, *@args) (stdio.rb:169-170). Process.spawn merges that hash into the inherited environment, so the server gets every variable of the host process (API keys, cloud credentials, tokens), not only the ones in env:.
docs/_client/transports.md describes env: as "A hash of environment variables to set for the server process" and does not say that the rest is inherited. The TypeScript SDK (DEFAULT_INHERITED_ENV_VARS in packages/client/src/stdio.ts) and the Python SDK (get_default_environment() in src/mcp/client/stdio.py) start from a short default list instead.
Repro
Run from the repository root with bundle exec ruby -I lib repro.rb:
require "mcp"
ENV["HOST_ONLY_SECRET"] = "from-host"
transport = MCP::Client::Stdio.new(
command: "/bin/sh",
args: ["-c", 'printf "%s\n" "$HOST_ONLY_SECRET"'],
env: { "SERVER_SETTING" => "1" },
)
transport.start
p transport.instance_variable_get(:@stdout).gets
transport.close
Expected: "\n". Only SERVER_SETTING and a small base environment reach the server.
Actual: "from-host\n"
Suggested fix
Spawn with unsetenv_others: true and a default allow-list (for example HOME, LOGNAME, PATH, SHELL, TERM, USER), merged with env:. Add an option to inherit the full environment for applications that need it, and document the behavior. This changes behavior for applications that rely on inheritance, so it may need a deprecation step or a release note.
- Vorherrschende Sprache
- Ruby
- Sterne
- 940
- Forks
- 143
- Ø Merge
- 1 T. 3 Std.
- Gemergte PRs (30 T.)
- 47
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/ruby-sdk
-
Invalid UTF-8 in `MCP-Protocol-Version`, `Mcp-Method` or `Mcp-Name` gives 500 instead of 400Evtl. vergeben @atesgoral hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
modelcontextprotocol/ruby-sdk#663 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Elicitation results are not checked against `requested_schema`, but the docs say they match itEvtl. vergeben @atesgoral hat das heute übernommen. Offenbug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
modelcontextprotocol/ruby-sdk#661 ·
Maintainer antworten meist innerhalb von 1 Tag
-
HTTP client sends handler exception messages back to the serverEvtl. vergeben @atesgoral hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
modelcontextprotocol/ruby-sdk#660 ·
Maintainer antworten meist innerhalb von 1 Tag
-
`JWTVerifier` answers 500 instead of 401 for a PS256 token when it verifies with an EC key (jwt < 3.3.0)Evtl. vergeben @atesgoral hat das heute übernommen. Offenbug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
modelcontextprotocol/ruby-sdk#659 ·
Maintainer antworten meist innerhalb von 1 Tag
-
`logging/setLevel` from one session changes the log level of other sessionsEvtl. vergeben @atesgoral hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
modelcontextprotocol/ruby-sdk#658 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in modelcontextprotocol/ruby-sdk
Ähnliche Issues
-
bug javascript
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
yegor256/netbout.rb#69 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
yegor256/iccq.github.io#161 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
palladius/rails8-app-on-gcp#198 ·
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 95/100
WikiEducationFoundation/WikiEduDashboard#7258 ·
Maintainer antworten meist innerhalb von 1 Tag