Skip to content

fix(agents): scope custom provider baseUrl SSRF trust by origin - #80751

Merged
steipete merged 23 commits into
openclaw:mainfrom
Kaspre:fix/provider-baseurl-ssrf-policy
May 15, 2026
Merged

steipete merged 23 commits into
openclaw:mainfrom
Kaspre:fix/provider-baseurl-ssrf-policy

Conversation

@Kaspre

@Kaspre Kaspre commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Ready for maintainer / security-policy review. Refs #80732.

What this PR does

OpenClaw's SSRF guard blocks outbound HTTP requests whose hostname resolves to a private, loopback, link-local, or CGNAT IP. That's the right default — it prevents a compromised model or a malicious prompt from probing the host's internal network or hitting cloud metadata endpoints (169.254.169.254, the GCP/AWS attack surface).

It also blocks the legitimate case where the operator deliberately configures a custom or self-hosted LLM provider at a private address. Every call to a baseUrl like http://127.0.0.1:1234/v1 (LM Studio), http://localhost:11434/v1 (Ollama), http://10.0.0.5:8000/v1 (vLLM on a LAN VM), or http://192.168.1.10:8080/v1 (llama-server) fails today with SsrFBlockedError. The only escape hatch is request.allowPrivateNetwork: true, which is a blanket opt-in that trusts every private IP — far too broad for a routing decision driven by a single configured endpoint.

This PR adds exact-origin trust. When a custom or local provider is configured with a private/loopback baseUrl, only that exact scheme://host:port is trusted; everything else (different ports, redirects to other origins, metadata addresses, other private hosts) stays blocked. The configured origin is resolved per request inside the guarded fetch's redirect loop, so the trust travels with the request but doesn't widen the policy.

Practical effect: provider.lmstudio.baseUrl: "http://127.0.0.1:1234/v1" works out of the box — without enabling allowPrivateNetwork and without weakening the guard for any other origin.

Safety properties preserved

The exact-origin trust is narrow and revocable:

  • Opt-out wins. Explicit request.allowPrivateNetwork: false disables exact-origin trust even when the origin matches.
  • Port-scoped. A trusted http://10.0.0.5:8000 does not authorize http://10.0.0.5:9000.
  • No redirect drift. Trust attaches to the configured origin, not to wherever a redirect chain ends.
  • Metadata always blocked. Link-local (169.254.0.0/16), cloud metadata literals, IPv6 metadata, and IPv6-embedded IPv4 metadata forms (NAT64, 6to4-style) stay rejected regardless of origin trust.
  • DNS rebinding defense. If a trusted hostname re-resolves to a metadata address mid-request, the request is blocked.
  • Plugin SDK can't bypass. Plugin-supplied allowedOrigins entries for metadata / link-local origins still fail at the resolver.
  • Native providers unaffected. Trust applies only to endpointClass: "custom" | "local". OpenAI, Anthropic, Bedrock, and other native providers remain on the default policy.

Maintainer questions

  • Is exact-origin trust for endpointClass: "custom" | "local" the right SSRF boundary for configured model provider endpoints?
  • Should this remain tied to provider attribution endpoint class, or be limited further to specific OpenAI-compatible APIs?
  • Is exposing allowedOrigins through the plugin SDK SSRF policy acceptable, or should the origin helper stay internal to core fetch-guard code?

Real behavior proof

Behavior or issue addressed: Operator-configured custom/local model provider baseUrl values that point at a private/self-hosted OpenAI-compatible endpoint should work without broad request.allowPrivateNetwork, but trust must stay scoped to the exact configured origin and must not permit metadata targets.

Real environment tested: OpenClaw source at rebased PR head (7ae83f2230105653a77de66a077ab5e0984cde45), real HTTP servers bound to the host private IPv4 address and loopback, and the actual buildGuardedModelFetch provider transport path used for OpenAI-compatible model requests. The proof server implemented the OpenAI-compatible POST /v1/chat/completions shape and used redacted private-IP/loopback baseUrl values.

Exact steps or command run after this patch:

timeout 90s node --import tsx /tmp/openclaw-80751-real-proof.mjs

Evidence after fix: Terminal output from the exact-head proof command showed successful configured private/loopback requests and blocked different-port, explicit-deny, and metadata destinations. The summarized result was:

{
  "proof": "custom/local provider private baseUrl exact-origin SSRF policy",
  "realEnvironment": {
    "endpoint": "OpenAI-compatible HTTP servers bound to host private IPv4 and loopback",
    "privateBaseUrl": "http://<private-ip>:43913/v1",
    "loopbackBaseUrl": "http://127.0.0.1:40589/v1",
    "requestPath": "/v1/chat/completions",
    "repoHead": "7ae83f2230105653a77de66a077ab5e0984cde45"
  },
  "configuredOriginRequest": { "status": 200, "ok": true, "serverReceivedRequests": 1 },
  "differentPortRequest": { "blocked": true, "errorName": "SsrFBlockedError", "serverReceivedRequest": false },
  "explicitDenyRequest": { "blocked": true, "errorName": "SsrFBlockedError", "serverReceivedRequest": false },
  "implicitLoopbackOriginRequest": { "status": 200, "ok": true, "serverReceivedRequests": 1 },
  "implicitLoopbackDifferentPortRequest": { "blocked": true, "errorName": "SsrFBlockedError", "serverReceivedRequest": false },
  "metadataLiteralRequest": { "blocked": true, "errorName": "SsrFBlockedError" },
  "metadataNonLinkLocalRequest": { "blocked": true, "errorName": "SsrFBlockedError" },
  "metadataIpv6Request": { "blocked": true, "errorName": "SsrFBlockedError" },
  "metadataEmbeddedIpv6Request": { "blocked": true, "errorName": "SsrFBlockedError" },
  "metadataHostnameRequest": { "blocked": true, "errorName": "SsrFBlockedError" }
}

Observed result after fix: The configured private and loopback provider origins returned HTTP 200 through the guarded model transport. Different ports, explicit deny, and metadata/cloud-metadata destinations remained blocked. This confirms the change is exact-origin scoped rather than a broad private-network opt-in.

What was not tested: A full LM Studio/vLLM/Ollama binary was not launched; this proof used a minimal OpenAI-compatible self-hosted endpoint to isolate the SSRF policy behavior. Hosted GitHub CI runs after the PR is marked ready; investigate any real failures. The dedicated Real behavior proof workflow re-runs on each push.

Validation

Post-rebase checks on e3f22a18743a0bce780702cd57aea1989013b4c8 (rebased onto origin/main at 02f2e08493; conflict was limited to the regenerable docs/.generated/config-baseline.sha256 baseline hash; one additional commit on top adds an SDK-boundary smoke test):

git merge-tree --write-tree origin/main HEAD
# clean merge tree, no conflicts

git rev-list --left-right --count origin/main...HEAD
# 0 18

git diff --check origin/main..HEAD
# passed

pnpm install --frozen-lockfile
# Done in 10.4s; lockfile already up to date

pnpm config:docs:gen && node --import tsx scripts/generate-config-doc-baseline.ts --check
# OK docs/.generated/config-baseline.sha256

pnpm plugin-sdk:api:gen && node --max-old-space-size=8192 --import tsx scripts/generate-plugin-sdk-api-baseline.ts --check
# OK docs/.generated/plugin-sdk-api-baseline.sha256

env OPENCLAW_VITEST_MAX_WORKERS=1 timeout 240s pnpm test \
  src/shared/net/ip.test.ts \
  src/infra/net/ssrf.test.ts \
  src/agents/provider-transport-fetch.test.ts \
  src/agents/provider-request-config.test.ts \
  src/infra/net/fetch-guard.ssrf.test.ts \
  src/plugin-sdk/ssrf-policy.test.ts
# passed: 4 shards, 241 tests (85 + 62 + 45 + 49)

pnpm check:import-cycles
# Import cycle check: 0 runtime value cycle(s).

pnpm check:architecture
# passed: import cycles + madge cycles + deprecated-api-usage + deprecated-jsdoc

Coverage added for:

  • custom/local private provider baseUrl exact-origin trust without broad allowPrivateNetwork
  • explicit request.allowPrivateNetwork: false disabling exact-origin trust
  • different-port and cross-origin redirects not inheriting trust
  • non-custom public/native endpoints not receiving exact-origin trust
  • metadata/link-local/cloud-metadata literal origins not receiving exact-origin trust
  • DNS rebinding from trusted private DNS to metadata/link-local/cloud-metadata addresses staying blocked
  • exact-origin target trust not authorizing a private explicit proxy
  • embedded IPv4 IPv6 metadata forms, including NAT64/6to4-style addresses
  • custom Anthropic-compatible proxy endpoint classification as custom
  • plugin-supplied allowedOrigins entries for metadata / link-local origins still rejected at the resolver (SDK-boundary smoke test)

Review notes

  • Claude CLI review and Codex /review --base origin/main had no actionable P0/P1/P2 findings on pre-rebase head cff86b616874203a22f8914734ae8f58d4d81ed9.
  • After rebasing onto current origin/main (02f2e08493), focused SSRF/provider regression tests, architecture guards, and generated-baseline checks passed on e3f22a18743a0bce780702cd57aea1989013b4c8.
  • Codex review was unavailable for this rebase (quota); substituted with four parallel Opus subagent review lanes covering the security boundary, plugin-SDK surface, rebase drift, and test coverage. Verdicts: clean / non-issue / no drift / adequate. The one in-scope action item (SDK-boundary smoke test for metadata IPs in plugin-supplied allowedOrigins) is the additional commit on top of the rebase.
  • Earlier Codex review found a P1 test typecheck issue in the transport mock return type; fixed in test(provider): widen transport policy mock and verified with focused TypeScript diagnostics plus the affected Vitest shard.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 11, 2026
@clawsweeper

clawsweeper Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adds exact-origin SSRF trust for custom/local model provider baseUrl requests, exports allowed-origin SSRF helpers through the plugin SDK runtime, updates provider docs/config help, and adds SSRF/provider regression tests.

Reproducibility: yes. source-reproducible: current main reaches guarded provider fetch with fake-IP or broad allowPrivateNetwork policy only, so a configured private custom/local baseUrl lacks exact-origin trust. The linked issue also provides concrete config, logs, and curl sanity evidence.

Real behavior proof
Sufficient (terminal): The PR body and latest Real behavior proof check provide after-fix terminal evidence from real loopback/private HTTP servers through the guarded model transport, including blocked metadata and different-origin cases.

Next step before merge
The remaining blocker is maintainer/security approval of the SSRF boundary and SDK surface; there is no narrow automated repair to queue.

Security
Cleared: Security-sensitive SSRF and SDK diff reviewed; I found no concrete SSRF bypass or supply-chain regression, but policy approval remains required.

Review details

Best possible solution:

Have a maintainer/security owner approve the trust boundary and SDK surface; if approved, land this PR and keep the non-blocking edge/docs items in #81963 as follow-up.

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

Yes, source-reproducible: current main reaches guarded provider fetch with fake-IP or broad allowPrivateNetwork policy only, so a configured private custom/local baseUrl lacks exact-origin trust. The linked issue also provides concrete config, logs, and curl sanity evidence.

Is this the best way to solve the issue?

Unclear until maintainer/security policy review signs off. The implementation is narrow and well covered, but exact-origin private-network trust plus SDK exposure is a policy/API decision rather than a purely mechanical fix.

What I checked:

  • Current-main behavior lacks exact-origin trust: Current main resolves provider fetch policy from matching baseUrl hostnames only into fake-IP hostname policy, plus broad allowPrivateNetwork when explicitly enabled; it does not attach exact scheme/host/port origin trust for private custom/local baseUrl requests. (src/agents/provider-transport-fetch.ts:410, 346a773b1894)
  • PR exact-origin implementation: PR head adds base/request origin comparison, gates exact-origin trust on custom/local endpoint class and absence of explicit denial, blocks metadata-like configured origins, and merges the exact-origin policy with existing fake-IP and broad private-network policies. (src/agents/provider-transport-fetch.ts:465, 968c2e42350f)
  • Redirect-loop scoping: PR head resolves allowedOrigins inside the fetch-guard redirect loop and passes the per-URL policy to hostname checks, pinned DNS, and dispatcher creation, so trust is recalculated after redirects. (src/infra/net/fetch-guard.ts:398, 968c2e42350f)
  • Metadata and link-local guardrail: PR head promotes matching allowedOrigins to allowedHostnames but still rejects trusted-host DNS answers that resolve to link-local or known cloud metadata addresses unless broad private-network policy is explicitly enabled. (src/infra/net/ssrf.ts:419, 968c2e42350f)
  • Regression coverage: PR tests cover exact-origin trust, explicit denial, different-port and cross-host redirects, private DNS, link-local/cloud metadata rebinding, IPv6 metadata forms, and SDK-supplied allowedOrigins rejection at the resolver. (src/infra/net/fetch-guard.ssrf.test.ts:632, 968c2e42350f)
  • Real behavior proof and CI: The PR body includes terminal proof from real loopback/private HTTP servers through the guarded model transport, and the latest head check runs include green aggregate check, check-test-types, Security High network-ssrf-boundary, and Real behavior proof. (968c2e42350f)

Likely related people:

  • steipete: Recent current-main history shows repeated work on provider guarded fetch policy, fake-IP SSRF scoping, local services, local-provider defaults, and LM Studio endpoint trust in the affected files. (role: recent area contributor; confidence: high; commits: edb7e00721fd, f7081a3879f2, 848c28537b1f; files: src/agents/provider-transport-fetch.ts, src/infra/net/ssrf.ts, docs/providers/lmstudio.md)
  • scoootscooob: Authored recent pinned SSRF lookup behavior that this PR relies on for DNS pinning and resolved-address ordering semantics. (role: adjacent SSRF contributor; confidence: medium; commits: 1382a5e639e3; files: src/infra/net/ssrf.ts)
  • vincentkoc: Recent history includes provider request transport overrides and plugin SDK SSRF/private-network contract work adjacent to the SDK surface touched by this PR. (role: SDK/config adjacent contributor; confidence: medium; commits: 61f13173c29a, 726bfd343423, 63db3443f131; files: src/agents/provider-request-config.ts, src/plugin-sdk/ssrf-policy.ts)

Remaining risk / open question:

  • Exact-origin trust for private custom/local provider endpoints and exposing allowedOrigins through the plugin SDK are security/API policy decisions that still need maintainer approval.
  • The PR's real behavior proof uses a minimal OpenAI-compatible server rather than launching LM Studio, vLLM, or Ollama binaries, although it does exercise the guarded transport path.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 346a773b1894.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 11, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: L triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed size: M proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 12, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@Kaspre
Kaspre force-pushed the fix/provider-baseurl-ssrf-policy branch from cff86b6 to 47a929f Compare May 12, 2026 17:04
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@Kaspre
Kaspre force-pushed the fix/provider-baseurl-ssrf-policy branch from 47a929f to 0e44c7d Compare May 13, 2026 13:56
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@Kaspre
Kaspre force-pushed the fix/provider-baseurl-ssrf-policy branch from 0e44c7d to 7ae83f2 Compare May 13, 2026 14:09
@Kaspre
Kaspre force-pushed the fix/provider-baseurl-ssrf-policy branch from 7ae83f2 to 3cdcbb4 Compare May 14, 2026 11:10
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@Kaspre

Kaspre commented May 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Multi-lane review on rebased head

Codex quota was exhausted at rebase time, so I substituted a multilane Claude review with four parallel Opus subagent review lanes against e3f22a18743a0bce780702cd57aea1989013b4c8. Posting the consolidated findings here, including 1 in-scope item and 7 not immediately addressed.

Lane Verdict P0 P1 P2
Security boundary clean 0 0 3
Plugin SDK surface (clawsweeper concern) non-issue 0 0 1
Test coverage adequate 0 0 4
Rebase drift no drift 0 0 0

In-scope fix applied on top of the rebase

  • test(plugin-sdk): assert metadata-IP allowedOrigins entries are rejected — adds an SDK-boundary smoke test in src/plugin-sdk/ssrf-policy.test.ts that builds a policy via ssrfPolicyFromHttpBaseUrlAllowedOrigin for AWS/Alibaba/GCP/IPv6/link-local metadata targets and asserts resolvePinnedHostnameWithPolicy still rejects each one, plus a DNS-rebinding case from a trusted private DNS origin to a metadata IP. Test would fail if the SDK helper or resolveSsrFPolicyForUrl short-circuited past the metadata block.

Maintainer questions surfaced by the review

  1. BLOCKED_HOSTNAMES symmetry — the pre-DNS hostname blocklist in src/infra/net/ssrf.ts currently contains metadata.google.internal but not the AWS (instance-data, region IMDS hostnames) or Azure (metadata.azure/IMDS endpoint) canonical names. The post-resolution IP guard (assertAllowedTrustedHostnameResolvedAddressesOrThrow) catches rebinding to 169.254.169.254 regardless, so this is defense-in-depth rather than a real gap. Is the IP guard the intended canonical defense, or would you take a follow-up that expands the hostname set for symmetry?

  2. fakeIpPolicy endpointClass gating — src/agents/provider-transport-fetch.ts applies ssrfPolicyFromHttpBaseUrlFakeIpHostnameAllowlist (RFC2544 / IPv6 ULA exemption + hostname allowlist) unconditionally, including for native / public endpointClass. This does not grant allowedOrigins, so there is no SSRF amplification through this PR, but it widens special-use IP acceptance for native providers without an explicit-deny gate. Pre-existing — flagging in case you want it scoped to custom/local in a follow-up.

P2 follow-ups (deferred, not blocking this PR)

Test coverage gaps — none are currently broken, just untested edges:

  • Trailing-slash equivalence of baseUrl (e.g. http://10.0.0.5:1234 vs …/)
  • Default-port elision (http://10.0.0.5/v1 ↔ http://10.0.0.5:80/v1, https://api/v1 ↔ :443/v1)
  • Userinfo in baseUrl (http://user:[email protected]:1234/v1) — URL.origin strips userinfo so origin equality should be unaffected, but worth a pinning assertion
  • Concurrent multi-agent origin-trust isolation (two agents with overlapping but distinct private baseUrls)

Docs:

  • docs/plugins/sdk-subpaths.md does not describe origin-scoped trust semantics for allowedOrigins (request-origin must exactly match, hostname promotion only applies to the current request, metadata/link-local always blocked at the resolver). Worth a small follow-up doc PR.

IPv6 zone-id literal in parseLooseIpAddress is currently fail-closed at ssrf.ts:331 and would also be fail-closed at the DNS-answer re-check; no bypass, but an invariant comment would make the intent self-documenting.

What was verified

  • All 9 PR-body coverage bullets are exercised by named tests (each one traced to a specific it("…")).
  • Negative tests correctly assert both SsrFBlockedError AND that the underlying socket was never opened (fetchImpl).not.toHaveBeenCalled()).
  • No fragility from vi.resetModules + vi.spyOn re-import patterns in any of the modified test files.
  • Rebase drift: 9 commits between the prior rebase point and current 02f2e08493, none touching SSRF / fetch-guard / provider-transport / ip helpers / generated baselines. Exported SSRF helper signatures unchanged; PR has nothing to catch up to.
  • Auto-merges in docs/concepts/model-providers.md and src/config/schema.help.ts produced coherent content (verified by reading the merged regions).
  • Both generated baselines (config-baseline.sha256, plugin-sdk-api-baseline.sha256) regenerated and pass --check.
  • Focused test suite passes locally: 4 shards / 241 tests (85 + 62 + 45 + 49). Architecture guards (check:architecture → import cycles, madge cycles, deprecated-api-usage, deprecated-jsdoc) all green.

Happy to spin off the maintainer-question items or the deferred P2s as separate issues / PRs if you want them tracked.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@Kaspre
Kaspre deleted the fix/provider-baseurl-ssrf-policy branch May 15, 2026 12:51
zqchris added a commit to zqchris/openclaw that referenced this pull request May 21, 2026
…oud metadata blocked

The SsrFPolicy.allowPrivateNetwork flag was respected for private-IP
ranges but not for the loopback/local hostname family (localhost,
localhost.localdomain, *.localhost, *.local, *.internal). BlueBubbles
already passes allowPrivateNetwork:true for Private API calls against
http://localhost:1234, but isBlockedHostnameNormalized ignored the
policy and kept blocking the outbound fetch — BB attachment download
failed SSRF.

Pass the policy into isBlockedHostnameNormalized. When the caller has
explicitly opted into private-network access, skip the hostname family
block. Split BLOCKED_HOSTNAMES so cloud-instance metadata endpoints
stay blocked even with the explicit opt-in (closes the CWE-918 hole
where metadata.google.internal would otherwise leak GCE IAM creds):

- ALWAYS_BLOCKED_CLOUD_METADATA_HOSTNAMES — checked before
  allowPrivateNetwork; metadata.google.internal stays blocked.
- LOOPBACK_HOSTNAMES — passes under allowPrivateNetwork (BB Private API,
  local LiteLLM proxies).

Under allowPrivateNetwork:
- loopback aliases + .localhost / .local pass (LAN service case)
- .internal stays blocked (cloud metadata + enterprise reserved domains)
- ordinary public hostnames pass

Regression coverage: metadata.google.internal blocked under
{allowPrivateNetwork:true} and {dangerouslyAllowPrivateNetwork:true};
.internal suffix table covering bar.compute.internal etc.

Replaces post-build shell script ~/.openclaw/patches/versions/2026.3.11/
proxy-ssrf-localhost.sh.

Upstream PR candidate. (See also: upstream PR openclaw#80751 which restructured
SSRF policy resolution along origin-allowlist lines; this patch will
need porting on rebase past v2026.5.13.)
zqchris added a commit to zqchris/openclaw that referenced this pull request May 22, 2026
…oud metadata blocked

SsrFPolicy.allowPrivateNetwork was respected for private-IP ranges but
not for the loopback/local hostname family (localhost,
localhost.localdomain, *.localhost, *.local, *.internal), so any caller
that explicitly opted into private-network access (local LLM proxies
like LMStudio / Ollama / ComfyUI / LiteLLM at localhost:*, mDNS-bound
services on the home LAN) still had its outbound fetch blocked by
isBlockedHostnameNormalized.

Thread the policy into isBlockedHostnameNormalized. When the caller has
explicitly opted in, skip the hostname-family block. Split
BLOCKED_HOSTNAMES so cloud-instance metadata endpoints stay blocked
even with the explicit opt-in (closes the CWE-918 hole where
metadata.google.internal would otherwise leak GCE IAM credentials):

- ALWAYS_BLOCKED_CLOUD_METADATA_HOSTNAMES — checked before
  allowPrivateNetwork; metadata.google.internal stays blocked.
- LOOPBACK_HOSTNAMES — passes under allowPrivateNetwork.

Under allowPrivateNetwork:
- loopback aliases + .localhost / .local pass (LAN service case)
- .internal stays blocked (cloud metadata + enterprise reserved domains)
- ordinary public hostnames pass

Regression coverage: metadata.google.internal blocked under
{allowPrivateNetwork:true} and {dangerouslyAllowPrivateNetwork:true};
.internal suffix table covering bar.compute.internal etc.

Upstream PR candidate. (See also: upstream PR openclaw#80751 which restructured
SSRF policy resolution along origin-allowlist lines; this patch will
need porting on rebase past v2026.5.13.)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…claw#80751)

* fix(agents): scope provider SSRF trust by origin

* fix(provider): preserve explicit private-network deny

* docs(provider): document exact-origin SSRF trust

* test(provider): cover exact-origin SSRF edges

* docs(provider): align local model private-origin guidance

* refactor(ssrf): keep policy merging in infra

* test(ssrf): cover exact-origin trust through guard

* test(ssrf): block sibling private-origin redirects

* fix(provider): keep loopback trust origin-scoped

* fix(provider): block metadata origin trust

* fix(ssrf): keep metadata rebinding blocked

* fix(ssrf): block cloud metadata origins

* fix(ssrf): block ipv6 metadata origins

* fix(ssrf): block embedded metadata origins

* test(ssrf): cover embedded link-local metadata

* test(provider): cover custom anthropic proxy classification

* test(provider): widen transport policy mock

* test(plugin-sdk): assert metadata-IP allowedOrigins entries are rejected

Plugin authors can construct an SsrFPolicy that lists any well-formed
http(s) origin in allowedOrigins. The abuse-resistance lives one layer
deeper, in resolvePinnedHostnameWithPolicy's metadata/link-local block.
Add an SDK-level smoke test asserting that contract directly:

- AWS/Alibaba IMDS IPv4 literals, GCP metadata canonical hostname,
  IPv6 ULA metadata literal, and non-metadata link-local IPv4 entries
  build a policy via ssrfPolicyFromHttpBaseUrlAllowedOrigin and are
  then rejected at resolvePinnedHostnameWithPolicy.
- DNS rebinding from a trusted private DNS origin to a metadata IP is
  rejected even when the request hostname is origin-trusted.

This would fail if the SDK helper or resolveSsrFPolicyForUrl ever
short-circuited past the metadata block.

* chore(docs): regenerate baselines after upstream rebase

upstream/main moved between rebases; the merged source state for the
PR's `src/config/schema.help.ts` change and the upstream plugin-sdk
surface changes both produce different hashes than the committed
baselines, so `config:docs:check` and `plugin-sdk:api:check` would fail.

Regenerated via `pnpm config:docs:gen` + `pnpm plugin-sdk:api:gen` on
Crabbox; both baselines verified with their respective `--check`
generators.

* test(plugin-sdk): assert SSRF blocked error class

* fix(lint): satisfy exact-origin PR lint rules

* docs: clarify custom provider origin trust

* chore(docs): refresh plugin sdk api baseline

---------

Co-authored-by: Peter Steinberger <[email protected]>
zqchris added a commit to zqchris/openclaw that referenced this pull request May 27, 2026
…oud metadata blocked

SsrFPolicy.allowPrivateNetwork was respected for private-IP ranges but
not for the loopback/local hostname family (localhost,
localhost.localdomain, *.localhost, *.local, *.internal), so any caller
that explicitly opted into private-network access (local LLM proxies
like LMStudio / Ollama / ComfyUI / LiteLLM at localhost:*, mDNS-bound
services on the home LAN) still had its outbound fetch blocked by
isBlockedHostnameNormalized.

Thread the policy into isBlockedHostnameNormalized. When the caller has
explicitly opted in, skip the hostname-family block. Split
BLOCKED_HOSTNAMES so cloud-instance metadata endpoints stay blocked
even with the explicit opt-in (closes the CWE-918 hole where
metadata.google.internal would otherwise leak GCE IAM credentials):

- ALWAYS_BLOCKED_CLOUD_METADATA_HOSTNAMES — checked before
  allowPrivateNetwork; metadata.google.internal stays blocked.
- LOOPBACK_HOSTNAMES — passes under allowPrivateNetwork.

Under allowPrivateNetwork:
- loopback aliases + .localhost / .local pass (LAN service case)
- .internal stays blocked (cloud metadata + enterprise reserved domains)
- ordinary public hostnames pass

Regression coverage: metadata.google.internal blocked under
{allowPrivateNetwork:true} and {dangerouslyAllowPrivateNetwork:true};
.internal suffix table covering bar.compute.internal etc.

Upstream PR candidate. (See also: upstream PR openclaw#80751 which restructured
SSRF policy resolution along origin-allowlist lines; this patch will
need porting on rebase past v2026.5.13.)
zqchris added a commit to zqchris/openclaw that referenced this pull request May 28, 2026
…oud metadata blocked

SsrFPolicy.allowPrivateNetwork was respected for private-IP ranges but
not for the loopback/local hostname family (localhost,
localhost.localdomain, *.localhost, *.local, *.internal), so any caller
that explicitly opted into private-network access (local LLM proxies
like LMStudio / Ollama / ComfyUI / LiteLLM at localhost:*, mDNS-bound
services on the home LAN) still had its outbound fetch blocked by
isBlockedHostnameNormalized.

Thread the policy into isBlockedHostnameNormalized. When the caller has
explicitly opted in, skip the hostname-family block. Split
BLOCKED_HOSTNAMES so cloud-instance metadata endpoints stay blocked
even with the explicit opt-in (closes the CWE-918 hole where
metadata.google.internal would otherwise leak GCE IAM credentials):

- ALWAYS_BLOCKED_CLOUD_METADATA_HOSTNAMES — checked before
  allowPrivateNetwork; metadata.google.internal stays blocked.
- LOOPBACK_HOSTNAMES — passes under allowPrivateNetwork.

Under allowPrivateNetwork:
- loopback aliases + .localhost / .local pass (LAN service case)
- .internal stays blocked (cloud metadata + enterprise reserved domains)
- ordinary public hostnames pass

Regression coverage: metadata.google.internal blocked under
{allowPrivateNetwork:true} and {dangerouslyAllowPrivateNetwork:true};
.internal suffix table covering bar.compute.internal etc.

Upstream PR candidate. (See also: upstream PR openclaw#80751 which restructured
SSRF policy resolution along origin-allowlist lines; this patch will
need porting on rebase past v2026.5.13.)
zqchris added a commit to zqchris/openclaw that referenced this pull request May 31, 2026
…oud metadata blocked

SsrFPolicy.allowPrivateNetwork was respected for private-IP ranges but
not for the loopback/local hostname family (localhost,
localhost.localdomain, *.localhost, *.local, *.internal), so any caller
that explicitly opted into private-network access (local LLM proxies
like LMStudio / Ollama / ComfyUI / LiteLLM at localhost:*, mDNS-bound
services on the home LAN) still had its outbound fetch blocked by
isBlockedHostnameNormalized.

Thread the policy into isBlockedHostnameNormalized. When the caller has
explicitly opted in, skip the hostname-family block. Split
BLOCKED_HOSTNAMES so cloud-instance metadata endpoints stay blocked
even with the explicit opt-in (closes the CWE-918 hole where
metadata.google.internal would otherwise leak GCE IAM credentials):

- ALWAYS_BLOCKED_CLOUD_METADATA_HOSTNAMES — checked before
  allowPrivateNetwork; metadata.google.internal stays blocked.
- LOOPBACK_HOSTNAMES — passes under allowPrivateNetwork.

Under allowPrivateNetwork:
- loopback aliases + .localhost / .local pass (LAN service case)
- .internal stays blocked (cloud metadata + enterprise reserved domains)
- ordinary public hostnames pass

Regression coverage: metadata.google.internal blocked under
{allowPrivateNetwork:true} and {dangerouslyAllowPrivateNetwork:true};
.internal suffix table covering bar.compute.internal etc.

Upstream PR candidate. (See also: upstream PR openclaw#80751 which restructured
SSRF policy resolution along origin-allowlist lines; this patch will
need porting on rebase past v2026.5.13.)
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…claw#80751)

* fix(agents): scope provider SSRF trust by origin

* fix(provider): preserve explicit private-network deny

* docs(provider): document exact-origin SSRF trust

* test(provider): cover exact-origin SSRF edges

* docs(provider): align local model private-origin guidance

* refactor(ssrf): keep policy merging in infra

* test(ssrf): cover exact-origin trust through guard

* test(ssrf): block sibling private-origin redirects

* fix(provider): keep loopback trust origin-scoped

* fix(provider): block metadata origin trust

* fix(ssrf): keep metadata rebinding blocked

* fix(ssrf): block cloud metadata origins

* fix(ssrf): block ipv6 metadata origins

* fix(ssrf): block embedded metadata origins

* test(ssrf): cover embedded link-local metadata

* test(provider): cover custom anthropic proxy classification

* test(provider): widen transport policy mock

* test(plugin-sdk): assert metadata-IP allowedOrigins entries are rejected

Plugin authors can construct an SsrFPolicy that lists any well-formed
http(s) origin in allowedOrigins. The abuse-resistance lives one layer
deeper, in resolvePinnedHostnameWithPolicy's metadata/link-local block.
Add an SDK-level smoke test asserting that contract directly:

- AWS/Alibaba IMDS IPv4 literals, GCP metadata canonical hostname,
  IPv6 ULA metadata literal, and non-metadata link-local IPv4 entries
  build a policy via ssrfPolicyFromHttpBaseUrlAllowedOrigin and are
  then rejected at resolvePinnedHostnameWithPolicy.
- DNS rebinding from a trusted private DNS origin to a metadata IP is
  rejected even when the request hostname is origin-trusted.

This would fail if the SDK helper or resolveSsrFPolicyForUrl ever
short-circuited past the metadata block.

* chore(docs): regenerate baselines after upstream rebase

upstream/main moved between rebases; the merged source state for the
PR's `src/config/schema.help.ts` change and the upstream plugin-sdk
surface changes both produce different hashes than the committed
baselines, so `config:docs:check` and `plugin-sdk:api:check` would fail.

Regenerated via `pnpm config:docs:gen` + `pnpm plugin-sdk:api:gen` on
Crabbox; both baselines verified with their respective `--check`
generators.

* test(plugin-sdk): assert SSRF blocked error class

* fix(lint): satisfy exact-origin PR lint rules

* docs: clarify custom provider origin trust

* chore(docs): refresh plugin sdk api baseline

---------

Co-authored-by: Peter Steinberger <[email protected]>
zqchris added a commit to zqchris/openclaw that referenced this pull request Jun 4, 2026
…oud metadata blocked

SsrFPolicy.allowPrivateNetwork was respected for private-IP ranges but
not for the loopback/local hostname family (localhost,
localhost.localdomain, *.localhost, *.local, *.internal), so any caller
that explicitly opted into private-network access (local LLM proxies
like LMStudio / Ollama / ComfyUI / LiteLLM at localhost:*, mDNS-bound
services on the home LAN) still had its outbound fetch blocked by
isBlockedHostnameNormalized.

Thread the policy into isBlockedHostnameNormalized. When the caller has
explicitly opted in, skip the hostname-family block. Split
BLOCKED_HOSTNAMES so cloud-instance metadata endpoints stay blocked
even with the explicit opt-in (closes the CWE-918 hole where
metadata.google.internal would otherwise leak GCE IAM credentials):

- ALWAYS_BLOCKED_CLOUD_METADATA_HOSTNAMES — checked before
  allowPrivateNetwork; metadata.google.internal stays blocked.
- LOOPBACK_HOSTNAMES — passes under allowPrivateNetwork.

Under allowPrivateNetwork:
- loopback aliases + .localhost / .local pass (LAN service case)
- .internal stays blocked (cloud metadata + enterprise reserved domains)
- ordinary public hostnames pass

Regression coverage: metadata.google.internal blocked under
{allowPrivateNetwork:true} and {dangerouslyAllowPrivateNetwork:true};
.internal suffix table covering bar.compute.internal etc.

Upstream PR candidate. (See also: upstream PR openclaw#80751 which restructured
SSRF policy resolution along origin-allowlist lines; this patch will
need porting on rebase past v2026.5.13.)
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
…claw#80751)

* fix(agents): scope provider SSRF trust by origin

* fix(provider): preserve explicit private-network deny

* docs(provider): document exact-origin SSRF trust

* test(provider): cover exact-origin SSRF edges

* docs(provider): align local model private-origin guidance

* refactor(ssrf): keep policy merging in infra

* test(ssrf): cover exact-origin trust through guard

* test(ssrf): block sibling private-origin redirects

* fix(provider): keep loopback trust origin-scoped

* fix(provider): block metadata origin trust

* fix(ssrf): keep metadata rebinding blocked

* fix(ssrf): block cloud metadata origins

* fix(ssrf): block ipv6 metadata origins

* fix(ssrf): block embedded metadata origins

* test(ssrf): cover embedded link-local metadata

* test(provider): cover custom anthropic proxy classification

* test(provider): widen transport policy mock

* test(plugin-sdk): assert metadata-IP allowedOrigins entries are rejected

Plugin authors can construct an SsrFPolicy that lists any well-formed
http(s) origin in allowedOrigins. The abuse-resistance lives one layer
deeper, in resolvePinnedHostnameWithPolicy's metadata/link-local block.
Add an SDK-level smoke test asserting that contract directly:

- AWS/Alibaba IMDS IPv4 literals, GCP metadata canonical hostname,
  IPv6 ULA metadata literal, and non-metadata link-local IPv4 entries
  build a policy via ssrfPolicyFromHttpBaseUrlAllowedOrigin and are
  then rejected at resolvePinnedHostnameWithPolicy.
- DNS rebinding from a trusted private DNS origin to a metadata IP is
  rejected even when the request hostname is origin-trusted.

This would fail if the SDK helper or resolveSsrFPolicyForUrl ever
short-circuited past the metadata block.

* chore(docs): regenerate baselines after upstream rebase

upstream/main moved between rebases; the merged source state for the
PR's `src/config/schema.help.ts` change and the upstream plugin-sdk
surface changes both produce different hashes than the committed
baselines, so `config:docs:check` and `plugin-sdk:api:check` would fail.

Regenerated via `pnpm config:docs:gen` + `pnpm plugin-sdk:api:gen` on
Crabbox; both baselines verified with their respective `--check`
generators.

* test(plugin-sdk): assert SSRF blocked error class

* fix(lint): satisfy exact-origin PR lint rules

* docs: clarify custom provider origin trust

* chore(docs): refresh plugin sdk api baseline

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime proof: supplied External PR includes structured after-fix real behavior proof. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants