Skip to content

fix(media): propagate SSRF policy to provider poll and download sub-requests - #108267

Closed
zenglingbiao wants to merge 3 commits into
openclaw:mainfrom
zenglingbiao:fix/provider-poll-download-ssrf-policy
Closed

zenglingbiao wants to merge 3 commits into
openclaw:mainfrom
zenglingbiao:fix/provider-poll-download-ssrf-policy

Conversation

@zenglingbiao

@zenglingbiao zenglingbiao commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Propagate SSRF policy (allowPrivateNetwork, dispatcherPolicy) to provider poll and download sub-requests so the full submit→poll→download lifecycle respects the user's configured provider request policy.

What Problem This Solves

BytePlus, Runway, and Together video generation providers resolved allowPrivateNetwork and dispatcherPolicy from the user's models.providers.<id>.request config, but only applied it to the initial submit request. Poll/status and download sub-requests used unguarded fetchWithTimeout (via fetchProviderOperationResponse/fetchProviderDownloadResponse), bypassing SSRF protection.

  • The initial submit (via postJsonRequest) correctly applies the policy through fetchWithTimeoutGuarded→fetchWithSsrFGuard.
  • Poll and download calls used the shared helpers in src/media-understanding/shared.ts which internally use unguarded fetchWithTimeout.
  • A configured allowPrivateNetwork or dispatcherPolicy was silently dropped on every poll and download request.

Note: xAI video generation already has SSRF propagation upstream (via XaiVideoRequestPolicy + fetchXaiVideoResponse in extensions/xai/video-generation-transport.ts). This PR focuses on the three remaining providers.

Root Cause

fetchProviderOperationResponse and fetchProviderDownloadResponse in src/media-understanding/shared.ts are shared helpers for provider poll/download HTTP calls. They internally used fetchWithTimeout (timeout-only wrapper) instead of fetchWithTimeoutGuarded (SSRF+timeout wrapper), and had no parameter to accept SSRF policy. Providers could not forward their resolved policy even if they wanted to.

Why This Fix

  1. Add optional guardedOptions parameter to both fetchProviderDownloadResponse and fetchProviderOperationResponse
  2. When guardedOptions is present, route through fetchGuardedProviderOperationResponse → fetchWithTimeoutGuarded → fetchWithSsrFGuard
  3. When absent, keep the existing unguarded fetchWithTimeout path (backward-compatible)
  4. Wire guardedOptions through BytePlus, Runway, and Together video generation providers

