Skip to content

fix(web-tools): exempt fake-IP DNS ranges from trusted/self-hosted SSRF policy - #76530

Closed
zqchris wants to merge 1 commit into
openclaw:mainfrom
zqchris:fix/web-tools-trusted-fake-ip
Closed

zqchris wants to merge 1 commit into
openclaw:mainfrom
zqchris:fix/web-tools-trusted-fake-ip

Conversation

@zqchris

@zqchris zqchris commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

The trusted-endpoint helper used by Tavily / Brave / Exa / hosted Firecrawl search providers passes a policy of {} to fetchWithSsrFGuard. On fake-IP proxy setups (sing-box / Clash / Surge), every public domain resolves to the 198.18.0.0/15 RFC 2544 benchmark range or fc00::/7 IPv6 ULA, which is unconditionally blocked unless the policy opts in.

#74571 extended the public tools.web.fetch.ssrfPolicy to accept allowRfc2544BenchmarkRange / allowIpv6UniqueLocalRange, but the parallel hardcoded trusted/self-hosted web-tool policies in web-guarded-fetch.ts:10-14 still pass {} and a partial exemption respectively, so users on fake-IP proxies still see:

[security] blocked URL fetch (url-fetch) targetOrigin=https://api.tavily.com reason=Blocked: resolves to private/internal/special-use IP address

…even after configuring tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRange: true in their config — because web_search providers don't read user config, they use the hardcoded trusted policy.

Change

-const WEB_TOOLS_TRUSTED_NETWORK_SSRF_POLICY: SsrFPolicy = {};
+const WEB_TOOLS_TRUSTED_NETWORK_SSRF_POLICY: SsrFPolicy = {
+  allowRfc2544BenchmarkRange: true,
+  allowIpv6UniqueLocalRange: true,
+};
 const WEB_TOOLS_SELF_HOSTED_NETWORK_SSRF_POLICY: SsrFPolicy = {
   dangerouslyAllowPrivateNetwork: true,
   allowRfc2544BenchmarkRange: true,
+  allowIpv6UniqueLocalRange: true,
 };

The trusted path still rejects RFC1918 private networks, link-local, loopback, and cloud-metadata hostnames — only the fake-IP-only special-use ranges are exempted, matching how tools.web.fetch.ssrfPolicy was extended in #74571.

Test plan

  • Local repro: pnpm openclaw infer web search --query "test" failed with SsrFBlockedError on a Surge fake-IP setup before the patch
  • After the patch + rebuild, the same call returns Tavily results
  • Re-ran web_fetch against various non-fake-IP destinations — still blocked as expected (no regression on real public IPs)
  • CI: pnpm test src/agents/tools/web-guarded-fetch.test.ts (added cases would be welcome — happy to add if the maintainers prefer it in this PR)

Refs

Open question for maintainers (separate, not blocking this fix)

The same fake-IP exemption is currently impossible to configure for two other ssrf-policy paths:

  • browser.ssrfPolicy — schema rejects allowRfc2544BenchmarkRange and allowIpv6UniqueLocalRange
  • models.providers.*.request — same rejection

Real-world impact for fake-IP proxy users (we see this on api.openai.com, generativelanguage.googleapis.com, image-describe pulling remote reference images, etc):

[security] blocked URL fetch (url-fetch) target=https://api.openai.com/v1/audio/transcriptions reason=Blocked: ...
[security] blocked URL fetch (url-fetch) target=https://generativelanguage.googleapis.com/... reason=Blocked: ...
[tools] image failed: Failed to fetch media from https://pbs.twimg.com/media/... : Blocked: ...

Should those schemas be extended to mirror tools.web.fetch.ssrfPolicy, or is the deliberate design that browser navigation and provider HTTP must rely solely on dangerouslyAllowPrivateNetwork plus DNS-level fake-IP exemptions outside OpenClaw?

Happy to follow up with separate PRs if the schema extension is desired — wanted to surface the question while you're already in the fake-IP context. Not part of this PR.

🤖 Generated with Claude Code

…RF policy

The trusted-endpoint helper used by Tavily / Brave / Exa / hosted Firecrawl
search providers passes a policy of `{}` to fetchWithSsrFGuard. On fake-IP
proxy setups (sing-box / Clash / Surge), every public domain resolves to the
198.18.0.0/15 RFC 2544 benchmark range or fc00::/7 IPv6 ULA, which is
unconditionally blocked unless the policy opts in.

Apply the same opt-in that openclaw#74571 added to the public `tools.web.fetch`
config to the hardcoded trusted/self-hosted web-tool policies:

  WEB_TOOLS_TRUSTED_NETWORK_SSRF_POLICY:
    + allowRfc2544BenchmarkRange: true
    + allowIpv6UniqueLocalRange: true

  WEB_TOOLS_SELF_HOSTED_NETWORK_SSRF_POLICY:
    + allowIpv6UniqueLocalRange: true (companion to the existing
                                       allowRfc2544BenchmarkRange entry)

Real-world impact: `api.tavily.com` (and every other trusted-endpoint
provider) currently fails with "Blocked: resolves to private/internal/
special-use IP address" on every fake-IP proxy user, even when they have
`tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRange: true` configured.
The trusted endpoint path doesn't read user config; it uses the hardcoded
policy above.

Refs openclaw#74351 (the original fake-IP IPv6 ULA report). The user-facing
`tools.web.fetch` path was fixed in openclaw#74571; this commit covers the parallel
trusted-endpoint path that openclaw#74571 didn't touch.

Open question for maintainers (not blocking this fix): the same fake-IP
exemption is currently impossible to configure for `browser.ssrfPolicy` and
`models.providers.*.request` — both schemas reject `allowRfc2544BenchmarkRange`
and `allowIpv6UniqueLocalRange`. Should those schemas be extended to mirror
`tools.web.fetch.ssrfPolicy`, or is the deliberate design that browser
navigation and provider HTTP must rely on `dangerouslyAllowPrivateNetwork`
plus DNS-level fake-IP exemptions outside OpenClaw? Happy to follow up
separately if the schema extension is desired.
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels May 3, 2026
@clawsweeper

clawsweeper Bot commented May 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge.

Summary
The PR changes src/agents/tools/web-guarded-fetch.ts so trusted web-tool endpoints allow RFC2544 and IPv6 ULA fake-IP ranges, and self-hosted endpoints also include the IPv6 ULA allowance.

Reproducibility: yes. Current main passes {} for trusted web-tool endpoints, while the SSRF implementation only exempts RFC2544 or IPv6 ULA DNS answers when the active policy has the corresponding flag, so a fake-IP lookup on this path is source-reproducible.

Next step before merge
Maintainer/security review should decide whether the trusted helper may default to these SSRF exceptions; after that, the remaining test and changelog fixes are mechanical.

Security
Needs attention: The diff changes the default SSRF policy for trusted web-tool helpers and should get explicit maintainer/security acceptance before merge.

Review findings

  • [P2] Update the web-guarded-fetch policy expectations — src/agents/tools/web-guarded-fetch.ts:21-22
  • [P3] Add the required changelog entry — src/agents/tools/web-guarded-fetch.ts:21-22
Review details

Best possible solution:

Land a tested policy update only after maintainers accept the trusted-helper SSRF exception, with web-guarded-fetch regression coverage and a single-line Unreleased changelog entry.

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

Yes. Current main passes {} for trusted web-tool endpoints, while the SSRF implementation only exempts RFC2544 or IPv6 ULA DNS answers when the active policy has the corresponding flag, so a fake-IP lookup on this path is source-reproducible.

Is this the best way to solve the issue?

No. The direction is plausible, but this PR is not the best mergeable form because it leaves failing test expectations, lacks regression coverage and changelog, and needs explicit maintainer/security acceptance for the default trusted-policy widening.

Full review comments:

  • [P2] Update the web-guarded-fetch policy expectations — src/agents/tools/web-guarded-fetch.ts:21-22
    The existing targeted test still asserts withTrustedWebToolsEndpoint calls fetchWithSsrFGuard with policy: {} and that the self-hosted policy only contains the private-network/RFC2544 fields. With this implementation change, pnpm test src/agents/tools/web-guarded-fetch.test.ts should fail, and the new fake-IP behavior has no regression coverage.
    Confidence: 0.94
  • [P3] Add the required changelog entry — src/agents/tools/web-guarded-fetch.ts:21-22
    This is a user-facing fix(web-tools) behavior change, but the PR changes only the implementation file. OpenClaw policy requires a single-line CHANGELOG.md entry under Unreleased Fixes for this kind of fix.
    Confidence: 0.89

Overall correctness: patch is incorrect
Overall confidence: 0.91

Security concerns:

  • [medium] Confirm the default fake-IP SSRF allowance — src/agents/tools/web-guarded-fetch.ts:21
    The patch makes every trusted web-tool helper caller accept DNS answers in 198.18.0.0/15 and fc00::/7 without an operator opt-in. Those ranges can also represent internal destinations outside fake-IP proxy setups, while current docs describe these policy flags as narrow opt-ins when the proxy owns the synthetic ranges.
    Confidence: 0.76

Acceptance criteria:

  • pnpm test src/agents/tools/web-guarded-fetch.test.ts
  • pnpm test src/infra/net/ssrf.test.ts src/infra/net/fetch-guard.ssrf.test.ts

What I checked:

Likely related people:

  • Val Alexander: Local blame shows the current web-guarded-fetch.ts helper and related SSRF-policy code in this checkout attributed to commit 85c000de1e, which introduced the current helper shape in the available main history. (role: recent maintainer / introduced current helper in local history; confidence: medium; commits: 85c000de1efa; files: src/agents/tools/web-guarded-fetch.ts, src/infra/net/ssrf.ts, src/shared/net/ip.ts)
  • jeffrey701: Provided GitHub context shows merged PR fix(ssrf): allow opt-in IPv6 unique-local exemption for fake-ip proxies #74571 added allowIpv6UniqueLocalRange across the SSRF/IP/web_fetch path and closed the original fake-IP IPv6 ULA report. (role: adjacent fake-IP SSRF feature implementer; confidence: medium; commits: 3b744bff8f72; files: src/shared/net/ip.ts, src/infra/net/ssrf.ts, src/agents/tools/web-fetch.ts)
  • fede-kamel: The changelog credits prior work keeping public web-search provider requests on the strict SSRF guard and reserving private-network access for explicit self-hosted endpoints, which is the boundary this PR changes. (role: adjacent web-search SSRF boundary contributor; confidence: low; files: CHANGELOG.md, src/agents/tools/web-guarded-fetch.ts, src/agents/tools/web-search-provider-common.ts)

Remaining risk / open question:

  • The PR makes RFC2544 and IPv6 ULA exceptions the default for every trusted web-tool helper caller, including SDK-exposed helpers and configured provider base URLs; maintainers should explicitly accept that SSRF boundary change.
  • The implementation-only diff does not update the existing unit expectations or add regression coverage for fake-IP trusted endpoints.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 39bc94e4ddf5.

zqchris pushed a commit to zqchris/openclaw that referenced this pull request May 3, 2026
…rt SSRF guard

The model transport guarded fetch passes `{ allowPrivateNetwork: true }` to
`fetchWithSsrFGuard` only when the operator opts in via
`models.providers.<id>.request.allowPrivateNetwork`. That covers RFC1918
private networks, but not the RFC 2544 benchmark range (198.18.0.0/15) or
IPv6 ULA (fc00::/7) that fake-IP DNS proxies (sing-box / Clash / Surge)
hand back for foreign provider hostnames.

Result: every model API call (LiteLLM gateway, api.openai.com,
generativelanguage.googleapis.com, api.x.ai, api.anthropic.com, etc) on a
fake-IP setup fails with:

  [security] blocked URL fetch (url-fetch) target=https://api.openai.com/...
    reason=Blocked: resolves to private/internal/special-use IP address

…even though those hostnames are reachable just fine through the proxy.
The schema on `models.providers.<id>.request` doesn't currently accept
`allowRfc2544BenchmarkRange` / `allowIpv6UniqueLocalRange` either, so
users have no way to opt in via config.

Fix: thread a fake-IP-only narrow exemption
(`{ allowRfc2544BenchmarkRange: true, allowIpv6UniqueLocalRange: true }`)
into the model transport guard policy. Same pattern the public
`tools.web.fetch` policy uses (openclaw#74571) and the trusted/self-hosted
web-tools endpoint policy in `agents/tools/web-guarded-fetch.ts` (openclaw#76530).

The narrow exemption only un-blocks the two fake-IP-specific special-use
ranges — loopback, RFC1918 private networks, link-local (including
169.254.169.254 cloud metadata), and `metadata.google.internal` stay
blocked unless the operator separately opts in via
`allowPrivateNetwork`. This is a strict subset of the
`ssrfPolicyFromHttpBaseUrlAllowedHostname` allowlist path used by
adjacent plugins, addressing the codex review concern that an
`allowedHostnames` bypass would be broader than the reported fake-IP
failure.

Adds regression coverage in `provider-transport-fetch.test.ts` asserting
that:
  * the policy threaded into `fetchWithSsrFGuard` only contains the
    fake-IP flags (no `allowedHostnames`, no
    `dangerouslyAllowPrivateNetwork`, no `allowPrivateNetwork`)
  * `allowPrivateNetwork: true` from the resolved provider request
    config still merges into the policy when the operator opts in

Refs openclaw#74351 (the original fake-IP IPv6 ULA report) and openclaw#74571 (the
`tools.web.fetch` companion fix). Together with openclaw#76530 (the trusted-web-
tools-endpoint companion), this closes the remaining major fake-IP
user-visible failure path.
@steipete

steipete commented May 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for pushing this. Landed the scoped version in #76887, which keeps web_fetch arbitrary URLs config-only and limits fake-IP DNS allowances to trusted web-search provider hosts / configured model-provider hosts.

Canonical landed PR: #76887
Landed commit: edb7e00

@steipete steipete closed this May 3, 2026
zqchris pushed a commit to zqchris/openclaw that referenced this pull request May 4, 2026
…rt SSRF guard

The model transport guarded fetch passes `{ allowPrivateNetwork: true }` to
`fetchWithSsrFGuard` only when the operator opts in via
`models.providers.<id>.request.allowPrivateNetwork`. That covers RFC1918
private networks, but not the RFC 2544 benchmark range (198.18.0.0/15) or
IPv6 ULA (fc00::/7) that fake-IP DNS proxies (sing-box / Clash / Surge)
hand back for foreign provider hostnames.

Result: every model API call (LiteLLM gateway, api.openai.com,
generativelanguage.googleapis.com, api.x.ai, api.anthropic.com, etc) on a
fake-IP setup fails with:

  [security] blocked URL fetch (url-fetch) target=https://api.openai.com/...
    reason=Blocked: resolves to private/internal/special-use IP address

…even though those hostnames are reachable just fine through the proxy.
The schema on `models.providers.<id>.request` doesn't currently accept
`allowRfc2544BenchmarkRange` / `allowIpv6UniqueLocalRange` either, so
users have no way to opt in via config.

Fix: thread a fake-IP-only narrow exemption
(`{ allowRfc2544BenchmarkRange: true, allowIpv6UniqueLocalRange: true }`)
into the model transport guard policy. Same pattern the public
`tools.web.fetch` policy uses (openclaw#74571) and the trusted/self-hosted
web-tools endpoint policy in `agents/tools/web-guarded-fetch.ts` (openclaw#76530).

The narrow exemption only un-blocks the two fake-IP-specific special-use
ranges — loopback, RFC1918 private networks, link-local (including
169.254.169.254 cloud metadata), and `metadata.google.internal` stay
blocked unless the operator separately opts in via
`allowPrivateNetwork`. This is a strict subset of the
`ssrfPolicyFromHttpBaseUrlAllowedHostname` allowlist path used by
adjacent plugins, addressing the codex review concern that an
`allowedHostnames` bypass would be broader than the reported fake-IP
failure.

Adds regression coverage in `provider-transport-fetch.test.ts` asserting
that:
  * the policy threaded into `fetchWithSsrFGuard` only contains the
    fake-IP flags (no `allowedHostnames`, no
    `dangerouslyAllowPrivateNetwork`, no `allowPrivateNetwork`)
  * `allowPrivateNetwork: true` from the resolved provider request
    config still merges into the policy when the operator opts in

Refs openclaw#74351 (the original fake-IP IPv6 ULA report) and openclaw#74571 (the
`tools.web.fetch` companion fix). Together with openclaw#76530 (the trusted-web-
tools-endpoint companion), this closes the remaining major fake-IP
user-visible failure path.
zqchris pushed a commit to zqchris/openclaw that referenced this pull request May 5, 2026
…rt SSRF guard

The model transport guarded fetch passes `{ allowPrivateNetwork: true }` to
`fetchWithSsrFGuard` only when the operator opts in via
`models.providers.<id>.request.allowPrivateNetwork`. That covers RFC1918
private networks, but not the RFC 2544 benchmark range (198.18.0.0/15) or
IPv6 ULA (fc00::/7) that fake-IP DNS proxies (sing-box / Clash / Surge)
hand back for foreign provider hostnames.

Result: every model API call (LiteLLM gateway, api.openai.com,
generativelanguage.googleapis.com, api.x.ai, api.anthropic.com, etc) on a
fake-IP setup fails with:

  [security] blocked URL fetch (url-fetch) target=https://api.openai.com/...
    reason=Blocked: resolves to private/internal/special-use IP address

…even though those hostnames are reachable just fine through the proxy.
The schema on `models.providers.<id>.request` doesn't currently accept
`allowRfc2544BenchmarkRange` / `allowIpv6UniqueLocalRange` either, so
users have no way to opt in via config.

