#16144: fix: respect HTTP_PROXY/HTTPS_PROXY in SSRF-protected fetch (#2102)
stale
size: M
Cluster:
SSRF Protection Enhancements
## Summary
- Adds HTTP/HTTPS proxy support to the SSRF-protected fetch guard (`fetchWithSsrFGuard`)
- Reads `HTTP_PROXY`, `HTTPS_PROXY`, `http_proxy`, `https_proxy` env vars automatically
- Adds `NO_PROXY`/`no_proxy` support with wildcard matching (e.g., `.example.com`, `*`)
- Routes through undici `ProxyAgent` while preserving SSRF hostname pre-validation
- Explicit `proxyUrl`/`skipProxy` options available for programmatic override
### Scope
This PR covers proxy support for SSRF-guarded fetch paths: web-fetch tool, media downloads, skill installation, and plugin SDK fetches. LLM API calls (Anthropic, OpenAI, etc.) already get proxy support via pi-ai's `EnvHttpProxyAgent` global dispatcher — this PR closes the remaining gap.
### Security notes
- SSRF pre-validation (`resolvePinnedHostnameWithPolicy`) still runs before every fetch
- When a proxy is configured, DNS pinning (`connect.lookup`) applies to the proxy hostname, not the target — this is documented in code. The proxy server itself must be trusted.
- `requestTls.lookup` was removed (not a valid undici option)
Closes #2102
## Test plan
- [x] 21 unit tests for `shouldBypassProxy` and `resolveProxyUrl` (NO_PROXY matching, env var precedence, skipProxy, explicit override)
- [x] All existing SSRF tests pass (34 total across 4 test files)
- [x] `pnpm build` passes
- [x] `pnpm lint` passes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added HTTP/HTTPS proxy support to SSRF-protected fetch paths with `NO_PROXY` bypass functionality. The implementation reads standard proxy environment variables (`HTTP_PROXY`, `HTTPS_PROXY`, and their lowercase variants) and routes requests through undici's `ProxyAgent` while preserving pre-fetch SSRF validation via `resolvePinnedHostnameWithPolicy`. DNS pinning through proxies is documented as limited (pins proxy hostname, not target). The `skipProxy` option disables all proxy detection, and explicit `proxyUrl` bypasses `NO_PROXY` checks (by design, per JSDoc). All previous thread comments have been addressed in commit 65a25fe92.
<h3>Confidence Score: 5/5</h3>
- Safe to merge with no remaining issues
- The implementation is well-tested (21 new proxy tests + 34 existing SSRF tests pass), addresses all previous review comments, and correctly preserves SSRF pre-validation. The proxy DNS pinning limitation is properly documented, and the design choices (explicit `proxyUrl` bypassing `NO_PROXY`, `skipProxy` for full disable) are intentional and documented. No logical errors, security vulnerabilities, or implementation issues found.
- No files require special attention
<sub>Last reviewed commit: f247fb0</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#8571: fix: support system proxy in web_fetch SSRF dispatcher
by Asura-2010 · 2026-02-04
85.0%
#16897: fix(tools): route web_search requests through HTTP proxy env vars
by battman21 · 2026-02-15
80.2%
#20578: feat(browser): add proxy configuration option
by illusivejosiah · 2026-02-19
74.8%
#19660: fix: respect HTTP_PROXY/HTTPS_PROXY env vars for undici fetch
by 88plug · 2026-02-18
74.5%
#19525: security: add SSRF validation for external URLs
by Mozzzaic · 2026-02-17
74.1%
#22644: feat(web-fetch): add allowPrivateNetwork config for web_fetch
by qingxuecc · 2026-02-21
72.0%
#19042: Security: add URL allowlist for web_search and web_fetch
by smartprogrammer93 · 2026-02-17
71.4%
#21132: fix: allow message(action='read') in isolated/cron sessions + add H...
by matt-bedda · 2026-02-19
71.1%
#8305: fix(browser): add SSRF protection to browser navigation
by yubrew · 2026-02-03
70.9%
#15923: feat: add proxy support for web_search tool
by Shuai-DaiDai · 2026-02-14
70.9%