Skip to content

Commit cbf2ae1

Browse files
atishpatelclaude
andcommitted
fix(agent): pass proxy and TLS trust env into MCP tool subprocesses
buzz-agent env_clear()s the environment of each MCP child, and the passthrough allowlist carried no proxy or TLS-trust variables. On a host whose only route out is a CONNECT proxy this does not degrade the tools, it blinds them: apt, curl, pip and git connect directly instead, the egress firewall resets the socket, and the agent reports "Connection reset by peer" and concludes the environment has no network — indistinguishable in the transcript from a task that is genuinely offline. Add both spellings of the proxy vars (HTTP_PROXY/HTTPS_PROXY/NO_PROXY/ALL_PROXY and lowercase) to PASSTHROUGH_ENV: curl and git read lowercase, most Go/Python tooling reads uppercase, and libcurl deliberately ignores uppercase HTTP_PROXY, so keeping only one form silently breaks half the toolchain. Also pass SSL_CERT_FILE/SSL_CERT_DIR: a TLS-terminating proxy presents its own CA, and an image whose trust store lacks it fails every https fetch with a verification error — the same class of failure, the parent configured correctly and the child unable to see it. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: Atish Patel <[email protected]>
1 parent 5c5ef8c commit cbf2ae1

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

‎crates/buzz-agent/src/mcp.rs‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,31 @@ const PASSTHROUGH_ENV: &[&str] = &[
5252
"GIT_ASKPASS",
5353
"GIT_SSH_COMMAND",
5454
"GIT_CONFIG_GLOBAL",
55+
// Proxy — on a host whose only route out is a CONNECT proxy, dropping
56+
// these does not degrade the tools, it blinds them: apt, curl, pip and git
57+
// all connect directly instead, and the egress firewall resets the socket.
58+
// The agent then reports "Connection reset by peer" and concludes the
59+
// environment has no network, which is indistinguishable in the transcript
60+
// from a task that is genuinely offline.
61+
//
62+
// Both cases are needed. curl and git read the lowercase spellings, most
63+
// Go and Python tooling reads the uppercase ones, and libcurl deliberately
64+
// ignores uppercase HTTP_PROXY (CGI ambiguity), so keeping only one form
65+
// silently breaks half the toolchain.
66+
"HTTP_PROXY",
67+
"HTTPS_PROXY",
68+
"NO_PROXY",
69+
"ALL_PROXY",
70+
"http_proxy",
71+
"https_proxy",
72+
"no_proxy",
73+
"all_proxy",
74+
// TLS trust — a proxy that terminates TLS presents its own CA, and an
75+
// image whose trust store does not carry it fails every https fetch with a
76+
// verification error. Same class of failure as the proxy vars: the parent
77+
// was configured correctly and the child could not see it.
78+
"SSL_CERT_FILE",
79+
"SSL_CERT_DIR",
5580
// Buzz identity — dev-mcp writes NOSTR_PRIVATE_KEY to a keyfile then
5681
// removes it from its own env (children never see it). BUZZ_PRIVATE_KEY
5782
// and BUZZ_RELAY_URL are kept for the buzz CLI. BUZZ_AUTH_TAG is a
@@ -1015,6 +1040,41 @@ mod content_tests {
10151040
fn passthrough_includes_buzz_owner_attestation() {
10161041
assert!(PASSTHROUGH_ENV.contains(&"BUZZ_AUTH_TAG"));
10171042
}
1043+
1044+
#[test]
1045+
fn passthrough_carries_proxy_configuration_to_tools() {
1046+
// On a proxy-only host this is the difference between an agent that can
1047+
// install a package and one that reports the network is down. Both
1048+
// spellings: libcurl ignores uppercase HTTP_PROXY, and Go/Python
1049+
// tooling largely ignores the lowercase set.
1050+
for var in [
1051+
"HTTP_PROXY",
1052+
"HTTPS_PROXY",
1053+
"NO_PROXY",
1054+
"ALL_PROXY",
1055+
"http_proxy",
1056+
"https_proxy",
1057+
"no_proxy",
1058+
"all_proxy",
1059+
] {
1060+
assert!(
1061+
PASSTHROUGH_ENV.contains(&var),
1062+
"{var} must survive env_clear() or every MCP tool loses the proxy"
1063+
);
1064+
}
1065+
}
1066+
1067+
#[test]
1068+
fn passthrough_carries_tls_trust_to_tools() {
1069+
// A TLS-terminating proxy presents its own CA; without these the child
1070+
// rejects every https fetch even though the proxy itself is reachable.
1071+
for var in ["SSL_CERT_FILE", "SSL_CERT_DIR"] {
1072+
assert!(
1073+
PASSTHROUGH_ENV.contains(&var),
1074+
"{var} must survive env_clear() or https fails inside tools"
1075+
);
1076+
}
1077+
}
10181078
use rmcp::model::Content;
10191079

10201080
#[cfg(windows)]

0 commit comments

Comments
 (0)