Repository navigation
Conversation
jeffrey701
commented
Apr 29, 2026
|
Codex review: found issues before merge. What this changes: Adds an optional IPv6 unique-local SSRF-policy exemption to shared IP/SSRF helpers and tests so Maintainer follow-up before merge: This is an open contributor implementation PR with a concrete blocking wiring bug on a security-sensitive SSRF surface; the next step is maintainer/author revision and review rather than an automated replacement job. Security review: Security review cleared: The diff touches SSRF policy but defaults remain closed and there are no dependency, CI, secret, or supply-chain changes; the blocking issue is incomplete functional wiring for the new opt-in. Review findings:
Review detailsBest possible solution: Revise the PR so the IPv6 ULA opt-in is a complete, documented Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3059702687da. |
Closes openclaw#74351. AI-assisted, fully tested. Sing-box / Clash / Surge fake-ip proxy stacks resolve foreign domains to BOTH IPv4 198.18.0.0/15 AND IPv6 fc00::/7 simultaneously. Setting `tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRange: true` already exempted the IPv4 leg, but the IPv6 ULA range stayed unconditionally blocked, so every web_fetch through a fake-ip proxy still failed with "Blocked: resolves to private/internal/special-use IP address". ## Approach Adds a separate, opt-in `allowIpv6UniqueLocalRange` flag rather than extending `allowRfc2544BenchmarkRange`'s semantics. Reasons: - No silent behavior change for existing `allowRfc2544BenchmarkRange: true` users — their IPv6 surface stays exactly as restrictive as it was. - Operators can mix and match: only IPv4 fake-ip ranges, only IPv6 ULA, or both, depending on which proxy they actually run. - Matches the issue's "Alternatively, provide a separate configuration option for exempting the IPv6 ULA range" suggestion, which is the conservative of the two presented options. ## Implementation - `src/shared/net/ip.ts`: new `Ipv6SpecialUseBlockOptions` type; `isBlockedSpecialUseIpv6Address` now takes optional opts and returns false for `range() === "uniqueLocal"` only when `allowUniqueLocalRange === true`. Loopback (`::1`), unspecified (`::`), multicast (`ff00::/8`), discard, reserved, and the deprecated site-local `fec0::/10` keep their unconditional block — the exemption is scoped to ULA, not "any reserved IPv6 range". - `src/infra/net/ssrf.ts`: new `allowIpv6UniqueLocalRange` field on `SsrFPolicy`, mirrored into `normalizeSsrFPolicyForComparison` so `isSameSsrFPolicy` participates in policy-cache invalidation. New `resolveIpv6SpecialUseBlockOptions` helper threaded through the `isPrivateIpAddress` path. The `media/parse.ts` call site keeps the default options (no opt-in), so media URL safety stays unchanged. ## Tests - `src/shared/net/ip.test.ts` — 2 new unit tests covering the wrapper contract and the explicit "exemption is scoped to ULA only" invariant (loopback / multicast / fec0:: stay blocked even with the new flag). - `src/infra/net/ssrf.test.ts` — 7 new `it.each` rows covering the policy-threading: ULA blocked by default; exempt with the new flag; other reserved ranges still blocked; the new flag is independent of `allowRfc2544BenchmarkRange` (neither implies the other). Plus a new `isSameSsrFPolicy` case asserting the new field participates in semantic equality. `pnpm test src/shared/net/ip.test.ts src/infra/net/ssrf.test.ts src/infra/net/ssrf.pinning.test.ts src/infra/net/fetch-guard.ssrf.test.ts` — 108 passed across 4 files. `pnpm exec oxfmt --check` — clean. `pnpm exec oxlint` — 0 warnings, 0 errors. ## AI-assisted PR - [x] Mark as AI-assisted (Claude). Lightly tested via targeted Vitest shards on the four ssrf/ip-policy files; not exercised end-to-end against a live fake-ip proxy stack — operator confirmation welcome if a maintainer has that environment handy. - [x] Confirm I understand what the code does: yes — the SSRF gate is delegating to `isBlockedSpecialUseIpv6Address`, and the new flag is a per-call, per-policy opt-out for one specific IPv6 range.
7a074f8 to
3b744bf
Compare
|
Thanks @jeffrey701, landed in 9b6670d. I kept the low-level IPv6 ULA SSRF policy from this PR and added the missing public plumbing: Verification:
|
…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.
…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.
…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.
…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.