-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
FirebaseUI Bug Report: Email enumeration fails for existing users in Next.js App Router
Summary
FirebaseUI's email sign-in flow incorrectly directs existing users to the "Create Account" panel. The internal mechanism for checking if a user exists appears to fail, even when the Firebase project is configured correctly and the user is confirmed to exist.
Environment
- firebase:
^10.12.2
- firebaseui:
^6.1.0
- next:
^15.5.4
- react:
^19.0.0
- Framework: Next.js (App Router)
- **Deployment Environment: localhost
Steps to Reproduce
- Set up a new Next.js project using the App Router.
- Configure Firebase and FirebaseUI for email authentication using the
redirect
flow. - Ensure there is an existing user in the Firebase Authentication database.
- Use the FirebaseUI widget to attempt to sign in with the existing user's email address.
Expected Behavior
After entering a valid, existing email address, FirebaseUI should recognize the user and present the password entry screen.
Actual Behavior
After entering a valid, existing email address, FirebaseUI proceeds to the "Create Account" screen, as if the user does not exist.
Debugging Steps Taken
This issue was subject to an extensive debugging session. Here are the key findings:
-
Configuration Verified: The
firebaseConfig
object used to initialize the Firebase app was verified to be correct. TheprojectId
and other credentials were confirmed to match the target Firebase project. The API key was confirmed to be working for other Firebase services like Firestore and for creating new user accounts through the UI. -
User Status Verified: The user account was confirmed to be enabled in the Firebase Authentication console.
-
fetchSignInMethodsForEmail
Fails: Using the (now deprecated)fetchSignInMethodsForEmail
function for the existing user's email consistently returned an empty array ([]
). This is the likely root cause of the UI's behavior. -
signInWithEmailAndPassword
with dummy password Fails as expected: UsingsignInWithEmailAndPassword
with a dummy password resulted in anauth/invalid-credential
error, which is the expected behavior in recent SDK versions and doesn't allow to distinguish between user not found and wrong password. -
signInWithEmailAndPassword
with real password SUCCEEDS: This is the key finding. WhensignInWithEmailAndPassword
was called directly with the correct email and password for the user, it succeeded, and a valid token was returned.
Conclusion
The fact that signInWithEmailAndPassword
succeeds proves that the Firebase project configuration, API keys, and connection to the Firebase backend are all working correctly.
The issue appears to be a bug within the FirebaseUI library's specific logic for checking for the existence of an email address before presenting the password prompt. This logic seems to be failing where the core Firebase Auth SDK succeeds.
As a workaround, we have implemented a custom login UI using the core Firebase Auth SDK, which works perfectly.