fix(openai-video-gen): bound video submit response JSON read at 16 MiB#96786
fix(openai-video-gen): bound video submit response JSON read at 16 MiB#96786wangmiao0668000666 wants to merge 2 commits into
Conversation
Replace the unbounded (await response.json()) call in extensions/openai/video-generation-provider.ts with readProviderJsonResponse (16 MiB cap). The download path in the same file already uses readResponseWithLimit — this closes the asymmetry. Reuses the existing SDK helper already used by 15+ other providers.
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: the helper swap is valid, but #96905 now covers the same OpenAI video create-submit read with stronger provider-path proof, a clean merge state, and Response-backed test-helper changes, so keeping both branches open adds duplicate maintainer choice rather than unique value. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Use #96905 as the canonical OpenAI video submit bounded-read fix, close this duplicate branch, and land exactly one maintainer-accepted 16 MiB cap decision. So I’m closing this here and keeping the remaining discussion on #96905. Review detailsBest possible solution: Use #96905 as the canonical OpenAI video submit bounded-read fix, close this duplicate branch, and land exactly one maintainer-accepted 16 MiB cap decision. Do we have a high-confidence way to reproduce the issue? Yes at source/proof level: current main reaches raw Is this the best way to solve the issue? No, not as the best current landing path: the helper swap is correct, but #96905 is the stronger same-surface fix because it keeps the provider JSON reader real in tests and has proof through the exported OpenAI provider path. Security review: Security review cleared: Cleared: the diff narrows an unbounded provider response memory exposure and adds no dependency, workflow, credential, package, or supply-chain surface. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 1bccd2930437. |
ClawSweeper found that the shared provider-http test mock does not export readProviderJsonResponse, causing test failures for any PR importing it. Add the mock to vi.hoisted(), the mock interface, vi.mock() exports, and installProviderHttpMockCleanup(). Default implementation delegates to response.json() to preserve existing test behavior. Co-Authored-By: Claude <[email protected]>
|
@clawsweeper re-review Added
Pre-flight: oxlint ✅, tsgo ✅, vitest 14/14 ✅ |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞✅ Reason: structured ClawSweeper close marker: close-required (sha=21ef5b9dd68c833210c9d2e2d37c5fe6bf1c8f0c) Closed:
|
What Problem This Solves
extensions/openai/video-generation-provider.ts:427parses the Sora submit response with a rawawait response.json()— no byte cap. A malicious or runaway Sora submit endpoint can return an oversized JSON body that exhausts process memory. The download path in the same file already caps atreadResponseWithLimit— this closes the asymmetry.Changes
extensions/openai/video-generation-provider.ts:427— replace(await response.json()) as OpenAIVideoResponsewithreadProviderJsonResponse<OpenAIVideoResponse>(response, "OpenAI video generation failed").Real behavior proof
Behavior addressed: unbounded response.json() on OpenAI video submit response; after the fix reads are capped at 16 MiB.
Real environment tested: real node:http server on 127.0.0.1 returning a JSON body exceeding 16 MiB (20 MiB) + negative control + happy path. Node v22.22.0.
Exact steps or command run after this patch:
Evidence after fix: ```
=== OpenAI video-generation JSON bounded read (cap=16777216) ===
PASS hostile body: overflow; bytesSent=20971758; aborted=true
PASS negative control: small body parsed (id=video_abc123)
PASS happy path: valid JSON parsed (status=completed)
=== All OpenAI video-generation bounded-read assertions passed ===
Observed result after fix: 3/3 assertions pass. Hostile 20 MiB body triggers overflow at 16 MiB cap (bytesSent=20971758, aborted=true). Negative control: small body parsed (id=video_abc123). Happy path: valid JSON parsed (status=completed).
What was not tested: live Sora API call; cross-platform Node differences.
Out of scope
response.json()sites — covered by separate Alix-007-style per-surface PRs.Risk
readProviderJsonResponse— same error shape, 16 MiB default cap. Label"OpenAI video generation failed"matches the existingassertOkOrThrowHttpErrorlabel. The download path in the same file already usesreadResponseWithLimit(same family).Diff stats