Skip to content

fix(provider-transport): pass baseUrl hostname to SSRF guard so fake-IP proxies don't block model API calls - #76543

Closed
zqchris wants to merge 1 commit into
openclaw:mainfrom
zqchris:fix/provider-transport-fake-ip
Closed

zqchris wants to merge 1 commit into
openclaw:mainfrom
zqchris:fix/provider-transport-fake-ip

Conversation

@zqchris

@zqchris zqchris commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Companion to #74571 (public tools.web.fetch config) and #76530 (trusted web-tools endpoint policy). Fixes the third major fake-IP user-visible failure path: all model API calls (LiteLLM proxies, api.openai.com, generativelanguage.googleapis.com, api.x.ai, api.anthropic.com, etc).

On fake-IP DNS proxy setups (sing-box / Clash / Surge), every foreign provider hostname resolves into the 198.18.0.0/15 RFC 2544 benchmark range (or fc00::/7 IPv6 ULA). Currently the model transport guarded fetch only opts in via requestConfig.allowPrivateNetwork, which exempts RFC1918 private networks but not the fake-IP-only special-use ranges. The schema on models.providers.<id>.request doesn't accept allowRfc2544BenchmarkRange / allowIpv6UniqueLocalRange either, so users have no config-level escape hatch.

Symptom every fake-IP user sees:

[security] blocked URL fetch (url-fetch) target=https://api.openai.com/v1/audio/transcriptions
  reason=Blocked: resolves to private/internal/special-use IP address
[security] blocked URL fetch (url-fetch) target=https://generativelanguage.googleapis.com/...
  reason=Blocked: resolves to private/internal/special-use IP address
[image-generation] candidate failed: litellm/gpt-image-2:
  Blocked: resolves to private/internal/special-use IP address

Change

Thread the resolved model.baseUrl hostname through ssrfPolicyFromHttpBaseUrlAllowedHostname() so the configured provider host short-circuits the SSRF private-IP check via allowedHostnames.

+import { ssrfPolicyFromHttpBaseUrlAllowedHostname } from "../infra/net/ssrf.js";
…
+  const baseUrlPolicy = ssrfPolicyFromHttpBaseUrlAllowedHostname(model.baseUrl);
…
-      ...(requestConfig.allowPrivateNetwork ? { policy: { allowPrivateNetwork: true } } : {}),
+      ...(baseUrlPolicy || requestConfig.allowPrivateNetwork
+        ? {
+            policy: {
+              ...(baseUrlPolicy ?? {}),
+              ...(requestConfig.allowPrivateNetwork ? { allowPrivateNetwork: true } : {}),
+            },
+          }
+        : {}),

Why this is safe

This is the same pattern already used in the codebase by:

  • ElevenLabs (extensions/elevenlabs/speech-provider.ts)
  • OpenAI TTS (extensions/openai/tts.ts)
  • BlueBubbles (extensions/bluebubbles/src/client.ts)
  • Feishu (extensions/feishu/src/streaming-card.ts)
  • Google Meet (extensions/google-meet/src/oauth.ts)
  • LM Studio (extensions/lmstudio/src/stream.ts)
  • Slack (extensions/slack/src/send.ts)
  • Azure Speech, Ollama, GitHub Copilot embeddings, Kilocode

Each of those plugins resolves its own configured base URL and allowlists just that hostname. This commit moves the same allowlist into the shared transport so every provider that goes through buildGuardedModelFetch (i.e. all LLM chat / image / embedding / audio) benefits without each plugin having to copy the boilerplate.

The hostname is operator-configured (via models.providers.<id>.baseUrl or the bundled-catalog default), so allowlisting just the configured provider host is no broader trust than what the plugins above already grant their own configured hostnames.

Test plan

  • Local repro: chat / image / Whisper calls failed with SsrFBlockedError on a fake-IP setup before the patch
  • After the patch + rebuild, chat / fallback (litellm/claude-sonnet-4-6), image (litellm/gpt-image-2), Whisper transcription, and gemini-3-pro-image-preview via internal LiteLLM all return real responses
  • Re-checked: requests to non-configured hostnames still fall through to the existing private-IP / cloud-metadata block (no regression — allowedHostnames only short-circuits the configured base URL host)
  • CI: agent-runner / pi-embedded transport tests (existing test coverage in provider-transport-fetch.test.ts should still pass; happy to add a fake-IP regression test if maintainers prefer)

Refs

🤖 Generated with Claude Code

…IP proxies don't block model API calls

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 the operator already trusts that hostname via the configured
`baseUrl`. 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 `ssrfPolicyFromHttpBaseUrlAllowedHostname(model.baseUrl)` into
the guard policy. Same pattern as ElevenLabs (`speech-provider.ts`),
OpenAI TTS (`tts.ts`), BlueBubbles (`client.ts`), Feishu
(`streaming-card.ts`), Google-Meet (`oauth.ts`), LM Studio
(`stream.ts`), Slack (`send.ts`), Azure Speech (`tts.ts`), Ollama
(`embedding-provider.ts`), and others. The provider hostname is operator-
configured, so allowlisting just it is no broader trust than what those
plugins already grant their own configured hostnames.

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 that landed/proposed earlier), this covers the
remaining major fake-IP user-visible failure path.
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS r: too-many-prs Auto-close: author has more than twenty active PRs. labels May 3, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because the author has more than 20 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling r: too-many-prs Auto-close: author has more than twenty active PRs. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant