← Back to PRs

#16144: fix: respect HTTP_PROXY/HTTPS_PROXY in SSRF-protected fetch (#2102)

by battman21 open 2026-02-14 10:10 View on GitHub →
stale size: M
## 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