Skip to content

fetchWithSsrFGuard strict mode resolves DNS locally before managed proxy #98925

Closed

Description

@sandl99

Summary

fetchWithSsrFGuard still performs local DNS pinning for STRICT fetches when OpenClaw's managed proxy lifecycle is active. In proxy-only sandboxes, local DNS can fail or disagree with the managed proxy resolver, so strict/default guarded fetches fail before the proxy can resolve the target and enforce its egress policy.

This is showing up as repeated downstream patches in NemoClaw/OpenShell integrations. The common shape is not one plugin-specific bug: many OpenClaw call paths either call withStrictGuardedFetchMode(...) directly or omit mode, which defaults to STRICT.

Current behavior

resolveGuardedFetchMode() defaults missing mode to STRICT.

In STRICT mode, fetchWithSsrFGuard() currently does this even when OPENCLAW_PROXY_ACTIVE=1 and proxy env vars are configured:

  1. Call resolvePinnedHostnameWithPolicy(...).
  2. That helper uses local dns.lookup(..., { all: true }).
  3. Only after local DNS succeeds does the fetch use the env proxy dispatcher.

That means proxy-only environments can fail with local DNS errors such as EAI_AGAIN / ENOTFOUND, or can reject fake/sentinel DNS results, before the managed proxy has a chance to resolve and apply policy.

Affected call paths observed downstream

Examples in current OpenClaw source:

  • src/cron/isolated-agent/model-preflight.runtime.ts: probeLocalProviderEndpoint() calls fetchWithSsrFGuard() for managed inference preflight with a policy but no mode, so it defaults to STRICT.
  • extensions/googlechat/src/auth.ts: fetchChatCerts() fetches Google Chat JWT verification certs with no mode or policy.
  • extensions/googlechat/src/api.ts: withGoogleChatResponse() is used by outbound sends, edits, uploads, media fetches, and reactions; it passes no mode or policy.
  • extensions/mattermost/src/mattermost/client.ts: the Mattermost guarded client wrapper passes a policy but no mode.
  • extensions/mattermost/src/mattermost/probe.ts: the Mattermost reachability probe passes a policy but no mode.
  • src/media/fetch.ts: media fetch can explicitly choose withStrictGuardedFetchMode(...).
  • src/agents/tools/web-guarded-fetch.ts: web tools explicitly choose strict mode unless useEnvProxy is enabled.

Downstream references

NemoClaw has had to patch or work around this repeatedly:

Related OpenClaw issue history shows the same class in individual call paths:

Expected behavior

When OpenClaw's managed proxy lifecycle is active (OPENCLAW_PROXY_ACTIVE=1) and the env HTTP proxy applies to the target URL, STRICT fetches should keep the pre-DNS SSRF checks that do not require local resolution:

  • URL parsing and scheme checks
  • hostname allowlist checks
  • blocked hostname checks
  • IP literal/private/internal/special-use checks
  • redirect revalidation

Then the request should use the managed env proxy dispatcher without local DNS pinning. The managed proxy should own DNS resolution and private-IP enforcement for the final target in this mode.

This matches the trust boundary already implied by the managed proxy lifecycle and avoids requiring every plugin/call path to remember to opt into TRUSTED_ENV_PROXY.

Security notes

The fix should not make ordinary STRICT mode proxy-aware just because HTTP_PROXY is present. It should be limited to the managed proxy lifecycle signal. It should also preserve direct-mode DNS pinning outside managed proxy mode.

Tests should prove:

  • default strict mode still ignores env proxy and pins local DNS
  • strict mode with OPENCLAW_PROXY_ACTIVE=1 and env proxy configured uses the env proxy without local lookup
  • blocked hostnames and private IP literals are still rejected before fetch
  • redirects still re-run the pre-DNS policy checks

Activity

  1. clawsweeper commented on Jul 2, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 2, 2026, 1:24 AM ET / 05:24 UTC.

    Summary
    Keep open: current main and v2026.6.11 still resolve target DNS in the strict managed-proxy branch before creating the env proxy dispatcher, so the reported proxy-only failure remains valid and security-sensitive.

    Reproducibility: yes. from source, not from a live run: with OPENCLAW_PROXY_ACTIVE=1, proxy env configured, and strict/default mode, current main calls resolvePinnedHostnameWithPolicy() before the env proxy dispatcher. A focused regression can use a failing lookupFn to prove the proxy is never reached.

    Root-cause cluster
    Relationship: canonical
    Canonical: #98925
    Summary: This issue is the central open report for strict/default guarded fetches doing local DNS before active managed-proxy dispatch; older related items fixed narrower caller or trusted-proxy paths.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Next step
    Manual maintainer/security review is needed before implementation because the repair changes the core SSRF and managed-proxy trust boundary.

    Security
    Needs attention: The issue is security-sensitive because any fix changes how strict SSRF validation, DNS pinning, and managed proxy enforcement share responsibility.

    Review details

    Best possible solution:

    Update the shared guarded-fetch managed-proxy branch so strict/default traffic that should use the active proxy performs pre-DNS hostname/IP-literal checks and then dispatches through the proxy, while preserving direct strict DNS pinning, loopback bypass rules, redirect revalidation, and focused regression coverage.

    Do we have a high-confidence way to reproduce the issue?

    Yes from source, not from a live run: with OPENCLAW_PROXY_ACTIVE=1, proxy env configured, and strict/default mode, current main calls resolvePinnedHostnameWithPolicy() before the env proxy dispatcher. A focused regression can use a failing lookupFn to prove the proxy is never reached.

    Is this the best way to solve the issue?

    Unclear until maintainer/security review: the shared fetch guard is the right layer because many callers default to strict mode, but maintainers need to accept the managed proxy as the final DNS/IP enforcement boundary for this branch.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Changing this path delegates target DNS and resolved-IP enforcement to the managed proxy for strict/default fetches, so maintainer security acceptance is required.
    • The source reproduction is high-confidence, but no live proxy-only sandbox was run in this read-only review.
    • Open broad pull request Refactor HTTP egress around external proxy enforcement #91722 overlaps the egress boundary but is draft, protected, and much broader than this issue, so it is not a safe canonical fix target.

    Codex review notes: model internal, reasoning high; reviewed against c8dba85b5d41.

    Label changes

    Label justifications:

    • P1: The issue affects core guarded network fetches across managed-proxy deployments and can break real channel/provider workflows in proxy-only sandboxes.
    • impact:security: The report is about the SSRF guard DNS-pinning boundary versus managed proxy DNS and private-IP enforcement.
    • impact:message-loss: The listed Google Chat and Mattermost paths include outbound sends, uploads, reactions, and cert/API requests that can fail before reaching the proxy.
    • maturity:stable: The affected managed-proxy guarded-fetch path belongs to the M4 Stable Gateway runtime network/security-control surface.
    Evidence reviewed

    Security concerns:

    • [medium] Preserve the strict SSRF boundary while moving DNS to the proxy — src/infra/net/fetch-guard.ts:505
      The desired fix should skip local target DNS only when the OpenClaw-managed proxy lifecycle is active and the proxy applies, while preserving direct strict mode DNS pinning plus hostname, IP-literal, blocked-hostname, and redirect checks before dispatch.
      Confidence: 0.9

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/infra/net/fetch-guard.ssrf.test.ts src/infra/net/proxy-env.test.ts
    • Add coverage proving strict mode with OPENCLAW_PROXY_ACTIVE=1 and an applicable HTTP(S) proxy does not call target lookupFn before dispatch.
    • Add coverage preserving direct strict DNS pinning, blocked hostname/private IP literal rejection, redirect revalidation, and configured-local-origin bypass behavior.

    What I checked:

    • Current strict managed-proxy branch still resolves locally: canUseManagedProxy is true for STRICT mode with OPENCLAW_PROXY_ACTIVE=1 and proxy env configured, but that branch calls resolvePinnedHostnameWithPolicy() before selecting createHttp1EnvHttpProxyAgent(). (src/infra/net/fetch-guard.ts:505, c8dba85b5d41)
    • Missing mode still defaults to strict: resolveGuardedFetchMode() returns GUARDED_FETCH_MODE.STRICT when callers omit mode, matching the issue's default-strict caller concern. (src/infra/net/fetch-guard.ts:147, c8dba85b5d41)
    • Pinned hostname helper performs the local lookup: resolvePinnedHostnameWithPolicy() uses lookupFn ?? dnsLookup with { all: true } and checks resolved addresses before returning pinned addresses. (src/infra/net/ssrf.ts:541, c8dba85b5d41)
    • Existing regression test does not prove DNS is skipped: The current managed-proxy strict-mode test only expects an env proxy dispatcher; the helper still passes a lookupFn and does not assert that lookup is not called. (src/infra/net/fetch-guard.ssrf.test.ts:1409, c8dba85b5d41)
    • Affected default-strict call paths exist: Google Chat cert/API fetches and Mattermost client/probe fetches call fetchWithSsrFGuard() without setting mode, so they inherit strict behavior. (extensions/googlechat/src/api.ts:47, c8dba85b5d41)
    • Docs support managed proxy as central egress routing: The public network-proxy docs say managed proxy mode routes normal runtime HTTP/WebSocket egress through the configured proxy and that the proxy policy is the security boundary. Public docs: docs/security/network-proxy.md. (docs/security/network-proxy.md:15, c8dba85b5d41)

    Likely related people:

    • jesse-merhi: GitHub history ties the operator-managed proxy routing and related lifecycle work to this contributor, which is the boundary this issue depends on. (role: introduced managed proxy lifecycle; confidence: high; commits: 2633b1491413, 7c2425a5186d, 5b00cd1ae12a; files: src/infra/net/proxy/proxy-lifecycle.ts, src/infra/net/proxy/active-proxy-state.ts, src/infra/net/fetch-guard.ts)
    • steipete: Commit history shows repeated work on trusted env proxy opt-in, NO_PROXY/CIDR handling, and proxy documentation near the affected code path. (role: recent guarded-fetch and proxy helper contributor; confidence: high; commits: 66336bf7c846, a95d7ab1c81b, 53aa5232bc00; files: src/infra/net/fetch-guard.ts, src/infra/net/proxy-env.ts, docs/security/network-proxy.md)
    • Kaspre: Merged history connects this contributor to exact-origin SSRF trust and managed-proxy loopback embedding bypass work in the same security boundary. (role: recent SSRF and managed-proxy boundary contributor; confidence: high; commits: 44840007d42d, fd2a9adbe6b0; files: src/infra/net/fetch-guard.ts, src/infra/net/ssrf.ts, src/infra/net/fetch-guard.ssrf.test.ts)
    • vincentkoc: History shows recent fetch-guard refactoring and trusted-env-proxy media-understanding work adjacent to this failure class. (role: recent adjacent proxy-path fixer; confidence: medium; commits: e098eb735ff7, 6ee8e194c027; files: src/infra/net/fetch-guard.ts, src/infra/net/proxy-env.ts, src/media-understanding/shared.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P1
    impact:security
    impact:message-loss
    maturity:stable
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    clawsweeper:no-new-fix-pr
    clawsweeper:fix-shape-clear
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-product-decision
    clawsweeper:needs-security-review
    on Jul 2, 2026
  3. locked as resolved and limited conversation to collaborators on Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1clawsweeper:fix-shape-clearclawsweeper:needs-maintainer-reviewclawsweeper:needs-product-decisionclawsweeper:needs-security-reviewclawsweeper:no-new-fix-prclawsweeper:source-reproimpact:message-lossimpact:securityissue-rating: 🦞 diamond lobstermaturity:stable

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions