Skip to content

fix(vydra,xai,runway,pixverse,deepinfra,together,elevenlabs,microsoft): bound JSON response reads to prevent OOM#96354

Closed
lsr911 wants to merge 1 commit into
openclaw:mainfrom
lsr911:fix/batch1-bounded-json
Closed

fix(vydra,xai,runway,pixverse,deepinfra,together,elevenlabs,microsoft): bound JSON response reads to prevent OOM#96354
lsr911 wants to merge 1 commit into
openclaw:mainfrom
lsr911:fix/batch1-bounded-json

Conversation

@lsr911

@lsr911 lsr911 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Bound xAI OAuth and Vydra speech HTTP response reads using the shared
provider JSON reader to prevent unbounded buffering from untrusted upstream.

Changes

  • extensions/xai/xai-oauth.ts: Replace response.json() with
    readProviderJsonResponse(response, "xai.oauth") (shared 16 MiB default cap)
  • extensions/vydra/speech-provider.ts: Replace response.json() with
    readProviderJsonResponse(response, "vydra.speech") (shared default cap)

Video/image-generation providers intentionally unchanged — already use proper
bounded readers or deferred to focused follow-up PRs.

Evidence

node --import tsx test/_proof_bounded_json.mts

PASS  oversized body: throws bounded cap error
PASS  stream cancelled at cap: bytesSent=1048576
PASS  happy path: small JSON parsed correctly
PASS  negative control: unbounded read buffers PAST cap
[proof] 4 PASS, 0 FAIL

AI-assisted.

@clawsweeper

clawsweeper Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 27, 2026, 2:12 AM ET / 06:12 UTC.

Summary
This PR replaces direct JSON parsing in Vydra speech and xAI OAuth/device-code responses with the shared bounded provider JSON reader.

PR surface: Source +2. Total +2 across 2 files.

Reproducibility: yes. at source level: current main still calls direct response.json() on the targeted Vydra speech and xAI OAuth/device-code paths. I did not establish a full runtime OOM reproduction for those exact paths in this read-only review.

Review metrics: 1 noteworthy metric.

  • Success JSON Reads Capped: 3 changed. The PR changes provider/auth control responses from unbounded response.json() reads to the shared 16 MiB bounded reader, which is the compatibility boundary maintainers should notice before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
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:

  • [P1] Add redacted xAI OAuth/device-code proof or a focused runtime harness showing normal parsing, overflow rejection, and stream cancellation on the changed auth reads.
  • [P1] Add or point to Vydra speech path proof, or rebase/drop the Vydra hunk if fix(vydra): bound control response reads #96875 lands first.
  • [P1] Add focused regression coverage for the unique xAI auth bounded-read paths if maintainers want this branch to carry the fix.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body has terminal output for a generic bounded-reader harness, but not after-fix proof through the changed Vydra speech or xAI OAuth/device-code paths; add redacted screenshots, terminal output, linked artifacts, recordings, or logs, then update the PR body so ClawSweeper re-reviews automatically, or ask a maintainer to comment @clawsweeper re-review if it does not.

Risk before merge

  • [P1] The PR body includes only generic bounded-reader terminal proof, not after-fix proof through the changed Vydra speech or xAI OAuth/device-code paths.
  • [P1] The xAI OAuth discovery, token exchange, refresh, and device-code token responses would change from unbounded parsing to a hard 16 MiB failure path, which is an auth-provider compatibility boundary maintainers should explicitly accept.
  • [P1] The Vydra speech hunk overlaps fix(vydra): bound control response reads #96875, so this PR may need to rebase and drop that hunk if the Vydra-focused PR lands first.
  • [P1] The PR adds no focused xAI or Vydra regression tests, so green CI does not by itself prove the changed provider/auth paths.

Maintainer options:

  1. Require xAI And Vydra Path Proof (recommended)
    Ask for redacted terminal output, logs, or linked artifacts showing normal parsing, oversized-body rejection, and stream cancellation through the changed xAI OAuth/device-code and remaining Vydra speech path before merge.
  2. Coordinate The Vydra Overlap
    If fix(vydra): bound control response reads #96875 lands first, require this PR to rebase and remove the duplicated Vydra speech hunk while preserving the unique xAI OAuth work.
  3. Accept The Auth Cap Explicitly
    Maintainers can intentionally accept the shared 16 MiB cap for xAI auth responses, but that compatibility choice should be visible before landing.

Next step before merge

  • [P1] Human review is needed for contributor-supplied provider/auth path proof, xAI auth cap acceptance, and coordination with the overlapping Vydra-focused PR; there is no automation-safe code repair to queue from this review.

Security
Cleared: The diff narrows untrusted provider/auth response buffering and adds no dependency, workflow, lockfile, permission, package-resolution, generated-code, or secret-handling surface.

Review details

Best possible solution:

Land the bounded-reader approach for xAI OAuth after representative proof and cap acceptance, and either rely on #96875 for Vydra or rebase with equivalent Vydra proof/tests if that PR does not land.

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

Yes at source level: current main still calls direct response.json() on the targeted Vydra speech and xAI OAuth/device-code paths. I did not establish a full runtime OOM reproduction for those exact paths in this read-only review.

Is this the best way to solve the issue?

Yes for the code shape: readProviderJsonResponse is the existing Plugin SDK seam and is the narrowest owner-boundary fix for these reads. It is not merge-ready until path-level proof, xAI auth cap acceptance, and Vydra overlap handling are resolved.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is focused provider/auth response hardening with limited blast radius and no evidence of an active production outage.
  • merge-risk: 🚨 compatibility: The PR intentionally changes oversized Vydra speech and xAI OAuth/device-code JSON bodies from unbounded parsing to a hard 16 MiB failure path.
  • merge-risk: 🚨 auth-provider: The xAI OAuth discovery, token exchange, refresh, and device-code polling paths are auth-provider flows and need representative after-fix proof.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body has terminal output for a generic bounded-reader harness, but not after-fix proof through the changed Vydra speech or xAI OAuth/device-code paths; add redacted screenshots, terminal output, linked artifacts, recordings, or logs, then update the PR body so ClawSweeper re-reviews automatically, or ask a maintainer to comment @clawsweeper re-review if it does not.
Evidence reviewed

PR surface:

Source +2. Total +2 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 5 3 +2
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 2 5 3 +2

What I checked:

  • Root policy read: Root AGENTS.md was read fully; it treats provider/auth fail-closed changes and plugin surfaces as compatibility-sensitive review areas. (AGENTS.md:13, fbfadbd806e1)
  • Scoped extension policy read: extensions/AGENTS.md was read fully; bundled plugin production code may use public SDK helpers such as openclaw/plugin-sdk/provider-http. (extensions/AGENTS.md:20, fbfadbd806e1)
  • PR diff: The live PR patch changes only extensions/vydra/speech-provider.ts and extensions/xai/xai-oauth.ts, replacing three direct JSON reads with readProviderJsonResponse. (8d385e17c26a)
  • Current main Vydra gap: Current main still parses the Vydra speech synthesis success response with direct response.json(). (extensions/vydra/speech-provider.ts:132, fbfadbd806e1)
  • Current main xAI OAuth gap: Current main still parses xAI OAuth discovery/token responses through direct response.json() in readJsonResponse. (extensions/xai/xai-oauth.ts:120, fbfadbd806e1)
  • Current main xAI device-code gap: Current main also directly calls response.json() while polling the xAI device-code token endpoint. (extensions/xai/xai-oauth.ts:418, fbfadbd806e1)

Likely related people:

  • Peter Steinberger: Git history shows this author introduced both the xAI OAuth module and the Vydra media provider areas touched by this PR. (role: feature introducer and area contributor; confidence: high; commits: af2b31319422, 9b2b22f35010; files: extensions/xai/xai-oauth.ts, extensions/vydra/speech-provider.ts)
  • Milosz Jankiewicz: Recent merged work changed xAI OAuth token endpoint rediscovery in the same module and adjacent tests. (role: recent xAI OAuth contributor; confidence: medium; commits: 0347ae48ea78; files: extensions/xai/xai-oauth.ts, extensions/xai/xai-oauth.test.ts)
  • Jaaneek: Prior merged work changed OAuth login behavior and User-Agent attribution in the same xAI auth module. (role: recent xAI OAuth contributor; confidence: medium; commits: 5f1df99a9c23; files: extensions/xai/xai-oauth.ts, extensions/xai/xai-oauth.test.ts)
  • Vincent Koc: Recent provider hardening bounded Vydra and Comfy media downloads near the Vydra speech path. (role: adjacent provider hardening contributor; confidence: medium; commits: 0902ee723b76; files: extensions/vydra/speech-provider.ts, extensions/vydra/shared.ts)
  • Alix-007: Merged shared provider JSON response hardening introduced the helper pattern used here, and the open Vydra-focused PR overlaps this PR's Vydra speech hunk. (role: adjacent shared-reader contributor; confidence: medium; commits: 2592f8a51a4e, 88125a070f3b; files: src/agents/provider-http-errors.ts, extensions/vydra/speech-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.

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 24, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: line Channel integration: line channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: feishu Channel integration: feishu channel: irc extensions: minimax extensions: kimi-coding extensions: kilocode channel: qqbot extensions: qa-lab extensions: codex extensions: amazon-bedrock labels Jun 25, 2026
lsr911 added a commit to lsr911/openclaw that referenced this pull request Jun 25, 2026
…ponseWithLimit

The readResponseWithLimit function expects a full Response type, but these
providers accept Pick<Response, "json"> as their parameter. Add an explicit
cast at the call site.

Refs openclaw#96354

Co-Authored-By: Claude <[email protected]>
@lsr911

lsr911 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Closing: check-test-types CI failure.

@lsr911 lsr911 closed this Jun 25, 2026
@lsr911 lsr911 reopened this Jun 26, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. size: M triage: blank-template Candidate: PR template appears mostly untouched. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. size: S labels Jun 26, 2026
@lsr911

lsr911 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 26, 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.

@lsr911

lsr911 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 26, 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.

@lsr911

lsr911 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 26, 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.

@lsr911

lsr911 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

… provider helpers

- xai-oauth: use readProviderJsonResponse for OAuth token responses
- vydra-speech: use readProviderJsonResponse for speech synthesis responses

Co-Authored-By: Claude <[email protected]>
Signed-off-by: lsr911 <[email protected]>
@lsr911

lsr911 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 27, 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.

@lsr911

lsr911 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

2 similar comments
@lsr911

lsr911 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@lsr911

lsr911 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@lsr911

lsr911 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Closed: merge conflicts with upstream. Superseded by cleaner single-module PRs covering the same modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: xai merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: blank-template Candidate: PR template appears mostly untouched.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant