[GH-ISSUE #2803] [BUG] It should return USER_NOT_FOUND instead of success when there's no such user #9356

Closed
opened 2026-04-13 04:47:40 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @dsonet on GitHub (May 27, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2803

25b7f4f2d6/packages/better-auth/src/plugins/email-otp/index.ts (L133-L141)

In this case, it should return:

throw new APIError("BAD_REQUEST", {
  message: ERROR_CODES.USER_NOT_FOUND,
});
Originally created by @dsonet on GitHub (May 27, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2803 https://github.com/better-auth/better-auth/blob/25b7f4f2d6aeaa5f83be5b3b9e86b665ec06da28/packages/better-auth/src/plugins/email-otp/index.ts#L133-L141 In this case, it should return: ```javascript throw new APIError("BAD_REQUEST", { message: ERROR_CODES.USER_NOT_FOUND, }); ```
GiteaMirror added the locked label 2026-04-13 04:47:40 -05:00
Author
Owner

@dsonet commented on GitHub (May 27, 2025):

PR is here: https://github.com/better-auth/better-auth/pull/2804

<!-- gh-comment-id:2913257929 --> @dsonet commented on GitHub (May 27, 2025): PR is here: https://github.com/better-auth/better-auth/pull/2804
Author
Owner

@Kinfe123 commented on GitHub (May 27, 2025):

This behavior is intentional and implemented for security reasons. Specifically, it is designed this way to mitigate potential risks of attack during the "Forgot Password" flow. This is a common security pattern to prevent user enumeration attacks.

<!-- gh-comment-id:2914355533 --> @Kinfe123 commented on GitHub (May 27, 2025): This behavior is intentional and implemented for security reasons. Specifically, it is designed this way to mitigate potential risks of attack during the "Forgot Password" flow. This is a common security pattern to prevent user enumeration attacks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9356