fix(openai): bound embedding-batch and realtime session JSON respons#97533
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 28, 2026, 1:12 PM ET / 17:12 UTC. Summary PR surface: Source +4, Tests +164. Total +168 across 4 files. Reproducibility: Source-level yes. Current main reaches raw Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this narrow shared-reader change if maintainers accept the 16 MiB success-response cap, and track remaining OpenAI response-read hardening outside this PR. Do we have a high-confidence way to reproduce the issue? Source-level yes. Current main reaches raw Is this the best way to solve the issue? Yes for the two targeted JSON paths. Reusing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 891096926e27. Label changesLabel justifications:
Evidence reviewedPR surface: Source +4, Tests +164. Total +168 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
… reads (openclaw#97533) (cherry picked from commit 4c477ee)
What Problem This Solves
Fixes an issue where two OpenAI success-path JSON reads are unbounded, allowing a misbehaving or hostile endpoint to stream an arbitrarily large response body and cause memory pressure or OOM:
extensions/openai/embedding-batch.ts—fetchOpenAiBatchStatuspolls/batches/:idto track embedding batch progress. The error path was already bounded viareadResponseTextLimited, but the success-pathparsecallback used a rawawait res.json()with no size cap. This is the same asymmetric gap fixed for sibling batch surfaces in fix(embedding): bound OpenAI-compatible embedding response reads #96868 (OpenAI-compatible embeddings) and fix(voyage): bound embedding-batch status, error, and non-OK responses #96608 (GitHub Copilot usage).extensions/openai/realtime-provider-shared.ts—createOpenAIRealtimeSecretfetches ephemeral session tokens for Realtime voice and transcription. The error path usedcreateProviderHttpError(bounded), while the success path fell back to a rawawait response.json(). This shared helper is called by bothcreateOpenAIRealtimeClientSecretandcreateOpenAIRealtimeTranscriptionClientSecret, so both Realtime entry points were affected.Why This Change Was Made
readProviderJsonResponsefromopenclaw/plugin-sdk/provider-httpwrapsreadResponseWithLimitwith the standard 16 MiB cap and stream cancellation. It is a one-call replacement that makes the success path symmetric with the existing error-path bounds, with no behavior change for well-formed endpoints.User Impact
No change for normal OpenAI endpoints. Users running memory embedding batches or Realtime voice/transcription against a self-hosted, misconfigured, or compromised
baseUrlthat returns an oversized success payload will now see a bounded error (Content too large: N bytes (limit: 16777216 bytes)) and early stream cancellation instead of unbounded heap growth.Evidence
Proof script (
node scripts/proof-openai-bound-batch-realtime.mjs, Node v22.22.0):Local test suite (
node scripts/run-vitest.mjs run extensions/openai/embedding-batch.test.ts extensions/openai/realtime-provider-shared.test.ts, Vitest v4.1.8, Node v22.22.0):What was not tested: live OpenAI embedding batch API or Realtime API calls.
AI-assisted.