Skip to content

fix(auth): close register-duplicate session cookie leak, scope sign-in-code issuance per client (#548) - #641

Merged
jimhoyd merged 1 commit into
mainfrom
claude/auth-register-enumeration-548
Sep 24, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/auth-register-enumeration-548

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes parts (a) and (c) of #548 (part (b) already landed in #604).

  • (a) /register for an already-registered email returned the same
    generic 201 {user, csrf, ...} shape as a genuine registration, but also
    set a session cookie built from a token that was never persisted
    server-side (packages/auth/src/auth-core.ts's create). The cookie
    looked 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
    /register contract is updated to match.

  • (c) Per-email sign-in code issuance (issueEmailCode in
    auth-core.ts) had a 20/day cap with no scope on the calling client, so
    any 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 HTTP
    test 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's
    per-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)
  • Full packages/auth suite (npm run verify --workspace @jimhoyd/urlcode-auth): 220/220 pass
  • npm run typecheck (repo root)
  • npm run verify (repo root, full workspace chain): exit 0

Closes #548

🤖 Generated with Claude Code

…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]>
@jimhoyd
jimhoyd merged commit 060c7ef into main Sep 24, 2026
16 checks passed
@jimhoyd
jimhoyd deleted the claude/auth-register-enumeration-548 branch September 24, 2026 03:45
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.

[Bug]: auth registration still reveals whether an email has an account

1 participant