feat(web-fetch): add ssrfPolicy.allowRfc2544BenchmarkRange config option#40354
feat(web-fetch): add ssrfPolicy.allowRfc2544BenchmarkRange config option#40354boat2moon wants to merge 3 commits intoopenclaw:mainfrom
Conversation
When users run behind proxy tools that use fake-IP DNS resolution (e.g. Clash TUN mode mapping hostnames into the 198.18.0.0/15 range), the default SSRF guard blocks every web_fetch request because those addresses fall into the RFC 2544 benchmark reserved range. This change adds a new tools.web.fetch.ssrfPolicy config block with an allowRfc2544BenchmarkRange boolean. Setting it to true lets web_fetch bypass the benchmark-range check, restoring normal operation for users behind such proxies. Changes: - config/zod-schema.agent-runtime.ts: add ssrfPolicy to ToolsWebFetchSchema - config/types.tools.ts: add TypeScript type + JSDoc for ssrfPolicy - agents/tools/web-fetch.ts: wire ssrfPolicy through to fetchWithWebToolsNetworkGuard Closes openclaw#25322
Greptile SummaryThis PR adds a scoped Key finding: Confidence Score: 2/5
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25871f3223
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| url: params.url, | ||
| maxRedirects: params.maxRedirects, | ||
| timeoutSeconds: params.timeoutSeconds, | ||
| policy: params.ssrfPolicy, |
There was a problem hiding this comment.
Isolate web_fetch cache by SSRF policy
This change makes web_fetch behavior depend on params.ssrfPolicy, but the shared FETCH_CACHE key in runWebFetch is still only URL/extractMode/maxChars. In environments with multiple tool instances/configs (or after toggling config at runtime), a fetch performed with allowRfc2544BenchmarkRange: true can populate cache and then be returned to a caller where that flag is false, effectively bypassing the new SSRF guard until cache expiry; the cache key should include policy state (or policy-sensitive requests should not be cached).
Useful? React with 👍 / 👎.
…che hits Address review feedback from Codex and Greptile: when ssrfPolicy differs between tool instances, a cached response from a permissive policy could be served to a restrictive one, bypassing the SSRF guard. Append ':rfc2544' suffix to the cache key when allowRfc2544BenchmarkRange is enabled, ensuring cache isolation between policy configurations.
Extend browser tool SSRF policy to support the allowRfc2544BenchmarkRange option, matching the web_fetch tool. This allows operators behind fake-IP DNS proxies (e.g. Clash TUN mode) to unblock browser navigation for hostnames that resolve to the RFC 2544 benchmark range (198.18.0.0/15). Changes: - types.browser.ts: add field to BrowserSsrFPolicyConfig - zod-schema.ts: add field to browser ssrfPolicy validation - browser/config.ts: read and pass through in resolveBrowserSsrFPolicy - schema.help.ts + schema.labels.ts: add help text and label - config.test.ts + navigation-guard.test.ts: add test coverage - pr-body.md: update PR description to cover both tools
Summary
Add a new
tools.web.fetch.ssrfPolicyconfiguration block that lets operators opt-in to allowing the RFC 2544 benchmark IP range (198.18.0.0/15) through the SSRF guard.Problem
When OpenClaw runs behind proxy tools that use fake-IP DNS resolution (e.g. Clash TUN mode commonly used in China), hostnames resolve to addresses in the 198.18.0.0/15 range. The default SSRF guard correctly identifies these as special-use addresses and blocks every
web_fetchrequest, making the tool completely unusable.The
browsertool already hasssrfPolicy.dangerouslyAllowPrivateNetworkfor similar scenarios, butweb_fetchhad no equivalent escape hatch.Solution
Add a scoped
ssrfPolicyconfig to the web fetch tool:{ "tools": { "web": { "fetch": { "ssrfPolicy": { "allowRfc2544BenchmarkRange": true } } } } }Changes
src/config/zod-schema.agent-runtime.tsssrfPolicytoToolsWebFetchSchemasrc/config/types.tools.tssrc/agents/tools/web-fetch.tsresolveSsrfPolicy(), wire policy through tofetchWithWebToolsNetworkGuardDesign notes
allowRfc2544BenchmarkRangeis exposed; the broaderdangerouslyAllowPrivateNetworkis intentionally not included to limit security impact.SsrFPolicymechanism already used bywithTrustedWebToolsEndpointand the browser tool.Closes #25322
Ref #25258