fix(msteams): bound Bot Framework attachmentInfo JSON response reads#99125
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 12:14 PM ET / 16:14 UTC. Summary PR surface: Source +4, Tests +55. Total +59 across 2 files. Reproducibility: yes. Current main has a direct Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land the focused owner-plugin hardening once a maintainer accepts the shared 16 MiB fail-closed cap and exact-head CI/QA is complete. Do we have a high-confidence way to reproduce the issue? Yes. Current main has a direct Is this the best way to solve the issue? Yes. Reusing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e580ed2f7105. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +4, Tests +55. Total +59 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
Review history (1 earlier review cycle)
|
|
@clawsweeper re-review Current head is fd1a8c7. I updated the oversized attachmentInfo test to return a fresh streaming Response and assert the original stream cancellation, then updated the PR body with targeted test, format check, and loopback Bot Framework-style proof for normal metadata plus oversized metadata rejection/cancellation. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
fd1a8c7 to
d8add73
Compare
d8add73 to
660df2c
Compare
|
Maintainer verification complete; this is land-ready at exact head
Thanks @ly85206559 for the focused fix, regression, and original loopback proof. |
|
Merged via squash.
|
…penclaw#99125) * fix(msteams): bound Bot Framework attachmentInfo JSON response reads * test(msteams): prove attachmentInfo stream cancellation
…penclaw#99125) * fix(msteams): bound Bot Framework attachmentInfo JSON response reads * test(msteams): prove attachmentInfo stream cancellation
What Problem This Solves
Bot Framework personal-chat attachment downloads call
/v3/attachments/{id}and previously parsed the metadata with unboundedresponse.json(). A hostile or misbehaving endpoint could stream an arbitrarily large JSON body and OOM the gateway process before the attachment view download even starts.Related open bounded-read work covers MS Teams Graph collection (#98833), Graph upload (#97784), and SSO (#97781), but not the Bot Framework
attachmentInfopath inbot-framework.ts.Note: Inworld TTS/voices bounded reads are already on
main(#95416, #98660), so this PR targets the remaining MS Teams gap instead.Why This Change Was Made
Route the Bot Framework attachment metadata success path through the shared
readProviderJsonResponsehelper (16 MiB cap, stream cancel on overflow), matching sibling MS Teams Graph/OAuth bounded JSON reads.The 16 MiB fail-closed cap is intentional: successful Bot Framework metadata responses larger than the shared provider JSON cap now fail as invalid attachment metadata instead of being buffered without a limit. That can reject unusual oversized metadata, but keeps the gateway from accepting unbounded JSON on this shipped attachment path.
User Impact
No config or API changes. Personal DM / Bot Framework attachment downloads fail closed with a logged warning when attachment metadata JSON exceeds the cap, instead of buffering the full body.
Evidence
Maintainer verification
Exact head
660df2c24db7abd5d4fb541eb5f9f90f302eed6dwas tested in a fresh,sanitized direct AWS Crabbox with public networking, no Tailscale, no instance
profile, isolated HOME, and the trusted untrusted-PR bootstrap.
run_d895c9a9e528: 21/21 Bot Framework attachment tests passed.run_1f4883b97ce5: normal metadata and view each completed once; oversized metadata was rejected, the server stream closed after 20 one-MiB writes, and the exact 16 MiB warning was emitted.28811868628: success.Contributor verification
Branch
fix/msteams-bound-bot-framework-attachmentinfo-json-reads.Result: 21/21 tests passed. The oversized regression test now returns a fresh streaming
Response, assertsresponse.json()is not used, verifies the bounded reader stops before the 64 MiB test ceiling, and asserts the original stream was canceled.Result: all matched files use the correct format.
Loopback Bot Framework-style proof:
The proof script started a local HTTP server with Bot Framework-style routes, invoked
downloadMSTeamsBotFrameworkAttachmentthrough the production MS Teams attachment path, mapped the Bot Framework URL to the loopback server via the injected fetch implementation, and exercised both normal metadata and oversized metadata responses.Output:
{ "ok": true, "normalMetadataHits": 1, "normalViewHits": 1, "oversizedRejected": true, "oversizedMetadataHits": 1, "oversizedChunksWritten": 19, "oversizedClosed": true, "warning": { "message": "msteams botFramework attachmentInfo parse failed", "meta": { "error": "msteams botFramework attachmentInfo: JSON response exceeds 16777216 bytes" } } }Changed files:
extensions/msteams/src/attachments/bot-framework.ts—readProviderJsonResponsefor attachmentInfoextensions/msteams/src/attachments/bot-framework.test.ts— bounded-read regression test with fresh streaming response cancellation proofFix, regression, and original loopback proof by @ly85206559; final exact-head
AWS/CI verification by @steipete.