fix(msteams): bound Bot Framework User Token JSON response read#101110
fix(msteams): bound Bot Framework User Token JSON response read#101110cxbAsDev wants to merge 1 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 branch fixes the same Microsoft Teams SSO User Token JSON read as the earlier canonical open PR, while the canonical PR covers the production registered SSO routes and has stronger proof. 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 duplicate and continue review on #97781, which carries the same bounded-read hardening plus production-route and sovereign-cloud coverage. So I’m closing this here and keeping the remaining discussion on #97781. Review detailsBest possible solution: Close this duplicate and continue review on #97781, which carries the same bounded-read hardening plus production-route and sovereign-cloud coverage. Do we have a high-confidence way to reproduce the issue? Yes by source inspection. Current main uses bare Is this the best way to solve the issue? No for this branch as the landing path. The bounded-read direction is useful, but the earlier canonical PR is the better solution because it fixes the same helper and the production registered SSO route boundary with stronger tests. Security review: Security review cleared: The diff narrows an external SSO response-read boundary and adds a local proof script; it does not add dependencies, workflows, permissions, or secret-handling changes. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 565097fc1001. |
|
🦞✅ Reason: structured ClawSweeper close marker: close-required (sha=0dcb0c4e52ed3e4a52f2b123bc501fd581171ec5) Closed:
|
What Problem This Solves
callUserTokenServicein the MSTeams SSO handler calledresponse.json()directly on the Bot Framework User Token service response. An oversized or malicious JSON body could be buffered without limit, leading to OOM during token exchange.Why This Change Was Made
Replace the bare
response.json()withreadProviderJsonResponsecapped at 64 KiB. The existing catch path already returns{ error: "invalid JSON from User Token service", status: response.status }, so the handler now treats an oversized body as an invalid response instead of crashing.User Impact
Teams SSO token exchanges are resilient to unexpectedly large User Token service responses.
Evidence
extensions/msteams/src/monitor-handler.sso.test.tsasserting the handler returns anunexpected_responseerror when the JSON body exceeds the cap.scripts/proof/msteams-sso-json-bound.mtsthat serves an oversized User Token JSON response from a local HTTP server and verifies the handler rejects cleanly.pnpm test extensions/msteams/src/monitor-handler.sso.test.tspassedOPENCLAW_OXLINT_SKIP_PREPARE=1 node scripts/run-oxlint.mjs extensions/msteams/src/sso.ts extensions/msteams/src/monitor-handler.sso.test.ts scripts/proof/msteams-sso-json-bound.mtspassednode --import tsx scripts/proof/msteams-sso-json-bound.mts: