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

Open
opened 2026-04-15 22:44:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8839
Author: @dipan-ck
Created: 3/30/2026
Status: 🔄 Open

Base: mainHead: fix/email-enumeration-autosignin-protection


📝 Commits (2)

  • 6a1fcec fix(email-and-password): apply enumeration protection when autoSignIn is false
  • b957d5a fix(email-and-password): apply enumeration protection when autoSignIn is false

📊 Changes

2 files changed (+12 additions, -8 deletions)

View changed files

📝 packages/better-auth/src/api/routes/sign-up.test.ts (+10 -7)
📝 packages/better-auth/src/api/routes/sign-up.ts (+2 -1)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8839 **Author:** [@dipan-ck](https://github.com/dipan-ck) **Created:** 3/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/email-enumeration-autosignin-protection` --- ### 📝 Commits (2) - [`6a1fcec`](https://github.com/better-auth/better-auth/commit/6a1fcece37e39053ee2c5cc3db57211f37316f8a) fix(email-and-password): apply enumeration protection when autoSignIn is false - [`b957d5a`](https://github.com/better-auth/better-auth/commit/b957d5a715c1fe98b03ffb542ff98f0e605c070e) fix(email-and-password): apply enumeration protection when autoSignIn is false ### 📊 Changes **2 files changed** (+12 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/sign-up.test.ts` (+10 -7) 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+2 -1) </details> ### 📄 Description ## 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. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:44:25 -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#25146