[PR #7376] [CLOSED] feat: prevent enumeration vulnerabilities #7270

Closed
opened 2026-03-13 13:30:16 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7376
Author: @himself65
Created: 1/15/2026
Status: Closed

Base: canaryHead: himself65/2026/01/14/enum


📝 Commits (7)

📊 Changes

11 files changed (+667 additions, -10 deletions)

View changed files

packages/better-auth/src/api/enumeration-protection.test.ts (+318 -0)
📝 packages/better-auth/src/api/middlewares/index.ts (+1 -0)
📝 packages/better-auth/src/api/routes/sign-up.ts (+7 -1)
📝 packages/better-auth/src/api/to-auth-endpoints.ts (+17 -0)
📝 packages/better-auth/src/plugins/phone-number/routes.ts (+4 -1)
📝 packages/better-auth/src/plugins/username/index.ts (+8 -7)
📝 packages/core/src/api/index.ts (+2 -1)
packages/core/src/context/enumeration.test.ts (+199 -0)
packages/core/src/context/enumeration.ts (+87 -0)
📝 packages/core/src/context/index.ts (+5 -0)
📝 packages/core/src/types/init-options.ts (+19 -0)

📄 Description

Upstream: #2954, #884


Summary by cubic

Prevents user enumeration in auth flows by returning generic responses and normalizing timing, so attackers can’t infer account existence.

  • New Features
    • Added helper to set a safe response with optional timing work (e.g., password hashing).
    • Endpoints now return a 200 with the safe payload when an error would reveal user existence.
    • Applied to email sign-up, phone number sign-in, and username sign-in.
    • New config: advanced.security.preventEnumeration (enabled in production, disabled in development).

Written for commit faa9fd452f. 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/7376 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/15/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `himself65/2026/01/14/enum` --- ### 📝 Commits (7) - [`c6d9e21`](https://github.com/better-auth/better-auth/commit/c6d9e21ea01141d484eca349f999e0dc15cee522) fix: user enum - [`3ac0e41`](https://github.com/better-auth/better-auth/commit/3ac0e414f18a23dbf76c30f9114e3ef7d4765f61) simplify - [`aba7cb9`](https://github.com/better-auth/better-auth/commit/aba7cb9720e246714355ed5193a5eb028f5964c3) move file - [`0e88581`](https://github.com/better-auth/better-auth/commit/0e88581f2b2aab6fd6e11765b1e57fefe4998b90) fix: is dev - [`48a85b3`](https://github.com/better-auth/better-auth/commit/48a85b39de4a30918e2b775743dff89fe662f637) fix: code - [`ae12d6f`](https://github.com/better-auth/better-auth/commit/ae12d6f548d6ac8d02617b48f468a7bf4794957e) test: improve - [`faa9fd4`](https://github.com/better-auth/better-auth/commit/faa9fd452f6139f7ddd98c7a4ab38ddf05d3d285) refactor: remove unused AuthEndpointOptions and AuthEndpointContext types ### 📊 Changes **11 files changed** (+667 additions, -10 deletions) <details> <summary>View changed files</summary> ➕ `packages/better-auth/src/api/enumeration-protection.test.ts` (+318 -0) 📝 `packages/better-auth/src/api/middlewares/index.ts` (+1 -0) 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+7 -1) 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+17 -0) 📝 `packages/better-auth/src/plugins/phone-number/routes.ts` (+4 -1) 📝 `packages/better-auth/src/plugins/username/index.ts` (+8 -7) 📝 `packages/core/src/api/index.ts` (+2 -1) ➕ `packages/core/src/context/enumeration.test.ts` (+199 -0) ➕ `packages/core/src/context/enumeration.ts` (+87 -0) 📝 `packages/core/src/context/index.ts` (+5 -0) 📝 `packages/core/src/types/init-options.ts` (+19 -0) </details> ### 📄 Description Upstream: #2954, #884 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prevents user enumeration in auth flows by returning generic responses and normalizing timing, so attackers can’t infer account existence. - **New Features** - Added helper to set a safe response with optional timing work (e.g., password hashing). - Endpoints now return a 200 with the safe payload when an error would reveal user existence. - Applied to email sign-up, phone number sign-in, and username sign-in. - New config: advanced.security.preventEnumeration (enabled in production, disabled in development). <sup>Written for commit faa9fd452f6139f7ddd98c7a4ab38ddf05d3d285. 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-03-13 13:30:16 -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#7270