Repository navigation
Fix/bound copilot login json responses - #97583
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 29, 2026, 12:52 AM ET / 04:52 UTC. Summary PR surface: Source +3, Tests +205. Total +208 across 2 files. Reproducibility: yes. Current main and v2026.6.10 call native response.json() in postGitHubDeviceFlowForm, and the existing fetch-guard test seam can inject an oversized success Response on either device-flow call path. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 bounded-reader change after required checks settle and maintainers accept the shared 16 MiB Copilot login cap, while keeping the separate SDK token-exchange work in #97579. Do we have a high-confidence way to reproduce the issue? Yes. Current main and v2026.6.10 call native response.json() in postGitHubDeviceFlowForm, and the existing fetch-guard test seam can inject an oversized success Response on either device-flow call path. Is this the best way to solve the issue? Yes. Reusing the existing plugin-sdk readProviderJsonResponse facade is the narrowest maintainable owner-boundary fix and matches sibling Copilot usage and embeddings hardening. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 75db48a17522. Label changesLabel justifications:
Evidence reviewedPR surface: Source +3, Tests +205. Total +208 across 2 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
|
|
I checked the current red CI on
The other red traces I checked look outside this PR's Copilot login surface: |
b1d3772 to
a54b999
Compare
a54b999 to
266d2b1
Compare
266d2b1 to
2716ebc
Compare
2716ebc to
b93af65
Compare
fix(github-copilot): bound device-flow JSON response reads
What Problem This Solves
postGitHubDeviceFlowForminextensions/github-copilot/login.tscallsawait response.json()on success responses from both the device-code URL andthe access-token polling URL without any byte limit. An attacker who can intercept
or spoof the GitHub endpoint (MITM, DNS poisoning, or operator-misconfigured proxy)
could return an arbitrarily large JSON body and exhaust Node.js heap memory.
The fix is XS: one import line, two lines at the call site.
Why This Change Was Made
readProviderJsonResponse(fromopenclaw/plugin-sdk/provider-http) caps JSON readsat 16 MiB, cancels the underlying
ReadableStreamon overflow, and surfaces aprovider-tagged error. The same helper is already used in
extensions/github-copilot/usage.tsandembeddings.tswithin the same extension —no new dependency surface is added.
The non-OK branch (
!response.ok) already throws before reading the body; only thesuccess-body read at line 151 was unbounded.
User Impact
are well under 1 KiB. The full normal flow (device code → authorization → token)
passes the regression suite unchanged.
ProviderHttpError("github-copilot.device-flow: JSON response exceeds 16777216 bytes").Evidence
Unit tests —
extensions/github-copilot/login.test.ts(new file, 7 tests)Tests use
setGitHubCopilotDeviceFlowFetchGuardForTesting(the existing test seam)to inject real
Responseobjects without mocking any modules. Coverage:{ status: "authorized", accessToken },showCodecalled with correct args, exactly 2 network callsaccess_denied{ status: "access_denied" }expired_token{ status: "expired" }"GitHub device code failed: HTTP 401""GitHub device token failed: HTTP 500""github-copilot.device-flow",readCount < 64,canceled === true"github-copilot.device-flow",readCount < 64,canceled === trueReal-network proof (
node scripts/proof-copilot-login-bound.mjs)A local
node:httpserver streams 64 MiB. The client read ~17 MiB (cap + TCPbuffer) before cancelling; the remaining ~47 MiB was never transferred.
Files changed
extensions/github-copilot/login.tsreadProviderJsonResponse; replaceawait response.json()extensions/github-copilot/login.test.ts