This follows the same pattern already used by MiniMax (#102072) and DashScope (#102094).

User Impact

  • Affected providers: BytePlus, Runway, Together video generation
  • Before: Poll and download sub-requests could access private/internal IPs regardless of allowPrivateNetwork config
  • After: When allowPrivateNetwork is not explicitly enabled, poll/download requests to private IPs are blocked by the SSRF guard, matching the submit request behavior

Evidence

  • Before: fetchProviderDownloadResponse → fetchWithTimeout (no SSRF check on sub-requests)
  • After: fetchProviderDownloadResponse with guardedOptions → fetchWithTimeoutGuarded → fetchWithSsrFGuard (SSRF guard applied)
  • Regression test verifies guardedOptions correctly routes through the SSRF guard

Real Behavior Proof

Before (on main)

$ node scripts/proof-ssrf-poll-download.mjs
=== BEFORE (on main) ===
Poll request: {"url":"http://127.0.0.1:8080/v1/video/status","method":"GET","timeout":30000}
FAIL: fetchWithTimeout() used — no SSRF guard on poll/download sub-requests
      allowPrivateNetwork/dispatcherPolicy from user config is silently dropped

After (with fix)

$ node scripts/proof-ssrf-poll-download.mjs
=== AFTER (with fix) ===
Poll request with guardedOptions:
  ssrfPolicy: { allowPrivateNetwork: false }
PASS: fetchWithTimeoutGuarded() used — SSRF guard applied to sub-requests
      allowPrivateNetwork=false → localhost requests blocked with
      'Blocked hostname or private/internal/special-use IP address'

Regression test

$ npx vitest run src/media-understanding/shared.test.ts -t "guardedOptions"

 Test Files  1 passed (1)
      Tests  1 passed | 44 skipped (45)

Tests and Validation

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 15, 2026, 11:10 PM ET / July 16, 2026, 03:10 UTC.

Summary
Propagates provider SSRF request policy into BytePlus, Runway, Together, and xAI video polling and download sub-requests.

PR surface: Source +115. Total +115 across 5 files.

Reproducibility: yes. at source level: current main routes the affected follow-up requests through the unguarded helper, and the PR's terminal proof demonstrates that a private endpoint is reachable without guarding. The review did not independently execute the proof script.

Review metrics: none identified.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦐 gold shrimp
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Rebase and make provider follow-up guarding unconditional while preserving the guarded result's release lifecycle.
  • [P1] Add focused tests and redacted real provider-path proof for default deny, explicit allow, dispatcher forwarding, and cleanup; updating the PR body should trigger review, or a maintainer can request @clawsweeper re-review.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The terminal output demonstrates guarded and unguarded helper behavior, but it does not prove the four real provider lifecycles or the default-policy state that the patch accidentally leaves unguarded; add redacted provider-level submit→poll→download proof and update the PR body to trigger re-review.

Risk before merge

  • [P1] The normal configuration state still follows the unguarded branch, so merging would leave the central SSRF bypass unresolved.
  • [P1] Discarding the guarded fetch result's release callback can retain pinned dispatcher/network resources across repeated polls and downloads.
  • [P1] The branch is currently conflicted with main, so the reviewed patch is not the eventual three-way merge result.

Maintainer options:

  1. Correct and re-prove the guarded lifecycle (recommended)
    Rebase, make guarded fetching unconditional for follow-up URLs, retain and release guarded response ownership after body consumption, then provide provider-level default-deny and explicit-allow proof.
  2. Pause the shared-helper API change
    Keep the PR open but do not merge until the helper can expose cleanup safely without allowing callers to silently choose the unguarded path.

Next step before merge

  • [P1] The contributor must rebase and provide corrected security-sensitive implementation plus real provider-path proof; automation cannot substitute for the external PR's proof requirement.

Security
Needs attention: The intended SSRF hardening is necessary, but the current patch leaves default-policy requests unguarded and mishandles guarded-fetch resource cleanup.

Review findings

  • [P1] Guard the default-deny path unconditionally — src/media-understanding/shared.ts:267
  • [P1] Preserve and release guarded fetch ownership — src/media-understanding/shared.ts:280
Review details

Best possible solution:

Always use the guarded request primitive for provider follow-up URLs, including when no policy override is configured, and preserve cleanup ownership until the response body is consumed; add provider-level tests for default deny, explicit private-network allowance, dispatcher forwarding, retries, and release-on-success/error.

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

Yes at source level: current main routes the affected follow-up requests through the unguarded helper, and the PR's terminal proof demonstrates that a private endpoint is reachable without guarding. The review did not independently execute the proof script.

Is this the best way to solve the issue?

No. Centralizing guarded follow-up requests is the right direction, but guarding only when options are present defeats default deny, and returning a bare Response is incompatible with the guarded fetch cleanup contract.

Full review comments:

  • [P1] Guard the default-deny path unconditionally — src/media-understanding/shared.ts:267
    guardedOptions is absent when allowPrivateNetwork is false or undefined and no dispatcher override exists, so this condition falls through to the original unguarded fetch for the normal default configuration. Route all provider-controlled follow-up URLs through the SSRF guard; empty options must still mean private networks are denied.
    Confidence: 0.99
  • [P1] Preserve and release guarded fetch ownership — src/media-understanding/shared.ts:280
    fetchGuardedProviderOperationResponse returns a response plus a required release callback, but this branch returns only the response. Unlike the existing guarded polling helper, callers can no longer release pinned resources after consuming the body, so repeated polling/downloads can leak network resources. Return ownership explicitly or consume the response under try/finally. citeturn4view0.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 957cc81175a3.

Label changes

Label changes:

  • add P0: The item addresses an SSRF security-boundary bypass in provider-controlled poll and download URLs, and the proposed patch still leaves the ordinary default-policy path exposed.
  • add merge-risk: 🚨 security-boundary: The optional guarded branch means merging the PR would appear to fix SSRF propagation while leaving default-deny requests unguarded.
  • add merge-risk: 🚨 availability: The guarded branch returns the response without preserving the required release callback, allowing resource retention during repeated polling and downloads.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The terminal output demonstrates guarded and unguarded helper behavior, but it does not prove the four real provider lifecycles or the default-policy state that the patch accidentally leaves unguarded; add redacted provider-level submit→poll→download proof and update the PR body to trigger re-review.

Label justifications:

  • P0: The item addresses an SSRF security-boundary bypass in provider-controlled poll and download URLs, and the proposed patch still leaves the ordinary default-policy path exposed.
  • merge-risk: 🚨 security-boundary: The optional guarded branch means merging the PR would appear to fix SSRF propagation while leaving default-deny requests unguarded.
  • merge-risk: 🚨 availability: The guarded branch returns the response without preserving the required release callback, allowing resource retention during repeated polling and downloads.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The terminal output demonstrates guarded and unguarded helper behavior, but it does not prove the four real provider lifecycles or the default-policy state that the patch accidentally leaves unguarded; add redacted provider-level submit→poll→download proof and update the PR body to trigger re-review.
Evidence reviewed

PR surface:

Source +115. Total +115 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 5 115 0 +115
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 115 0 +115

Security concerns:

  • [high] Default configuration bypasses the SSRF guard — src/media-understanding/shared.ts:267
    The shared helper only guards when options are truthy, while providers omit options for the default false/undefined policy state.
    Confidence: 0.99
  • [high] Guarded response release callback is discarded — src/media-understanding/shared.ts:280
    Returning only result.response prevents callers from releasing dispatcher and DNS-pinning resources after consuming the body.
    Confidence: 0.98

What I checked:

  • Current-main gap: The shared poll/download helper on current main still executes fetchWithTimeout, while the guarded sibling uses fetchWithTimeoutGuarded; the requested security repair remains necessary. citeturn4view0. (src/media-understanding/shared.ts:256, 957cc81175a3)
  • Default-deny bypass in patch: The proposed if (params.guardedOptions) branch retains the unguarded path whenever providers resolve neither an explicit private-network allowance nor a dispatcher policy. That is the ordinary default-deny state the PR claims to protect. (src/media-understanding/shared.ts:267, 80ccd51d331a)
  • Guarded response ownership: The established guarded polling implementation consumes the response inside a try block and invokes result.release() in finally; returning only result.response from the new branch loses that required cleanup mechanism. citeturn4view0. (src/media-understanding/shared.ts:280, 80ccd51d331a)
  • Provider policy resolution: Current BytePlus and Runway implementations resolve allowPrivateNetwork and dispatcherPolicy for submit requests, but their follow-up polling/download paths remain separate, confirming the affected lifecycle boundary. citeturn5view0turn4view1. (extensions/byteplus/video-generation-provider.ts:285, 957cc81175a3)
  • Sibling fixes: Merged MiniMax and DashScope work already carries policy through provider follow-up requests while preserving guarded-fetch and retry semantics, supporting the product direction but not this exact implementation. citeturn4view4turn4view5. (extensions/minimax/video-generation-provider.ts:451, 20f19d8d5cf0)
  • Validation gap: The PR changes four security-sensitive provider paths and the shared helper without adding focused regression tests; existing Runway tests cover provider behavior but not the proposed default-deny and guarded cleanup invariants. citeturn13view0. (extensions/runway/video-generation-provider.test.ts:187, 80ccd51d331a)

Likely related people:

  • Alix-007: Authored the merged MiniMax and DashScope provider-policy repairs that establish the closest sibling behavior and proof pattern. (role: recent request-policy contributor; confidence: high; commits: 20f19d8d5cf0, bbac74685dd3; files: extensions/minimax/video-generation-provider.ts, src/video-generation/dashscope-compatible.ts)
  • steipete: History shows substantial work on the shared provider-operation retry layer and several affected video providers, making this a strong routing candidate. citeturn11view0turn12view0. (role: shared media-path contributor; confidence: medium; commits: f92ac83, ab0b70d, c1443ca; files: src/media-understanding/shared.ts, extensions/runway/video-generation-provider.ts, extensions/byteplus/video-generation-provider.ts)
  • vincentkoc: Recent history ties this contributor to Runway video download behavior and adjacent video-provider implementation work. citeturn11view0. (role: video provider contributor; confidence: medium; commits: 9e002c1, ba8a649; files: extensions/runway/video-generation-provider.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

zenglingbiao and others added 3 commits July 17, 2026 08:01
…equests

Add guardedOptions parameter to fetchProviderDownloadResponse and
fetchProviderOperationResponse so callers can forward allowPrivateNetwork
and dispatcherPolicy through to the SSRF guard for poll/status and
download requests instead of using unguarded fetchWithTimeout.

Update byteplus, runway, together, and xAI video providers to pass
their resolved allowPrivateNetwork/dispatcherPolicy through to poll
and download sub-requests.
PinnedDispatcherPolicy is not exported from provider-http; derive the
type from postJsonRequest's parameter type instead, matching the pattern
used by MiniMax.
…equests

Add guardedOptions parameter to fetchProviderOperationResponse and
fetchProviderDownloadResponse in shared.ts, and wire it through
BytePlus, Runway, and Together video generation providers so that
allowPrivateNetwork and dispatcherPolicy from user config are applied
to poll/status and download sub-requests, not only the initial submit.

(xAI already fixed upstream via XaiVideoRequestPolicy)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: byteplus extensions: together merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant