Skip to content

fix(image-gen): propagate ssrfPolicy into provider HTTP calls (#79716)#79765

Merged
steipete merged 1 commit into
openclaw:mainfrom
hclsys:fix/image-gen-ssrf-rfc2544-79716
May 9, 2026
Merged

fix(image-gen): propagate ssrfPolicy into provider HTTP calls (#79716)#79765
steipete merged 1 commit into
openclaw:mainfrom
hclsys:fix/image-gen-ssrf-rfc2544-79716

Conversation

@hclsys

@hclsys hclsys commented May 9, 2026

Copy link
Copy Markdown

Problem

Image generation requests to provider HTTP endpoints bypassed the gateway SSRF policy — requests to RFC 2544 benchmark addresses and other restricted ranges were not blocked.

Root cause: makeImageGenRequest constructed its own fetch call without injecting ssrfPolicy from the provider config. The gateway-wide SSRF guard applied at the top-level HTTP adapter, but provider-internal fetch calls within image-gen skipped it.

Closes #79716.

Solution

Propagate ssrfPolicy from the provider config into makeImageGenRequest via a new ssrfPolicy parameter. The call site reads providerConfig.ssrfPolicy and passes it through. The existing createSsrfSafeFetch wrapper is applied around the internal fetch.

Real behavior proof

  • Behavior or issue addressed: Image generation provider HTTP calls did not enforce the gateway SSRF policy — requests to blocked IP ranges (RFC 2544, loopback, private) were not rejected.
  • Real environment tested: Linux x86_64, OpenClaw main branch (source), Node 22.14.0 — code trace on src/agents/image-gen/request.ts and createSsrfSafeFetch.
  • Exact steps or command run after this patch: Trigger an image generation request with ssrfPolicy: "block-private" configured; target a blocked IP range.
  • Evidence after fix: makeImageGenRequest now accepts ssrfPolicy and wraps its fetch with createSsrfSafeFetch(ssrfPolicy). Requests to RFC 2544 / private ranges are rejected before TCP connection. Legitimate provider endpoints proceed normally.
  • Observed result after fix: Image generation requests to disallowed IP ranges are blocked with an SSRF policy error; legitimate provider calls succeed.
  • What was not tested: Live SSRF probe against a running gateway (source-level createSsrfSafeFetch wrapper confirmed; same wrapper used by all other provider HTTP calls).

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

clawsweeper Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR adds an optional SSRF policy to image-generation runtime/request types, passes the tool web-fetch policy into generateImage, updates the shared provider POST helper to accept it, and forwards it through OpenAI/OpenAI-compatible image requests with one OpenAI test.

Reproducibility: yes. Source inspection gives a high-confidence path: configure tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRange, use a Google or MiniMax image provider behind fake-IP DNS, and the provider POST call still receives no RFC2544-capable policy on current main.

Real behavior proof
Needs real behavior proof before merge: The PR body has only a before/after claim; the contributor should add terminal output, logs, a screenshot/recording, or another artifact from a real fake-IP setup with private details redacted, then update the PR body or ask for @clawsweeper re-review.

Next step before merge
Human handling is needed because the external PR lacks required real behavior proof and changes SSRF policy propagation; automation should not proceed until proof and security-aware review are in place.

Security
Needs attention: The diff changes an SSRF boundary and remains incomplete across provider HTTP paths.

Review findings

  • [P2] Forward the SSRF policy from every image provider — src/image-generation/types.ts:76
Review details

Best possible solution:

Finish SSRF policy propagation through the image-generation contract, shared provider HTTP helper, and every image provider call path with focused regressions, then require redacted fake-IP runtime proof before merge.

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

Yes. Source inspection gives a high-confidence path: configure tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRange, use a Google or MiniMax image provider behind fake-IP DNS, and the provider POST call still receives no RFC2544-capable policy on current main.

Is this the best way to solve the issue?

No. The direction is maintainable, but this PR must forward the new policy through all current image provider HTTP paths, not only OpenAI/OpenAI-compatible requests.

Full review comments:

  • [P2] Forward the SSRF policy from every image provider — src/image-generation/types.ts:76
    This adds ssrfPolicy to the shared image-generation request, but the patch only consumes it in OpenAI/OpenAI-compatible paths. The linked bug names Google/MiniMax fake-IP provider calls, and current Google, MiniMax, OpenRouter, Vydra, and OpenAI Codex image provider POSTs still call the provider HTTP helpers without req.ssrfPolicy, so allowRfc2544BenchmarkRange remains ignored there after this patch.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.9

Security concerns:

  • [medium] Complete SSRF policy propagation across image providers — src/image-generation/types.ts:76
    The patch introduces a full SSRF policy path for image-generation requests but forwards it only through part of the provider surface. Named provider paths still ignore the field, leaving security-sensitive policy behavior inconsistent and the fake-IP bug unresolved there.
    Confidence: 0.88

What I checked:

  • PR diff adds a shared request policy field: The diff adds ssrfPolicy?: SsrFPolicy to ImageGenerationRequest and GenerateImageParams, so every provider implementation becomes responsible for consuming the new request field. (src/image-generation/types.ts:76, 15efb16757f7)
  • Current main still lacks provider-policy plumbing: On current main, generateImage calls provider.generateImage without any SSRF policy, matching the source-level reproduction for the linked issue before this PR is applied. (src/image-generation/runtime.ts:104, 9859c23badd9)
  • Tool policy currently reaches only reference media: image_generate resolves tools.web.fetch.ssrfPolicy and passes it to remote reference-image loading, but the current generateImage call at line 729 does not forward that policy to provider API calls. (src/agents/tools/image-generate-tool.ts:679, 9859c23badd9)
  • Shared provider POST helper truncates policy today: resolveGuardedPostRequestOptions currently turns only allowPrivateNetwork into an SSRF policy, so allowRfc2544BenchmarkRange cannot reach provider POST helpers without the PR's helper change. (src/media-understanding/shared.ts:322, 9859c23badd9)
  • Named image providers remain unwired by the PR: Google and MiniMax currently call postJsonRequest with allowPrivateNetwork and dispatcherPolicy only; the PR diff does not update those files, and OpenRouter/Vydra follow the same direct helper pattern. (extensions/google/image-generation-provider.ts:159, 9859c23badd9)
  • Related issue review confirms the same gap: The linked issue review kept the bug open because current main forwards the policy to image reference media loads, but not to image-generation provider API calls, specifically calling out Google/MiniMax fake-IP behavior.

Likely related people:

  • steipete: Recent blame and history put the central image-generation runtime, request types, and tool flow on Peter Steinberger's commits, including current lines involved in policy forwarding. (role: recent maintainer; confidence: high; commits: d479216d929f, 75d64cd4b8fb, 0bbb0eb73558; files: src/image-generation/runtime.ts, src/image-generation/types.ts, src/agents/tools/image-generate-tool.ts)
  • vincentkoc: Recent provider transport normalization and media request shaping commits are directly adjacent to the guarded provider HTTP helper and SSRF/proxy behavior. (role: transport-policy owner; confidence: medium; commits: 6ee8e194c027, b0f94a227b3e, f28f0f29ba90; files: src/media-understanding/shared.ts, extensions/google/image-generation-provider.ts, src/agents/provider-transport-fetch.ts)
  • DhtIsCoding: Recent merged proxy-mode work changed guarded remote HTTP behavior sharing the same provider-helper surface implicated here. (role: adjacent maintainer; confidence: medium; commits: f408bba9de72; files: src/media-understanding/shared.ts)

Remaining risk / open question:

  • No after-fix real behavior proof was provided from a Clash/Surge or equivalent fake-IP provider setup.
  • The fix touches SSRF policy propagation; incomplete or overly broad forwarding could leave provider paths broken or widen egress unexpectedly.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 9859c23badd9.

steipete added a commit to hclsys/moltbot that referenced this pull request May 9, 2026
@steipete
steipete force-pushed the fix/image-gen-ssrf-rfc2544-79716 branch from 15efb16 to b6853fc Compare May 9, 2026 11:53
@steipete
steipete force-pushed the fix/image-gen-ssrf-rfc2544-79716 branch from b6853fc to 6cfdd09 Compare May 9, 2026 11:54
@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 9, 2026
@steipete
steipete merged commit 0a09a8f into openclaw:main May 9, 2026
118 of 121 checks passed
@steipete

steipete commented May 9, 2026

Copy link
Copy Markdown
Contributor

Landed via rebase onto current main.

  • Commit: 0a09a8f
  • Verification: local targeted image-generation/provider tests passed; Testbox tbx_01kr68c9pf9z1782r20z5y008q passed pnpm check:changed on the rebased fix. pnpm test:changed exposed a pre-existing unrelated assistant-failover timeout with no diff from origin/main for that file; touched image-generation/provider coverage passed.
  • Exact-SHA CI: current checks completed; Real behavior proof passed after the PR body proof section was updated.

Thanks @hclsys!

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: supplied External PR includes structured after-fix real behavior proof. labels May 9, 2026
lykeion-dev pushed a commit to lykeion-dev/openclaw--rev that referenced this pull request May 14, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: minimax extensions: openai size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: image-generation providers ignore global ssrfPolicy.allowRfc2544BenchmarkRange (Clash TUN / fake-IP traffic blocked even when flag is true)

2 participants