fix(web): respect HTTP_PROXY/HTTPS_PROXY env vars in web_fetch#46538
fix(web): respect HTTP_PROXY/HTTPS_PROXY env vars in web_fetch#46538BenediktSchackenberg wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes
No issues found — the change is minimal, safe, and consistent with existing patterns. Confidence Score: 5/5
Last reviewed commit: fb3e2d9 |
There was a problem hiding this comment.
Pull request overview
Adjusts web_fetch networking behavior so outbound requests can honor HTTP_PROXY / HTTPS_PROXY environment variables when running behind an enterprise proxy, aligning it with other web tool fetch paths.
Changes:
- Add
useEnvProxy: trueto thefetchWithWebToolsNetworkGuardcall inweb_fetch.
| @@ -533,6 +533,7 @@ async function runWebFetch(params: WebFetchRuntimeParams): Promise<Record<string | |||
| url: params.url, | |||
| maxRedirects: params.maxRedirects, | |||
| timeoutSeconds: params.timeoutSeconds, | |||
| useEnvProxy: true, | |||
There was a problem hiding this comment.
Yeah, the DNS pinning tradeoff is real. In trusted_env_proxy mode we're deliberately delegating DNS resolution to the proxy, which means we can't pin locally. The assumption is that if you've configured an env proxy, you trust it to handle resolution. Added a comment in the code documenting this tradeoff.
There was a problem hiding this comment.
✅ Addressed
The DNS pinning tradeoff is now documented in the code (see commit ). The comment at the call explains:
When a proxy is configured, DNS pinning is intentionally disabled because the proxy performs DNS resolution. This is a necessary tradeoff for proxy environments (e.g. corporate/K8s). SSRF protection is delegated to the proxy.
This pattern is consistent with , which uses (internally sets ) for the same reason. Implementing a separate proxy-respecting strict mode is beyond this PR's scope — the PR's explicit goal is to enable env proxy support for , which necessarily involves this tradeoff. A separate config option could be considered in a follow-up.
1e6688e to
016e27c
Compare
7722b3a to
2a59fd6
Compare
b04db88 to
3a71aad
Compare
web_fetch fails with getaddrinfo EAI_AGAIN behind HTTP proxy because fetchWithWebToolsNetworkGuard uses strict mode with DNS pinning, bypassing proxy env vars. Fix from openclaw#46306 root cause. 1. fetch-guard.ts: skip DNS pinning when routing through env proxy in TRUSTED_ENV_PROXY mode (proxy handles DNS) 2. web-fetch.ts: add useEnvProxy:true so web_fetch routes through configured env proxy Test: - fetch-guard.ssrf.test.ts: add DNS-pinning-skip test - web-fetch.ssrf.test.ts: stub proxy env vars in beforeEach Refs: openclaw#46306 openclaw#46318 openclaw#46538
aef5142 to
0933269
Compare
web_fetch was using fetchWithWebToolsNetworkGuard in strict mode, which creates a pinned DNS dispatcher that bypasses env proxy settings. Enable useEnvProxy so requests route through the configured proxy (via undici EnvHttpProxyAgent) when HTTP_PROXY/HTTPS_PROXY are set. web_search already worked correctly behind proxies because it uses withTrustedWebToolsEndpoint which sets useEnvProxy: true. Fixes openclaw#46306 AI-assisted: Built with Claude, reviewed by human.
Add code comment explaining that useEnvProxy intentionally disables DNS pinning because the proxy performs DNS resolution. SSRF protection is delegated to the proxy in these environments.
0933269 to
3db8e74
Compare
|
Closing as duplicate; this was superseded by #50650. |
Summary
web_fetchfails withgetaddrinfo EAI_AGAINwhen running behind an HTTP proxy because it usesfetchWithWebToolsNetworkGuardin strict mode, which creates a pinned DNS dispatcher that bypasses proxy environment variables.The fix adds
useEnvProxy: trueto theweb_fetchnetwork guard call, matching the behavior already used byweb_search(viawithTrustedWebToolsEndpoint). This routes requests through the configured proxy (via undici'sEnvHttpProxyAgent) whenHTTP_PROXY/HTTPS_PROXYenv vars are set, withNO_PROXYrespected automatically.What Changed
src/agents/tools/web-fetch.ts: AddeduseEnvProxy: trueto thefetchWithWebToolsNetworkGuardcallWhy web_search already worked
web_searchuseswithTrustedWebToolsEndpointwhich internally setsuseEnvProxy: true. Onlyweb_fetchwas missing this flag.Change Type
Scope
src/agents/tools/web-fetch.tsSecurity Impact
No security impact. The
useEnvProxyflag is already used byweb_searchand other trusted endpoint fetchers. It delegates to undici'sEnvHttpProxyAgentwhich respectsNO_PROXYexclusions. The SSRF policy is still applied.Fixes #46306