Repository navigation
feat(web-fetch): add ssrfPolicy.allowRfc2544BenchmarkRange config option - #61830
Conversation
Greptile SummaryThis PR adds an opt-in Key changes:
Confidence Score: 4/5Safe to merge; default behavior is unchanged and the SSRF guard is fail-closed. The implementation is well-scoped and security-sensitive paths are handled correctly: SsrFBlockedError is re-thrown (not swallowed by provider fallback), the policy normalization ensures only explicit
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/tools/web-fetch.ts
Line: 370-397
Comment:
**Cache key built from raw `ssrfPolicy`, not the normalized effective policy**
The `ssrfPolicySuffix` is serialized from `params.ssrfPolicy` (the raw config object), but the variable that actually governs fetch behavior — `policy` — is computed ~25 lines later and normalizes the input:
```typescript
// effective policy: only 'true' enables the exemption
const policy =
params.ssrfPolicy?.allowRfc2544BenchmarkRange === true
? { allowRfc2544BenchmarkRange: true }
: undefined;
```
Because the cache key uses the raw object, semantically equivalent strict configs (`ssrfPolicy: undefined`, `ssrfPolicy: {}`, `ssrfPolicy: { allowRfc2544BenchmarkRange: false }`) all produce different cache keys even though they produce identical SSRF behavior. This causes unnecessary cache misses and fragmentation when configs vary structurally but not behaviorally.
The fix is to compute `policy` before building the cache key, then derive the suffix from `policy`:
```typescript
const policy =
params.ssrfPolicy?.allowRfc2544BenchmarkRange === true
? { allowRfc2544BenchmarkRange: true }
: undefined;
const ssrfPolicySuffix = policy ? `:${JSON.stringify(policy)}` : "";
const cacheKey = normalizeCacheKey(
`fetch:${params.url}:${params.extractMode}:${params.maxChars}${ssrfPolicySuffix}`,
);
```
This ensures the cache key directly reflects the effective SSRF behavior, not the raw config shape. The security invariant (permissive and strict entries are still isolated from each other) is preserved.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "chore(config): regenerate schema artifac..." | Re-trigger Greptile |
6c9900d to
f680319
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6803193a9
ℹ️ 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".
30c32c1 to
a33f553
Compare
|
@obviyus This PR fixes a long-standing issue that has a pretty big impact for users running OpenClaw behind a proxy, and now that CI is passing, I’d really appreciate it if you had a chance to take a look. |
a33f553 to
a97f183
Compare
a97f183 to
543ba32
Compare
obviyus
left a comment
There was a problem hiding this comment.
Reviewed latest changes; landing now.
|
Landed on main. Thanks @xing-xing-coder. |
Summary
allowRfc2544BenchmarkRange, butweb_fetchhad no scoped config surface to pass that policy through for fake-IP proxy environments such as Clash TUN, Mihomo, and Surge.198.18.0.0/15, makingweb_fetchunusable even though the underlying network guard already has the necessary benchmark-range allowance capability.tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRangeconfig path, threaded it through runtime/schema handling andweb_fetch, and added regression coverage for default-blocked behavior, explicit opt-in behavior, and cache isolation across policy variants.web_fetchopt-in.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
web_fetchdid not expose an existing lower-level SSRF policy capability at the tool config layer.Regression Test Plan (if applicable)
src/agents/tools/web-fetch.ssrf.test.tssrc/config/schema.test.tssrc/config/schema.base.generated.test.tsUser-visible / Behavior Changes
tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRangeweb_fetchcan access fake-IP-proxied public destinations resolving into198.18.0.0/15.Security Impact (required)
Yes/No) YesYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation:web_fetch-only opt-in for one special-use range.ssrfPolicyso permissive results do not bleed into stricter instances.Repro + Verification
Environment
tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRange: trueSteps
web_fetchagainst a URL resolving into198.18.0.0/15with default config.tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRange.Expected
web_fetch.Actual
Evidence
Human Verification (required)
pnpm checkweb_fetch/ schema surfaceCompatibility / Migration
Yes/No) YesYes/No) Optional new config onlyYes/No) NoRisks and Mitigations
ssrfPolicyis now part of the cache key.