Fix: thread a fake-IP-only narrow exemption
(`{ allowRfc2544BenchmarkRange: true, allowIpv6UniqueLocalRange: true }`)
into the model transport guard policy. Same pattern the public
`tools.web.fetch` policy uses (openclaw#74571) and the trusted/self-hosted
web-tools endpoint policy in `agents/tools/web-guarded-fetch.ts` (openclaw#76530).

The narrow exemption only un-blocks the two fake-IP-specific special-use
ranges — loopback, RFC1918 private networks, link-local (including
169.254.169.254 cloud metadata), and `metadata.google.internal` stay
blocked unless the operator separately opts in via
`allowPrivateNetwork`. This is a strict subset of the
`ssrfPolicyFromHttpBaseUrlAllowedHostname` allowlist path used by
adjacent plugins, addressing the codex review concern that an
`allowedHostnames` bypass would be broader than the reported fake-IP
failure.

Adds regression coverage in `provider-transport-fetch.test.ts` asserting
that:
  * the policy threaded into `fetchWithSsrFGuard` only contains the
    fake-IP flags (no `allowedHostnames`, no
    `dangerouslyAllowPrivateNetwork`, no `allowPrivateNetwork`)
  * `allowPrivateNetwork: true` from the resolved provider request
    config still merges into the policy when the operator opts in

Refs openclaw#74351 (the original fake-IP IPv6 ULA report) and openclaw#74571 (the
`tools.web.fetch` companion fix). Together with openclaw#76530 (the trusted-web-
tools-endpoint companion), this closes the remaining major fake-IP
user-visible failure path.
zqchris pushed a commit to zqchris/openclaw that referenced this pull request May 5, 2026
…rt SSRF guard

The model transport guarded fetch passes `{ allowPrivateNetwork: true }` to
`fetchWithSsrFGuard` only when the operator opts in via
`models.providers.<id>.request.allowPrivateNetwork`. That covers RFC1918
private networks, but not the RFC 2544 benchmark range (198.18.0.0/15) or
IPv6 ULA (fc00::/7) that fake-IP DNS proxies (sing-box / Clash / Surge)
hand back for foreign provider hostnames.

Result: every model API call (LiteLLM gateway, api.openai.com,
generativelanguage.googleapis.com, api.x.ai, api.anthropic.com, etc) on a
fake-IP setup fails with:

  [security] blocked URL fetch (url-fetch) target=https://api.openai.com/...
    reason=Blocked: resolves to private/internal/special-use IP address

…even though those hostnames are reachable just fine through the proxy.
The schema on `models.providers.<id>.request` doesn't currently accept
`allowRfc2544BenchmarkRange` / `allowIpv6UniqueLocalRange` either, so
users have no way to opt in via config.

Fix: thread a fake-IP-only narrow exemption
(`{ allowRfc2544BenchmarkRange: true, allowIpv6UniqueLocalRange: true }`)
into the model transport guard policy. Same pattern the public
`tools.web.fetch` policy uses (openclaw#74571) and the trusted/self-hosted
web-tools endpoint policy in `agents/tools/web-guarded-fetch.ts` (openclaw#76530).

The narrow exemption only un-blocks the two fake-IP-specific special-use
ranges — loopback, RFC1918 private networks, link-local (including
169.254.169.254 cloud metadata), and `metadata.google.internal` stay
blocked unless the operator separately opts in via
`allowPrivateNetwork`. This is a strict subset of the
`ssrfPolicyFromHttpBaseUrlAllowedHostname` allowlist path used by
adjacent plugins, addressing the codex review concern that an
`allowedHostnames` bypass would be broader than the reported fake-IP
failure.

Adds regression coverage in `provider-transport-fetch.test.ts` asserting
that:
  * the policy threaded into `fetchWithSsrFGuard` only contains the
    fake-IP flags (no `allowedHostnames`, no
    `dangerouslyAllowPrivateNetwork`, no `allowPrivateNetwork`)
  * `allowPrivateNetwork: true` from the resolved provider request
    config still merges into the policy when the operator opts in

Refs openclaw#74351 (the original fake-IP IPv6 ULA report) and openclaw#74571 (the
`tools.web.fetch` companion fix). Together with openclaw#76530 (the trusted-web-
tools-endpoint companion), this closes the remaining major fake-IP
user-visible failure path.
@zqchris
zqchris deleted the fix/web-tools-trusted-fake-ip branch May 17, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants