fix(chutes): bound OAuth token exchange and userinfo JSON response reads#96262
fix(chutes): bound OAuth token exchange and userinfo JSON response reads#96262cxbAsDev wants to merge 1 commit into
Conversation
Add readChutesOAuthJsonResponse helper wrapping readResponseWithLimit with a 4 MB cap to prevent unbounded buffering of Chutes OAuth API responses (userinfo, token exchange, and token refresh). Co-Authored-By: Claude <[email protected]>
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close this PR in favor of the open canonical Chutes OAuth bounded-read PR, which targets the same three response reads with the repository's shared provider JSON helper, regression tests, and accepted real behavior proof; this branch is a smaller duplicate with a new local helper and weaker proof. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Use #96249 as the canonical landing path and repair its narrow test typecheck blocker instead of merging this duplicate local-helper branch. So I’m closing this here and keeping the remaining discussion on #96249. Review detailsBest possible solution: Use #96249 as the canonical landing path and repair its narrow test typecheck blocker instead of merging this duplicate local-helper branch. Do we have a high-confidence way to reproduce the issue? Yes from source: current main still uses raw Is this the best way to solve the issue? No. Bounding the reads is the right bug fix, but the best repository-shaped solution is the shared Security review: Security review cleared: The diff does not add dependency, workflow, permission, secret, package-resolution, or supply-chain risk; the functional duplicate-helper concern is tracked separately. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 2ab3b223ed69. |
Summary
Replace raw
response.json()calls with a boundedreadChutesOAuthJsonResponsehelper in the Chutes OAuth flow (userinfo fetch, token exchange, and token refresh). The helper wrapsreadResponseWithLimitwith a 4 MB cap to prevent unbounded buffering.Real behavior proof (required for external PRs)
Behavior addressed: Three unbounded
response.json()calls in the Chutes OAuth module replaced with a single boundedreadChutesOAuthJsonResponsehelper usingreadResponseWithLimit.Real environment tested: Linux, Node 24, OpenClaw main @ 92c10d4
Exact steps or command run after fix:
Evidence after fix:
All three response read paths now go through this helper:
fetchChutesUserInfo(line 127)exchangeChutesCodeForTokens(line 167)refreshChutesTokens(line 239)Observed result after fix: OAuth JSON responses are bounded at 4 MB via
readResponseWithLimit. Read stops buffering when the cap is reached, beforeJSON.parseis called.What was not tested: Live Chutes OAuth token exchange and refresh against api.chutes.ai was not tested.
Risk
Low. OAuth token responses are tiny (typically < 10 KB). The 4 MB cap is far above realistic response sizes. The helper function reduces duplication and keeps the bounded read pattern in one place.