fix(net): respect HTTP proxy env vars in web_fetch SSRF dispatcher#24625
Closed
makew0rld wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(net): respect HTTP proxy env vars in web_fetch SSRF dispatcher#24625makew0rld wants to merge 1 commit intoopenclaw:mainfrom
makew0rld wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When HTTP_PROXY/HTTPS_PROXY env vars are set, createPinnedDispatcher now returns an undici EnvHttpProxyAgent instead of a plain Agent. This allows web_fetch (and all fetchWithSsrFGuard callers) to route through the configured proxy. DNS pinning is skipped when proxying since the proxy handles resolution; SSRF hostname/IP pre-checks still run beforehand. Closes openclaw#2102 Related openclaw#8534 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Closing as AI-assisted stale-fix triage. Linked issue #2102 ("[Bug]: HTTP_PROXY is ignored") is currently CLOSED and was closed on 2026-02-24T04:30:36Z with state reason NOT_PLANNED. If the underlying bug is still reproducible on current main, please reopen this PR (or open a new focused fix PR) and reference both #2102 and #24625 for fast re-triage. |
Contributor
|
Closed after AI-assisted stale-fix triage (closed issue duplicate/stale fix). |
makew0rld
added a commit
to eqtylab/openclaw
that referenced
this pull request
Feb 24, 2026
When HTTP_PROXY/HTTPS_PROXY env vars are set, createPinnedDispatcher now returns an undici EnvHttpProxyAgent instead of a plain Agent. This allows web_fetch (and all fetchWithSsrFGuard callers) to route through the configured proxy. DNS pinning is skipped when proxying since the proxy handles resolution; SSRF hostname/IP pre-checks still run beforehand. Related openclaw#2102 Related openclaw#8534 Supersedes openclaw#24625 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
15 tasks
Author
|
Reopened as #25573 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
web_fetch(and allfetchWithSsrFGuardcallers) ignoreHTTP_PROXY/HTTPS_PROXYenv vars becausecreatePinnedDispatchercreates a plain undiciAgentthat overrides the global dispatcher, bypassing all proxy settings.web_fetchat all, even when proxy env vars are correctly configured and work for other HTTP clients (e.g., Anthropic API calls, curl).createPinnedDispatchernow detects proxy env vars and returns an undiciEnvHttpProxyAgent(which readsHTTP_PROXY,HTTPS_PROXY,NO_PROXYautomatically) instead of a plainAgent. Added 4 tests covering all env var variants.resolvePinnedHostnameWithPolicystill run before the dispatcher is created. The non-proxy code path (plainAgentwith DNS pinning) is untouched.web_searchbarefetch()calls are not in scope.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
web_fetch(and other tools usingfetchWithSsrFGuard) now route through the user's configured HTTP proxy whenHTTP_PROXY/HTTPS_PROXY(or lowercase variants) env vars are set.NO_PROXYis also respected viaEnvHttpProxyAgent.Security Impact (required)
NoNoYes— when proxy env vars are set,web_fetchHTTP requests are routed through the proxy instead of directly. This is user-initiated behavior (requires explicit proxy env var configuration).NoNoresolvePinnedHostnameWithPolicystill execute before the dispatcher is created, maintaining protection against requests to private/internal addresses. The proxy path only activates when the user has explicitly configured proxy env vars.Repro + Verification
Environment
HTTP_PROXY=http://proxy:8080,HTTPS_PROXY=http://proxy:8080Proxy setup
For systemd-managed OpenClaw (e.g. gateway running as a service), env vars can be set globally via a drop-in override:
Then add:
Then
sudo systemctl daemon-reload && sudo systemctl restart openclaw-gateway.Note: it is unclear whether setting proxy vars in
openclaw.jsonconfig is supported — the env var approach above is the tested path.Steps
HTTP_PROXY/HTTPS_PROXYenv vars pointing to a proxy server (via systemd override, shell, etc.)web_fetchto fetch any URLExpected
Request is routed through the configured proxy.
Actual (before fix)
Request bypasses proxy — the custom undici
Agentdispatcher overrides global proxy settings.Evidence
EnvHttpProxyAgentis used when proxy env vars are set, and plainAgentwhen notweb_fetchrequests now appear in proxy logsHuman Verification (required)
web_fetchsuccessfully routes through proxy on a VM withHTTPS_PROXYset via systemd override; all existing SSRF tests pass (29 tests across 3 test files)http_proxy), missing env vars (falls back to plainAgent), mixed env var configurationsNO_PROXYexclusion behavior (delegated to undici'sEnvHttpProxyAgentimplementation),web_searchtool (uses barefetch(), out of scope)Compatibility / Migration
Yes— no behavior change when proxy env vars are not setNo— reads existing standard env varsNoFailure Recovery (if this breaks)
HTTP_PROXY/HTTPS_PROXYenv vars to fall back to plainAgent(existing behavior)src/infra/net/ssrf.tsweb_fetchfailing with connection errors when proxy env vars are set but proxy is unreachableRisks and Mitigations
AI-assisted: This PR was developed with Claude Code (Opus). Fully tested on a real proxy setup. I understand what the code does.
Greptile Summary
Adds HTTP proxy support to
web_fetchby detectingHTTP_PROXY/HTTPS_PROXYenv vars increatePinnedDispatcherand returning undici'sEnvHttpProxyAgentinstead of a plainAgent. SSRF hostname/IP pre-checks inresolvePinnedHostnameWithPolicystill execute before dispatcher creation. DNS pinning is skipped when proxying (proxy handles DNS resolution). Test coverage includes all four proxy env var variants (uppercase/lowercaseHTTP_PROXY/HTTPS_PROXY) plus the no-proxy fallback path.Confidence Score: 4/5
Last reviewed commit: 26024cf
(2/5) Greptile learns from your feedback when you react with thumbs up/down!