Repository navigation
fix: refuse anything but a JSON body on /connect and its preview - #6
Merged
Merged
Conversation
The README says requiring `application/json` is what stops a form on
another site from redeeming a link as whoever is signed in, but the
handlers parsed whatever arrived. A `text/plain` form can send
`{"token":"…","x":"="}`, which parses as JSON, so a cross-site form
carrying the visitor's cookies redeemed the attacker's own token as
them, without the preview ever being shown.
- Both handlers answer 415 to any other Content-Type, before reading the
session or calling Agenta. A charset parameter is fine
- AGENTS.md makes it a rule for handlers written in a framework's own
style, which do not get the check from these ones
- README says the header is what has to be checked, not the body
Reported by Codex.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013TYQ7D3Pk6WDSYuhCUvtGN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The README says requiring
application/jsonis what stops a form on another site from redeeming a link as whoever is signed in. ButhandleConnectRequestandhandlePreviewRequestparsed whatever arrived. A<form enctype="text/plain">can send a body that parses as JSON:That posts
{"token":"ATTACKER_TOKEN","x":"="}. Whenever the visitor's session cookie went along,mainanswered 200 and redeemed the attacker's own Connect link as the signed-in customer, without the page or its preview ever being shown. A cookie with noSameSiteattribute gets Chrome's two-minute Lax-by-default grace period on a POST, and a cookie setSameSite=Nonealways goes. From then on, the attacker's Slack or Teams messages run as that customer.Content-Type, before reading the session or calling Agenta.application/json; charset=utf-8is fine.text/plainby default.Agenta's own
/connect/linkalready does this (isJson, 415).Reported by Codex.
Checks
main, Codex's request reproduces:text/plainwith{"token":"attacker-token","x":"="}gives 200, and Agenta receives{"linkToken":"attacker-token","customerId":"victim-customer"}. With this change it gets 415 and Agenta is never called.text/plain, urlencoded and multipart on both handlers, checking 415, no session lookup and no Agenta call. They all fail onmain. A seventh accepts JSON with a charset.bun run check,bun run typecheckandbun testpass (26). Merged with fix: hold Connect until the preview answers, and stop calling every refusal expired #5 they still pass (43), and the two branches don't conflict.Generated by Claude Code