Repository navigation
docs(plans): the connect callback binds the browser as well as the state (TASK-172) - #1998
Conversation
…ate (TASK-172) The hosted-MCP scope said the callback's state "is its only binding", and slice 3a was built to that sentence. The state rides in a URL the starter holds and can hand to someone else. If that person approves, their tokens land on the starter's row (Vera, pod 75250). The Slack connect flow already closes this with a second nonce that the start sets as an httpOnly cookie and the callback compares in constant time. - hosted-MCP §4: the start is a POST that answers with the authorize URL and sets the browser nonce cookie. The callback checks both secrets. With no cookie it refuses invalid_state before the row lookup, and a wrong cookie refuses browser_mismatch without consuming pendingAuth. The callback is rate-limited by address, as Slack's is, but a throttled callback still redirects to the page with rate_limited, because its caller is a browser mid-navigation. Slack's limiter answers JSON there (Vera, pod 75269). - The client metadata document has a rate limiter too, as the route guard requires of every route, and a deliberately loose one. The AS fetches it for every member from a few addresses of its own, so a bound sized for one browser would refuse the vendor and fail every connect at once (Vera, pod 75265). - The page's call to start passes withCredentials. The API is on another origin, so without it the browser drops the cookie and every callback refuses. A backend test cannot see that. The page's test asserts the flag, as the Slack arms do, and the deployed walk shows a real browser keeps it. - Step 3 names the arms: a valid state from a browser that did not start the flow refuses, and the flow stays pending, including on a row that stores no nonce; and a throttled callback lands on the page. Step 7 names the page arm. - §10.2 path 1 and 6e described the Slack shape as a nonce bound to the caller's user id. They now name both secrets, and 6e's test names the second browser. 6g's Connect call carries withCredentials, with a page arm for it (Vera, pod 75258). Path 1 takes oauthLimiter's bound and not its handler, which answers JSON, and 6e's test names the throttled callback. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
ux-lead (design seat): a plan note, not a gate. The callback now has 13 outcomes that land on Nothing on the page reads any of them. At main #1999 says the redirect carries "a code the page can speak to". Step 3 tests that
If you want the copy for those lines in en and zh, ask in the Sharpen sprint pod and I'll write it. |
What this corrects
The hosted-MCP scope said the connect callback's state "is its only binding". Slice 3a (#1995) was built to that sentence, and its review found the hole.
The state rides in a URL that the starter holds and can hand to someone else. If that person approves at the vendor, the vendor sends their browser back with their own code and the starter's state. Their tokens then land on the starter's row, and the starter can grant that Connection to rooms. PKCE does not stop this, because it binds the code to this instance, and neither does
iss, because the authorization server is the right one.The Slack connect flow on main already closes it.
POST /api/installables/slack/authorize-urlsets a second nonce as anhttpOnly,sameSite: 'lax',securecookie scoped to the callback's path. The callback refuses when the cookie is absent and compares it to the row in constant time (matchesSlackNonce). In the second person's browser there is no cookie. The plan pointed at that shape but described it as "a state nonce bound to the caller's user id", which is the half that does not help.#1995 now builds the binding in this shape, and this PR names its refusal codes. It also names a rate limit on both unauthenticated routes, which the repo's route guard requires of every route, and says a throttled callback still redirects to the page, which #1995 does not do yet.
Changes
POSTthat answers with the authorize URL and sets the browser nonce cookie, as Slack's does. The callback checks both secrets. With no cookie it refusesinvalid_statebefore it looks up the row. A wrong cookie refusesbrowser_mismatchwithout consumingpendingAuth, so a wrong browser cannot burn a real flow. The callback is rate-limited by address, as Slack's is, but a throttled callback still redirects to the page withrate_limited, because its caller is a browser mid-navigation. Slack's limiter, and the login flow'soauthLimiter, answer JSON there.withCredentials: true, as Slack's does (V2ConnectorsPage.tsx:588). The API is on another origin from the app, so without it the browser drops the cookie and every callback refuses. A backend test sets the cookie itself and cannot see this. A page arm asserts the flag, as the Slack arms do, and the deployed walk shows that a real browser keeps the cookie: hosted step 7, and 6g for GitHub.the callback refuses a valid state from a browser that did not start the flow, and the flow stays pending, run with no cookie, with another flow's cookie, and on a row that stores no nonce; anda throttled callback lands on the page with rate_limited. Step 7 names the page arm.oauthLimiter's bound and not its JSON handler. 6g's Connect call carrieswithCredentials, with a page arm for it.Docs only, two files.
Gate: Rhea.
🤖 Generated with Claude Code