`Client::Stdio` passes the whole parent environment to the server process
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Ruby
- Star
- 940
- Fork
- 143
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 48
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/ruby-sdk
-
Invalid UTF-8 in `MCP-Protocol-Version`, `Mcp-Method` or `Mcp-Name` gives 500 instead of 400Có thể đã có người làm @koic đã nhận 1 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/ruby-sdk#663 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Elicitation results are not checked against `requested_schema`, but the docs say they match itCó thể đã có người làm @atesgoral đã nhận 1 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
modelcontextprotocol/ruby-sdk#661 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`JWTVerifier` answers 500 instead of 401 for a PS256 token when it verifies with an EC key (jwt < 3.3.0)Có thể đã có người làm @atesgoral đã nhận 1 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
modelcontextprotocol/ruby-sdk#659 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`logging/setLevel` from one session changes the log level of other sessionsCó thể đã có người làm @atesgoral đã nhận 1 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
modelcontextprotocol/ruby-sdk#658 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Concurrent requests overwrite each other's instrumentation dataCó thể đã có người làm @atesgoral đã nhận 1 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
modelcontextprotocol/ruby-sdk#657 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/ruby-sdk
Issue tương tự
-
test_rescues_connection_reset_on_issue_comments_lookup fails on master and blocks every pull requestĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
zerocracy/judges-action#3142 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Malformed encoded_filters causes a 500, and keeps failing with session persistenceCó thể đã có người làm @officialasishkumar đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
avo-hq/avo#4986 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Visual COBOL: missing 11.0 and 12.0, and 9.0 date differs from Rocket Software's lifecycle pageĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
endoflife-date/endoflife.date#11561 ·
Maintainer thường phản hồi trong vòng 1 ngày