[PR #8839] fix(email-and-password): apply enumeration protection when autoSignIn is false #16492

Open
opened 2026-04-13 10:32:30 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8839

State: open
Merged: No


What does this PR do?

Fixes email enumeration protection not being applied when autoSignIn
is set to false and requireEmailVerification is not set.

Why?

The documentation states that email enumeration protection is enabled
when either requireEmailVerification: true OR autoSignIn: false is
set. However the code only checked requireEmailVerification, ignoring
autoSignIn.

This caused the endpoint to return a 422 instead of a synthetic 200
response when a duplicate email was used — leaking whether an email
is registered.

Changes

  • Updated shouldReturnGenericDuplicateResponse in sign-up.ts to
    also check autoSignIn === false

Fixes #8832


Summary by cubic

Apply email enumeration protection when emailAndPassword.autoSignIn is false. Duplicate email sign-ups now return a synthetic user (token: null) and still trigger onExistingUserSignUp, even without requireEmailVerification—preventing email leakage and aligning with the docs.

Written for commit b957d5a715. Summary will update on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8839 **State:** open **Merged:** No --- ## What does this PR do? Fixes email enumeration protection not being applied when `autoSignIn` is set to `false` and `requireEmailVerification` is not set. ## Why? The documentation states that email enumeration protection is enabled when either `requireEmailVerification: true` OR `autoSignIn: false` is set. However the code only checked `requireEmailVerification`, ignoring `autoSignIn`. This caused the endpoint to return a 422 instead of a synthetic 200 response when a duplicate email was used — leaking whether an email is registered. ## Changes - Updated `shouldReturnGenericDuplicateResponse` in `sign-up.ts` to also check `autoSignIn === false` ## Related Issue Fixes #8832 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Apply email enumeration protection when `emailAndPassword.autoSignIn` is false. Duplicate email sign-ups now return a synthetic user (`token: null`) and still trigger `onExistingUserSignUp`, even without `requireEmailVerification`—preventing email leakage and aligning with the docs. <sup>Written for commit b957d5a715c1fe98b03ffb542ff98f0e605c070e. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 10:32:31 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16492