Repository navigation
fix: strict guarded fetch fails before managed proxy DNS - #98951
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 2, 2026, 5:24 PM ET / 21:24 UTC. Summary PR surface: Source +22, Tests +111. Total +133 across 3 files. Reproducibility: yes. Current main is source-reproducible because strict/default mode with OPENCLAW_PROXY_ACTIVE=1 and applicable proxy env reaches local DNS pinning before the env proxy dispatcher is created. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this shared fetch-guard fix after maintainer/security signoff accepts proxy-owned DNS enforcement for active managed-proxy strict/default traffic. Do we have a high-confidence way to reproduce the issue? Yes. Current main is source-reproducible because strict/default mode with OPENCLAW_PROXY_ACTIVE=1 and applicable proxy env reaches local DNS pinning before the env proxy dispatcher is created. Is this the best way to solve the issue? Mostly yes. The shared fetch guard is the right layer because many callers default to strict mode, and the PR preserves direct, NO_PROXY, configured-local-origin, loopback-mode, and redirect behavior; the remaining question is maintainer/security acceptance of proxy-owned enforcement. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1a508d7915ef. Label changesLabel justifications:
Evidence reviewedPR surface: Source +22, Tests +111. Total +133 across 3 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper review |
|
@clawsweeper re-review |
0478a1d to
e9a39b1
Compare
Closes #98925
What Problem This Solves
Fixes an issue where users in managed proxy-only sandboxes could see strict/default guarded fetches fail before reaching the managed proxy when local DNS could not resolve, disagreed with, or rejected the target hostname.
Affected surfaces include guarded fetch callers that omit
modeand therefore default to strict mode, such as channel/provider preflight and plugin HTTP paths described in #98925.Why This Change Was Made
When
OPENCLAW_PROXY_ACTIVE=1and the HTTP(S) env proxy applies to the target URL, strict guarded fetch now keeps the pre-DNS hostname/IP-literal SSRF checks and dispatches through the managed env proxy without resolving the target locally. Direct strict mode and NO_PROXY targets still use DNS pinning, while exact configured local-origin bypass candidates still resolve/pin DNS soproxy.loopbackModeand loopback-only bypass policy remain enforced.Provenance: current
origin/mainstill calledresolvePinnedHostnameWithPolicy()inside the strict managed-proxy branch before creating the env proxy dispatcher. The managed-proxy branch was introduced by #70044 and the configured-local-origin bypass path was later carried forward by #85707.User Impact
Operators can rely on the managed proxy as the resolver/enforcement boundary for strict/default guarded fetches in proxy-only deployments. Google Chat, Mattermost, managed provider preflight, media, and web-tool paths no longer need caller-specific
TRUSTED_ENV_PROXYworkarounds just to avoid local DNS in active managed-proxy mode.Security boundary note: this does not make ordinary strict mode proxy-aware just because proxy env vars exist. The proxy skip is limited to the OpenClaw managed proxy lifecycle, still respects whether the HTTP(S) env proxy applies to the URL, still blocks private IP literals/blocked hostnames before fetch, and still revalidates redirects.
Evidence
node scripts/run-vitest.mjs src/infra/net/fetch-guard.ssrf.test.ts src/infra/net/proxy-env.test.tsnode scripts/run-oxlint.mjs src/infra/net/fetch-guard.ts src/infra/net/configured-local-origin-bypass.ts src/infra/net/fetch-guard.ssrf.test.tspnpm exec oxfmt --check src/infra/net/fetch-guard.ts src/infra/net/configured-local-origin-bypass.ts src/infra/net/fetch-guard.ssrf.test.tsgit diff --checkcodex review --base origin/maininitially found aproxy.loopbackMode=block+NO_PROXYregression; fixed with an extra regression test and rerancodex review --base origin/main, which reported no actionable regressions.Real behavior proof,Security High (network-ssrf-boundary),security-fast,check-lint,check-prod-types,check-test-types,check-guards, and the compact/check shards passed on PR fix: strict guarded fetch fails before managed proxy DNS #98951.Critical Quality (network-runtime-boundary)intentionally fast-failed because added test lines mentionNO_PROXY; its log says boundary-sensitive lines require full CodeQL review, and the relevant full security checks passed.Managed proxy-only behavior proof from a local CONNECT proxy setup:
{ "proof": "strict managed-proxy guarded fetch skips local target DNS", "proxyUrl": "http://127.0.0.1:<ephemeral>", "managedFetch": { "status": 200, "body": "proxied-ok", "lookupCallsAfterManagedFetch": 0, "proxyEventsAfterManagedFetch": [ { "type": "connect", "target": "proxy-only.example:80" }, { "type": "tunnel-request", "requestLine": "GET /proxy-ok HTTP/1.1", "host": "host: proxy-only.example" } ] }, "privateLiteral": { "blockedBeforeProxyDispatch": true, "proxyEventCountBefore": 2, "proxyEventCountAfter": 2 }, "redirectToPrivate": { "blockedAfterFirstProxyResponseBeforeSecondProxyDispatch": true, "proxyEventCountBefore": 2, "proxyEventCountAfter": 4, "redirectProxyEvents": [ { "type": "connect", "target": "proxy-only.example:80" }, { "type": "tunnel-request", "requestLine": "GET /redirect-to-private HTTP/1.1", "host": "host: proxy-only.example" } ] }, "totalLookupCalls": 0 }That proof used
OPENCLAW_PROXY_ACTIVE=1, HTTP(S) proxy env vars pointing at a temporary local CONNECT proxy, an unresolvable target hostname (proxy-only.example), and alookupFnthat throws on any target DNS lookup. The successful 200 response andlookupCallsAfterManagedFetch: 0show strict managed-proxy dispatch reached the proxy without local target DNS. The private literal and redirect checks show those unsafe targets were rejected before proxy dispatch.AI-assisted: yes, implemented with Codex; I understand the changed guarded-fetch/proxy path and verified the security-sensitive cases above.
Additional Operator Proxy Policy Proof
To close the proxy-owned enforcement gap, I also ran a local operator-policy-equivalent CONNECT proxy proof. The proxy owns DNS for the target hostnames, maps test hostnames to public/private/link-local/loopback addresses, and rejects the CONNECT before opening a tunnel when the proxy-side resolved address is disallowed.
{ "proof": "operator proxy policy resolves target and blocks private/link-local/loopback destinations after proxy-side DNS", "proxyUrl": "http://127.0.0.1:<ephemeral>", "proxyPolicy": { "resolver": "proxy-owned static DNS map for proof", "denyAfterResolution": [ "127.0.0.0/8", "10.0.0.0/8", "169.254.0.0/16" ], "allowPublicExampleAddress": "93.184.216.34" }, "publicAllowed": { "url": "http://policy-public.example/proxy-ok", "ok": true, "status": 200, "body": "proxied-policy-ok", "events": [ { "type": "connect", "targetHost": "policy-public.example", "targetPort": "80", "proxyResolvedAddress": "93.184.216.34", "decision": "allow", "reason": "public-address" }, { "type": "tunnel-request", "requestLine": "GET /proxy-ok HTTP/1.1", "host": "host: policy-public.example", "targetHost": "policy-public.example", "proxyResolvedAddress": "93.184.216.34", "decision": "allow", "reason": "public-address" } ], "lookupCallsAfter": 0 }, "loopbackDenied": { "url": "http://policy-loopback.example/private", "ok": false, "errorName": "TypeError", "errorMessage": "fetch failed", "events": [ { "type": "connect", "targetHost": "policy-loopback.example", "targetPort": "80", "proxyResolvedAddress": "127.0.0.1", "decision": "deny", "reason": "loopback" } ], "lookupCallsAfter": 0 }, "privateDenied": { "url": "http://policy-private.example/private", "ok": false, "errorName": "TypeError", "errorMessage": "fetch failed", "events": [ { "type": "connect", "targetHost": "policy-private.example", "targetPort": "80", "proxyResolvedAddress": "10.0.0.5", "decision": "deny", "reason": "rfc1918-private" } ], "lookupCallsAfter": 0 }, "linkLocalDenied": { "url": "http://policy-linklocal.example/metadata", "ok": false, "errorName": "TypeError", "errorMessage": "fetch failed", "events": [ { "type": "connect", "targetHost": "policy-linklocal.example", "targetPort": "80", "proxyResolvedAddress": "169.254.169.254", "decision": "deny", "reason": "link-local-metadata" } ], "lookupCallsAfter": 0 }, "totalLookupCalls": 0 }This proof is intentionally policy-equivalent rather than tied to a specific production proxy vendor: it demonstrates the required deployment contract for the strict managed-proxy branch. The proxy, not local DNS pinning, owns target DNS; after proxy-side DNS resolution, the proxy blocks loopback, RFC1918 private, and link-local/metadata targets before creating the tunnel, while public destinations still work through the same managed-proxy path.