R21.1: bind the browser_completion attempt handle to the private plane
The public /v1/oauth/:provider/start route read handoff.attemptId straight out of the request body and folded it into the signed state token unconditionally. Since the private command plane's beginAuth mints an attempt handle server-side and later redeems by that handle (consumeAuthCompletionByAttempt), anyone who learned a pending handle could carry it through their own OAuth flow and bind their own identity to it -- the app's completeAuth(H) would then authenticate the victim's session as the attacker. Same family as the takeover chain closed in the prior pass: a caller-chosen identifier trusted as authority. normalizeOAuthHandoff now always strips attemptId from a browser_completion handoff; a public caller has no attempt to correlate and gets its completion code directly. The only path an attempt handle can reach the state token is startOAuthFlow's new trustedBrowserAttemptId option, which is a TypeScript function argument set by beginAuth from the handle it just minted -- never a value parsed out of a request body. Also adds the uniqueness constraint the by-attempt redemption needed: a partial unique index on (app_slug, attempt_id) WHERE attempt_id IS NOT NULL AND consumed_at IS NULL, mirrored in InMemoryStore. Without it, consumeAuthCompletionByAttempt's UPDATE could match more than one row and silently discard all but the one it returned. Flips Soul's attempt-handle-binding it.fails to a passing it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
9ebf38bead
commit
ea804ddbbe
5 changed files with 74 additions and 25 deletions
|
|
@ -277,13 +277,19 @@ async function beginAuth(
|
|||
});
|
||||
// Same authority, same non-HTTP entry as refreshAuth above.
|
||||
const context = getHeimdallRuntimeContext(app);
|
||||
const start = await startOAuthFlow({ config: context.config, keys: context.keys, store: context.store }, provider, callerFromOpenedEnvelope(appSlug), {
|
||||
appSlug,
|
||||
mode,
|
||||
returnTo,
|
||||
handoff: { kind: "browser_completion", attemptId: attempt.handle },
|
||||
...(entitlementPolicy ? { entitlementPolicy } : {}),
|
||||
});
|
||||
const start = await startOAuthFlow(
|
||||
{ config: context.config, keys: context.keys, store: context.store },
|
||||
provider,
|
||||
callerFromOpenedEnvelope(appSlug),
|
||||
{
|
||||
appSlug,
|
||||
mode,
|
||||
returnTo,
|
||||
handoff: { kind: "browser_completion" },
|
||||
...(entitlementPolicy ? { entitlementPolicy } : {}),
|
||||
},
|
||||
{ trustedBrowserAttemptId: attempt.handle }
|
||||
);
|
||||
const startPayload = start.body as Record<string, unknown>;
|
||||
if (start.statusCode !== 201) {
|
||||
await context.store.updateAuthAttempt(appSlug, attempt.handle, {
|
||||
|
|
|
|||
Loading…
Reference in a new issue