Repository navigation
fix(auth): close register-duplicate session cookie leak, scope sign-in-code issuance per client (#548) - #641
Merged
Conversation
…on; scope sign-in-code issuance per client (#548) (a) A duplicate /register returned the same generic 201 body as a genuine registration, but also set a session cookie built from a token that was never persisted server-side. The cookie looked valid while authenticating nothing, so a caller could still tell new-signup from existing-email by attempting an authenticated request with it. Duplicate registration now keeps the same status/body but omits the session cookie entirely, clearing only the anonymous flow cookie like the genuine path already does. (c) Per-email sign-in code issuance had a 20/day cap with no scope on the caller, so a single client could alone exhaust — or, since a fresh code invalidates whichever one is in flight, alone keep cancelling — another account's codes. A trusted client now also gets its own tighter per-email daily budget, alongside the existing per-email cap, mirroring the client-scoped budget already used for password guesses (#547). Part (b) of #548 (the waitlist duplicate-notice timing signal) already landed in #604. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
Fixes parts (a) and (c) of #548 (part (b) already landed in #604).
(a)
/registerfor an already-registered email returned the samegeneric
201 {user, csrf, ...}shape as a genuine registration, but alsoset a session cookie built from a token that was never persisted
server-side (
packages/auth/src/auth-core.ts'screate). The cookielooked well-formed while authenticating nothing, so a follow-up
authenticated request with it distinguished a genuine signup from a
duplicate. Duplicate registration now keeps the exact same status and JSON
body, but no longer sets a session cookie — only the anonymous flow cookie
is cleared, same as the genuine path.
packages/auth/docs/JSON-API.md's/registercontract is updated to match.(c) Per-email sign-in code issuance (
issueEmailCodeinauth-core.ts) had a 20/day cap with no scope on the calling client, soany caller could alone exhaust that budget against a target email or —
since a fresh code invalidates whichever one is still in flight — alone
keep cancelling that account's pending codes. A trusted client now also
gets its own, tighter per-email daily budget, alongside the existing
per-email cap, mirroring the client-scoped budget already used for
password-guess attempts ([Bug]: per-client rate limits key full IPv6 addresses, so one /64 gets unlimited budgets #547).
Regression tests added for both:
packages/auth/test/auth-http.test.ts: the existing no-enumeration HTTPtest now also asserts the genuine registration sets a session cookie and
the duplicate does not, plus an isolated-cookie-jar follow-up confirming
there is nothing left to authenticate with.
packages/auth/test/auth-core.test.ts: a new test exhausts one client'sper-email code-issuance budget and confirms a different client's budget
for the same address is unaffected, and that an untrusted/absent client
still falls back to the pre-existing per-email budget alone.
No exploit-level detail (patterns, payload sizes, timings) is included here
per SECURITY.md.
Test plan
node --conditions=development --test packages/auth/test/auth-http.test.ts(13/13 pass)node --conditions=development --test packages/auth/test/auth-core.test.ts(69/69 pass)packages/authsuite (npm run verify --workspace @jimhoyd/urlcode-auth): 220/220 passnpm run typecheck(repo root)npm run verify(repo root, full workspace chain): exit 0Closes #548
🤖 Generated with Claude Code