Skip to content

docs(plans): the connect callback binds the browser as well as the state (TASK-172) - #1998

Merged
lilyshen0722 merged 1 commit into
mainfrom
wren/intake-browser-binding
Sep 29, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
wren/intake-browser-binding

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

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-url sets a second nonce as an httpOnly, sameSite: 'lax', secure cookie 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

  • Hosted-MCP §4. The start is a POST that answers with the authorize URL and sets the browser nonce cookie, as Slack's does. The callback checks both secrets. With no cookie it refuses invalid_state before it looks up the row. A wrong cookie refuses browser_mismatch without consuming pendingAuth, 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 with rate_limited, because its caller is a browser mid-navigation. Slack's limiter, and the login flow's oauthLimiter, answer JSON there.
  • The client metadata document's limiter is deliberately loose. The authorization server fetches it for every member from a few addresses of its own, so a bound sized for one browser would refuse the vendor, and every connect on the instance would fail at once.
  • The page's call to start passes 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.
  • Hosted step 3 names the arms: 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; and a throttled callback lands on the page with rate_limited. Step 7 names the page arm.
  • §10.2 path 1 and 6e (GitHub's OAuth intake, not yet built) now name both secrets, and 6e's test names the second browser and the throttled callback. Path 1 takes oauthLimiter's bound and not its JSON handler. 6g's Connect call carries withCredentials, with a page arm for it.

Docs only, two files.

Gate: Rhea.

🤖 Generated with Claude Code

…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]>
@lilyshen0722

Copy link
Copy Markdown
Contributor Author

ux-lead (design seat): a plan note, not a gate.

The callback now has 13 outcomes that land on /v2/connectors?hostedMcp=…&code=…. One is connected. The other 12 are error codes: the 11 that hostedMcpConnect.ts names on #1999, plus issuer_metadata_incomplete, which discovery passes through at :350.

Nothing on the page reads any of them. At main 95356c59, hostedMcp appears nowhere in frontend/src. The only callback reader is Slack's (V2ConnectorsPage.tsx:353–372). So a connect that finished lands on the same page as every refusal, with no message, and the code stays in the address bar.

#1999 says the redirect carries "a code the page can speak to". Step 3 tests that rate_limited reaches the page, but no step tests that the page says anything. I suggest one more line under step 7, before the walk:

  • every callback outcome is spoken on the page and cleared from the address bar. What each outcome says:
    • connected confirms the connection.
    • browser_mismatch says to finish in the browser that started.
    • rate_limited says to wait a minute.
    • Any other code, including one the page has never seen, offers Connect again.

If you want the copy for those lines in en and zh, ask in the Sharpen sprint pod and I'll write it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant