Skip to content

fix(xai): apply request policy to video generation requests - #104836

Merged
Solvely-Colin merged 27 commits into
openclaw:mainfrom
Alix-007:alix/xai-request-policy-video-generation
Jul 16, 2026
Merged

Solvely-Colin merged 27 commits into
openclaw:mainfrom
Alix-007:alix/xai-request-policy-video-generation

Conversation

@Alix-007

@Alix-007 Alix-007 commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users generating video with xAI could configure provider request policy, such as custom headers or proxy settings, but xAI video generation requests ignored that policy.

Why This Change Was Made

The xAI video provider now sanitizes cfg.models.providers.xai.request and passes it into the existing provider HTTP resolver used by the create, poll, and download flow. The poll and download flow now always uses the guarded provider fetch path; private-network access is enabled only when explicitly configured. The change leaves generation parameters, polling semantics, idempotency headers, and media parsing unchanged.

User Impact

Users who depend on configured provider transport policy can expect xAI video generation to honor those request settings. With no request policy, provider-controlled xAI video status/download URLs now stay on the default SSRF-protected path instead of being fetched through an unguarded fallback.

Evidence

Additional exact-head local controlled transport proof (redacted):

  • Head: 9ed880e8aa71
  • Command: node scripts/run-vitest.mjs extensions/xai/video-generation-provider.transport.test.ts --reporter verbose
  • Result: passed, 1 file / 3 tests.
  • Observed transcript:
RUN v4.1.9 <repo>

✓ extensions/xai/video-generation-provider.transport.test.ts > xai video generation provider transport > uses configured policy for xAI API requests without leaking headers to video downloads
✓ extensions/xai/video-generation-provider.transport.test.ts > xai video generation provider transport > blocks default loopback xAI video requests before reaching the server
✓ extensions/xai/video-generation-provider.transport.test.ts > xai video generation provider transport > blocks explicit false loopback xAI video requests before reaching the server

Test Files  1 passed (1)
Tests       3 passed (3)

Observation: the exact-head controlled loopback transport proof covers configured-policy forwarding plus zero loopback server reachability for both unset/default request policy and explicit allowPrivateNetwork: false. This is local controlled proof, not a live xAI provider run.

  • node scripts/run-vitest.mjs extensions/xai/video-generation-provider.test.ts passed: 19 tests.
  • git diff --check passed.
  • .agents/skills/autoreview/scripts/autoreview --mode local --engine claude --model claude-fable-5 --thinking high reported no accepted/actionable findings.

2026-07-12 follow-up: local controlled request-policy proof

  • Commit 523f5999e4 fixes the review gap by passing the resolved xAI request policy through video create, poll, and generated-video download. The poll/download stages now use guarded provider fetches when allowPrivateNetwork or a dispatcher/proxy policy is configured, while preserving the existing unconfigured fast path and bounded xAI JSON/media readers.
  • Local focused proof: node scripts/run-vitest.mjs extensions/xai/video-generation-provider.test.ts passed: 19 tests.
  • The focused regression now asserts the configured header, explicit private-network opt-in, and dispatcher policy are visible on all three changed stages: create submit, status poll, and generated-video download.
  • This is controlled local provider-path proof only. No live xAI API call was made and no real xAI account, proxy, or media generation was exercised.

2026-07-13 follow-up: default-deny SSRF guard repair

  • Current head 0ba4e54026 includes 3edeec9ec3 and removes the unguarded xAI video poll/download fallback. fetchXaiVideoResponse now always calls fetchWithTimeoutGuarded; allowPrivateNetwork is passed only when explicitly true, and dispatcher policy/header behavior remains preserved.
  • Added controlled local transport proof for both unset request policy and explicit request.allowPrivateNetwork: false: each case points xAI baseUrl at a local loopback HTTP server and asserts server.requests remains 0, proving the guard blocks before the server receives a connection.
  • Local lightweight check run by the maintainer agent: git diff HEAD --check — passed.
  • Not run locally: focused Vitest, because this is contributor/fork source and the current agent policy uses secretless fork CI/sanitized remote proof for untrusted code execution. The pushed head is expected to run the added transport/unit tests in GitHub CI.
  • Merge/update note: 17ad46ac16 merges latest upstream/main into the branch with the provider-http-mocks.ts conflict resolved by keeping the current SDK dispatcherPolicy return type while preserving the xAI guarded-fetch mock support.
  • CI repair note: 0ba4e54026 removes unused test helper code and restores the mocked fetchWithTimeout timeout assertion type after the main merge.

Proof

2026-07-12 exact-head local transport proof after CI-refresh update-branch

  • Exact head tested after normal gh pr update-branch: 4ffb626175e89d694394ae655a69128245807ef0.

  • Scope: controlled local provider-path proof for xAI video generation create, poll, and generated-video download. This is not a live xAI API call.

  • Commands run:

    git fetch fork alix/xai-request-policy-video-generation --no-tags
    git checkout --detach FETCH_HEAD
    git rev-parse HEAD
    git diff --check
    node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/xai/video-generation-provider.ts extensions/xai/video-generation-provider.test.ts extensions/xai/video-generation-provider.transport.test.ts
    node scripts/run-vitest.mjs extensions/xai/video-generation-provider.transport.test.ts extensions/xai/video-generation-provider.test.ts
  • Result: PASS. git diff --check passed; focused oxlint exited 0; Vitest passed 1 shard, 2 files, 20 tests in 22.02s total wall time. Vitest duration: 14.47s.

  • Transcript excerpt:

    HEAD is now at 4ffb626175 Merge branch 'main' into alix/xai-request-policy-video-generation
    4ffb626175e89d694394ae655a69128245807ef0
    Test Files  2 passed (2)
    Tests  20 passed (20)
    [test] passed 1 Vitest shard in 22.02s
    
  • Observation: extensions/xai/video-generation-provider.transport.test.ts starts a local HTTP server and drives the real provider path through video create, poll, and generated-video download. The configured X-Xai-Trace header and Authorization header reach only xAI API-origin create/poll requests; the generated-video download request is a plain GET and does not include the custom header or Authorization. The companion unit test also asserts the download init remains headerless and the provider no longer overrides request-policy private-network opt-in with caller-level allowPrivateNetwork:false.

  • Not tested: no live xAI account, real API key, external proxy/TLS route, real video generation job, or external provider endpoint was exercised.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 12, 2026
@clawsweeper

clawsweeper Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 14, 2026, 7:08 AM ET / 11:08 UTC.

Summary
The PR applies sanitized xAI provider request policy to video creation, polling, and generated-video downloads, routes poll/download requests through guarded fetches, and adds focused unit and controlled HTTP transport coverage.

PR surface: Source +90, Tests +309. Total +399 across 5 files.

Reproducibility: yes. at source level: current main hardcodes caller-level private-network denial, omits sanitized xAI request config, and uses unguarded poll/download helpers, so configured headers, proxy policy, and private-network policy cannot consistently reach all three stages. The review did not execute a failing current-main live xAI request.

Review metrics: 2 noteworthy metrics.

  • Transport Policy Coverage: 3 stages changed: create, poll, download. The change affects the complete asynchronous provider workflow, so the security and compatibility decision applies beyond the initial API submission.
  • Private-Network Default: 1 default changed: unguarded to deny. Poll and download URLs that were previously fetched without SSRF guarding now require explicit private-network permission.

Stored data model
Persistent data-model change detected: serialized state: extensions/xai/video-generation-provider.transport.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Risk before merge

  • [P1] Existing workflows that currently accept an xAI-returned private-network status or media URL without an explicit models.providers.xai.request.allowPrivateNetwork: true will fail after merge; the controlled proof confirms that this is an intentional default-deny behavior change, not merely request-header propagation.
  • [P1] The request-policy dispatcher now participates in generated-video download traffic while configured provider headers and authorization are intentionally withheld from that potentially different origin; maintainers should confirm that this split is the permanent xAI transport contract.

Maintainer options:

  1. Confirm And Land Default-Deny (recommended)
    Have an xAI/provider-transport owner approve the explicit-opt-in upgrade contract, refresh the branch, and gate the exact head through normal checks.
  2. Preserve Narrow Compatibility
    Adjust the policy so an explicitly configured trusted xAI origin remains reachable while provider-returned cross-origin URLs stay guarded and headerless.
  3. Pause Pending Live Origin Proof
    Defer or close the PR if maintainers require live xAI evidence about poll and download URL origins before changing the security boundary.

Next step before merge

  • [P2] A provider-transport owner should decide the default-deny private-network upgrade contract; no narrow mechanical repair or contributor proof action remains.

Maintainer decision needed

  • Question: Should xAI video polling and generated-video downloads become default-deny for private-network destinations, requiring explicit models.providers.xai.request.allowPrivateNetwork: true even though current behavior fetches those URLs unguarded?
  • Rationale: The code and proof establish the behavior precisely, but choosing between preserving the shipped permissive path and enforcing the safer default is a compatibility and SSRF-policy decision that automation should not make.
  • Likely owner: KateWilkins — KateWilkins is the strongest available xAI-specific routing candidate, while provider-transport reviewers can confirm the shared security contract.
  • Options:
    • Accept Default-Deny (recommended): Adopt guarded polling and downloads with explicit private-network opt-in, retaining the PR’s header-isolation and transport tests.
    • Preserve Configured-Origin Compatibility: Use the shared configured-origin trust contract or another narrow compatibility rule while still guarding provider-returned cross-origin media URLs.
    • Pause The Change: Keep current behavior until xAI URL-origin guarantees and upgrade expectations are documented with live provider evidence.

Security
Cleared: The patch strengthens the SSRF boundary, keeps authorization and configured xAI headers off generated-media downloads, and introduces no new dependency, secret, permission, or supply-chain concern.

Review details

Best possible solution:

Keep the shared sanitized request-policy resolver and guarded fetch path, preserve header isolation for generated-media URLs, and merge only after the provider owner explicitly accepts default-deny private-network behavior with explicit opt-in as the supported upgrade contract.

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

Yes at source level: current main hardcodes caller-level private-network denial, omits sanitized xAI request config, and uses unguarded poll/download helpers, so configured headers, proxy policy, and private-network policy cannot consistently reach all three stages. The review did not execute a failing current-main live xAI request.

Is this the best way to solve the issue?

Yes, conditionally: resolving the existing provider request policy at the xAI plugin boundary and using shared guarded HTTP primitives is the narrow maintainable fix. The remaining question is intentional upgrade policy, not a known implementation defect.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 236a6b815c18.

Label changes

Label justifications:

  • P2: This is a bounded xAI provider bug fix with strong focused proof but a limited compatibility and security-boundary decision before merge.
  • merge-risk: 🚨 compatibility: Merging can make existing xAI video workflows fail when status or media URLs resolve to private networks without newly explicit opt-in.
  • merge-risk: 🚨 security-boundary: The PR changes SSRF enforcement and the separation of provider-origin headers from generated-media download traffic.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The exact-head controlled HTTP harness exercises the real xAI provider create/poll/download path and visibly proves policy forwarding, header isolation, and default/explicit-false loopback blocking; a live xAI account or external proxy run would be additional confidence, not a contributor merge-gate gap.
  • proof: sufficient: Contributor real behavior proof is sufficient. The exact-head controlled HTTP harness exercises the real xAI provider create/poll/download path and visibly proves policy forwarding, header isolation, and default/explicit-false loopback blocking; a live xAI account or external proxy run would be additional confidence, not a contributor merge-gate gap.
Evidence reviewed

PR surface:

Source +90, Tests +309. Total +399 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 136 46 +90
Tests 2 309 0 +309
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 445 46 +399

What I checked:

  • Current-main bug path: Current main resolves xAI video HTTP config with caller-level allowPrivateNetwork: false, does not sanitize or pass models.providers.xai.request, and then uses unguarded operation/download helpers for polling and media retrieval; this explains both the ignored request policy and the existing SSRF-boundary inconsistency. (github.com) (extensions/xai/video-generation-provider.ts:415, 236a6b815c18)
  • Shared policy contract: The shared resolver gives explicit caller policy precedence, defaults private-network access to false, preserves explicit true/false values from sanitized model-provider request config, and exposes dispatcher policy for guarded requests. (github.com) (src/agents/provider-request-config.ts:2254, 236a6b815c18)
  • Sibling implementation: The OpenAI video provider already sanitizes provider request configuration, applies it to creation and polling, and keeps download authorization headers separate while passing private-network and dispatcher policy through the guarded path. (github.com) (extensions/openai/video-generation-provider.ts:461, 236a6b815c18)
  • Guard contract: fetchWithTimeoutGuarded is the shared provider HTTP security seam and documents proxy-aware SSRF handling, including strict treatment where proxy bypass could otherwise skip pinned-DNS checks. (github.com) (src/media-understanding/shared.ts:573, 236a6b815c18)
  • Exact-head proof: The PR body records exact-head controlled transport proof over the real provider path: create and poll receive configured xAI-origin headers, download remains headerless, default and explicit-false loopback requests reach the server zero times, and focused tests and lint pass. This is convincing after-fix behavior proof, though not a live xAI account or external-proxy run. (extensions/xai/video-generation-provider.transport.test.ts:1, 8100634402d0)
  • Review continuity: The latest completed ClawSweeper cycle at the same head reported no findings and retained only the provider-owner decision about default-deny SSRF and upgrade behavior; this review found no new head change or concrete patch defect that invalidates that conclusion. (8100634402d0)

Likely related people:

  • KateWilkins: Recent repository history and routing signals connect KateWilkins to adjacent xAI provider work, making them a useful xAI-specific reviewer; the exact video-file ownership trail is incomplete because local git-history commands were unavailable. (role: adjacent xAI contributor; confidence: medium; files: extensions/xai/video-generation-provider.ts)
  • vincentkoc: The PR timeline routes this security- and compatibility-sensitive provider change to vincentkoc, and repository policy identifies provider/runtime seams as requiring owner review. (role: provider transport reviewer; confidence: medium; files: extensions/xai/video-generation-provider.ts, src/media-understanding/shared.ts)
  • Takhoffman: The PR timeline also routes the provider-boundary review to Takhoffman; the available evidence supports review relevance but not sole ownership. (role: adjacent provider reviewer; confidence: low; files: extensions/xai/video-generation-provider.ts, src/agents/provider-request-config.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.
Review history (22 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-13T04:18:54.943Z sha 9ed880e :: needs maintainer review before merge. :: none
  • reviewed 2026-07-13T11:39:07.458Z sha db142e8 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-13T11:54:30.369Z sha db142e8 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-13T15:44:33.410Z sha 692204f :: needs maintainer review before merge. :: none
  • reviewed 2026-07-13T17:41:28.165Z sha 0cb8b24 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T02:22:35.127Z sha 0fc6c42 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T10:22:30.657Z sha 8100634 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T10:46:03.201Z sha 8100634 :: needs maintainer review before merge. :: none

@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 12, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 12, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 12, 2026
@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Current head 08bdeda fixes the real xAI video request-policy gap found by local transport proof: request.allowPrivateNetwork is no longer overridden, and the PR now includes a controlled local xAI API/download harness. PR body Proof records git diff check, focused oxlint, and node scripts/run-vitest.mjs extensions/xai/video-generation-provider.transport.test.ts extensions/xai/video-generation-provider.test.ts passing 2 files / 20 tests. The harness proves create/poll receive the configured custom header while generated-video download remains headerless. This is controlled local endpoint proof, not a live xAI request.

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 13, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jul 13, 2026
@Solvely-Colin
Solvely-Colin merged commit dcf1107 into openclaw:main Jul 16, 2026
113 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 16, 2026
yetval added a commit to yetval/openclaw that referenced this pull request Jul 27, 2026
…ownloads

The byteplus and runway video-generation providers fetched the generated
video from a URL taken out of the provider's own completion response using
an unguarded download call, never re-applying the SSRF guard (DNS pinning,
private/loopback/link-local blocking) they already apply to submit and poll.
A compromised, MITM'd, or malicious-base-URL provider could point that result
URL at an internal address and OpenClaw would fetch it and save the bytes as
the generated video (CWE-918), with default configuration.

Add a canonical fetchGuardedProviderDownloadResponse helper that mirrors
fetchProviderDownloadResponse but always routes the download through the SSRF
guard, blocking private targets by default while honoring the resolved
allowPrivateNetwork and dispatcherPolicy operator opt-in. Thread the resolved
policy into both providers' download step. This matches the always-on guard
already used by fal and openrouter and closes the default-configuration gap.

minimax (openclaw#102072) and xai (openclaw#104836) are already guarded; vydra is covered by
open PR openclaw#105884.

Closes openclaw#103083
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: xai merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants