fix(security): chat attachment XSS, MCP OAuth SSRF guards, Teams clientState verification#4877
Conversation
…caping Replace document.write with an escaped blob URL preview: HTML-entity encode the user-controlled filename and data URL, open with noopener,noreferrer, and revoke the blob URL after navigation.
Route discoverOAuthServerInfo and the RFC 7009 revocation POST through an SSRF-guarded fetch that validates every request URL via validateMcpServerSsrf (blocking private/reserved/loopback targets, honoring ALLOWED_MCP_DOMAINS and self-hosted localhost rules) and pins the connection to the resolved IP to prevent DNS-rebinding TOCTOU. Previously these fetches used unvalidated global fetch against URLs taken verbatim from attacker-controllable authorization-server metadata.
…tifications The microsoftteams_chat_subscription trigger set clientState=webhook.id when creating the Graph subscription but never validated it on inbound change notifications, so any request to the webhook path with a crafted notification body was treated as authentic (CWE-345). verifyAuth now requires every notification in the value array to carry a clientState matching the stored webhook id (constant-time compare) and rejects payloads without notifications. Validation handshakes (validationToken) are handled before auth and remain unaffected; outgoing-webhook HMAC auth is unchanged.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview Chat: Image attachment previews no longer use MCP OAuth: New Teams: For Reviewed by Cursor Bugbot for commit 617073c. Configure here. |
… unavailable Hardens the clientState check so a missing webhook id (theoretically unreachable, since the row is looked up by primary key) can never collapse the expected value to an empty string that a forged clientState could match.
Greptile SummaryThis PR fixes three distinct security issues: XSS in chat attachment preview via
Confidence Score: 5/5All three security fixes are correctly implemented and safe to merge. The XSS fix properly escapes both the filename and data URL before interpolation and uses a blob URL to avoid document.write. The SSRF guard validates every outbound URL independently per request, covering both OAuth discovery hops and the revocation endpoint. The Teams clientState check is timing-safe, fails closed on missing webhook.id, and has thorough test coverage across edge cases. No regressions or new attack surfaces introduced. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "improvement(chat): hoist HTML escape map..." | Re-trigger Greptile |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 617073c. Configure here.
Summary
Type of Change
Testing
Tested manually
Checklist