You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Firebase Blocking Auth functions beforeUserCreated and beforeUserSignedIn fire incorrectly when the a user that already exists in Firebase Auth attempts to register.
import{initializeApp}from"firebase/app";import{createUserWithEmailAndPassword}from'firebase/auth'import{getAuth}from'firebase/auth'constfirebaseConfig={apiKey: "xxx",authDomain: "xxx.firebaseapp.com",projectId: "xxx",storageBucket: "xxx.appspot.com",messagingSenderId: "xxx",appId: "xxx"};// Initialize Firebaseconstapp=initializeApp(firebaseConfig);constauth=getAuth(app)consttestEmail=`[email protected]`constuserCredential=awaitcreateUserWithEmailAndPassword(auth,testEmail,'testPassword')console.log(`ℹ️ Created test user ${userCredential.user.uid} with email ${testEmail}`)
When registerUser.js is called multiple times, the beforeSignedIn and beforeUserCreated functions will fire. After the first time for the correct user creation, they will STILL FIRE, and provide random / nonexistent uid's.
This means any code that makes the assumption that these functions will only fire on authenticated sign-ins or post user-creation can potentially be exploited.
[REQUIRED] Steps to reproduce
Deploy functions
Run script multiple times, observe Firebase: Error (auth/email-already-in-use).
Check logs
[REQUIRED] Expected behavior
I'd expect the functions fire as described in the documentation:
Before the user is created: Triggers before a new user is saved to the Firebase Authentication database, and before a token is returned to your client app.
Before the user is signed in: Triggers after a user's credentials are verified, but before Firebase Authentication returns an ID token to your client app. If your app uses multi-factor authentication, the function triggers after the user verifies their second factor. Note that creating a new user also triggers both these events.
[REQUIRED] Actual behavior
Blocking functions fire despite the error Firebase: Error (auth/email-already-in-use).
The text was updated successfully, but these errors were encountered:
I reported this to Google Support, Firebase Support and our Account Management In Feb 2024. The issue was passed on to a product team and we didn't hear back.
[REQUIRED] Version info
node: n/a
firebase-functions: n/a
firebase-tools: n/a
firebase-admin: n/a
[REQUIRED] Test case
Firebase Blocking Auth functions
beforeUserCreated
andbeforeUserSignedIn
fire incorrectly when the a user that already exists in Firebase Auth attempts to register.Function:
registerUser.js:
When
registerUser.js
is called multiple times, thebeforeSignedIn
andbeforeUserCreated
functions will fire. After the first time for the correct user creation, they will STILL FIRE, and provide random / nonexistent uid's.This means any code that makes the assumption that these functions will only fire on authenticated sign-ins or post user-creation can potentially be exploited.
[REQUIRED] Steps to reproduce
Firebase: Error (auth/email-already-in-use).
[REQUIRED] Expected behavior
I'd expect the functions fire as described in the documentation:
Before the user is created: Triggers before a new user is saved to the Firebase Authentication database, and before a token is returned to your client app.
Before the user is signed in: Triggers after a user's credentials are verified, but before Firebase Authentication returns an ID token to your client app. If your app uses multi-factor authentication, the function triggers after the user verifies their second factor. Note that creating a new user also triggers both these events.
[REQUIRED] Actual behavior
Blocking functions fire despite the error
Firebase: Error (auth/email-already-in-use).
The text was updated successfully, but these errors were encountered: