Repository navigation
fix(google): bound Vertex ADC OAuth token refresh responses - #98706
ly85206559 wants to merge 0 commit into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: this PR is a clean narrow raw-body cap, but #98507 is the better canonical Vertex ADC OAuth hardening path because it covers the same parser, the same unbounded token-response read, and the decoded gzip-output bound with positive proof and clean mergeability. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this narrower branch and use #98507 as the canonical Google Vertex ADC OAuth response hardening path. So I’m closing this here and keeping the remaining discussion on #98507. Review detailsBest possible solution: Close this narrower branch and use #98507 as the canonical Google Vertex ADC OAuth response hardening path. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main reaches Is this the best way to solve the issue? No for this branch as the best landing path: the raw-body cap is a correct narrow mitigation, but #98507 is the better canonical fix because it also bounds decoded gzip output in the same parser. Security review: Security review cleared: The diff narrows an existing memory-exhaustion path and does not add dependencies, workflows, scripts, permissions, lockfile changes, or external code execution. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against b6f4cf5ac432. |
|
Thanks for the review. I'm fine with either path:
No further code changes planned from my side unless maintainers request them. |
bfb9d4f to
83a679b
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
83a679b to
a34b8a8
Compare
What Problem This Solves
Fixes a sibling OOM risk in the Google Vertex ADC OAuth token refresh path. Gemini CLI OAuth calls already cap HTTP bodies at 16 MiB via
fetchWithTimeout, butreadGoogleOauthTokenResponsePayloadin the Vertex ADC refresh flow still buffered the full token response withresponse.arrayBuffer(). A faulty or hostile OAuth endpoint could stream an oversized refresh body and grow gateway memory without bound.Related: #98507 covers the same bug class with additional gzip/decompression hardening.
Why This Change Was Made
The Vertex ADC refresh path now uses the shared bounded response reader (
readResponseWithLimit) and reusesGOOGLE_OAUTH_BODY_MAX_BYTES(16 MiB) fromoauth.http.tsso the cap stays consistent across Google OAuth call sites.This follows the same invariant as recent Google provider hardening work (for example #98692 on embedding batch reads): legitimate small token responses keep working, but unbounded provider output must be cancelled early.
Scope is intentionally narrow:
oauth.http.tsarrayBuffer()read inreadGoogleOauthTokenResponsePayloadThis PR does not change ADC discovery, cache behavior, gzip decode policy, or non-OAuth Vertex auth flows.
User Impact
Users running Google Vertex with
authorized_userADC keep the same refresh behavior for normal token responses (typically well under 10 KiB). If a refresh response exceeds 16 MiB, the gateway now fails fast with a clear error instead of buffering the entire body into memory.Evidence
Shared bounded-read wire proof:
oauth.http.test.tsexercises the samereadResponseWithLimithelper this PR uses on the Vertex ADC path against a localhttp.createServerlistener on127.0.0.1with realfetch()and streamed chunked bodies. No mocked reader.Targeted unit proof: the new tests drive the production
resolveGoogleVertexAuthorizedUserHeaders->refreshGoogleVertexAuthorizedUserAccessToken->readGoogleOauthTokenResponsePayloadpath with realResponsestreams passed through an injectedfetchImpl. They cover the normal authorized_user refresh case and the oversized streamed refresh body case that previously relied on unboundedarrayBuffer().Notes for reviewers:
oauth.http.ts. Legitimate ADC token responses are far smaller; the cap is a fail-closed bound against unbounded wire reads, not a product limit change.maxOutputLengthhardening present in fix(google-vertex-adc): bound token response body read to prevent OOM #98507. If maintainers prefer one combined fix, that sibling PR is the broader option; this one is the minimal shared-cap alignment for the ADC refresh read site.AI-assisted: built with Codex. I understand the change: it replaces the unbounded Vertex ADC OAuth token refresh
arrayBuffer()read with the shared 16 MiB bounded response reader and adds focused regression tests for normal and oversized streamed refresh bodies.