high · M3 · MASVS-AUTH-1 · PTKD-BACKEND-FIREBASE-EMAIL-UNVERIFIED
Firebase rules trust an email address nobody verified
A Firebase security rule lets a user in because of their email address (an admin address or your company's domain) but does not check that the address was verified. With email and password sign-up anyone can create an account with that address and pass the rule straight away, without access to the mailbox.
How it is exploited
The rule is `allow write: if request.auth.token.email.matches('.*@acme[.]com$');`. Someone opens the app's sign-up screen (or calls createUserWithEmailAndPassword with the config from the app) as boss@acme.com, never opens the confirmation mail, and can write every document the rule covers.
Why it matters
Anyone can pass rules meant for your staff or admins: read or change their data, or act as an admin.
How to fix it
- Search your rules for `auth.token.email`.
- Add `&& request.auth.token.email_verified == true` to each of those conditions.
- For admin rights use a custom claim set from a Cloud Function (`admin.auth().setCustomUserClaims(uid, { admin: true })`) and check `request.auth.token.admin == true`.
firestore.rules
function isStaff() {
return request.auth != null
&& request.auth.token.email_verified == true
&& request.auth.token.email.matches('.*@acme[.]com$');
}Does your app have this?
PTKD checks your build or your source project for PTKD-BACKEND-FIREBASE-EMAIL-UNVERIFIED and every other check in this knowledge base.
Scan your appReferences
Related checks (M3)
- Permissive CORS with credentials
- State-changing request succeeded without authentication
- Weak JWT observed on the wire
- Biometric authentication not bound to a cryptographic key
- Premium access is stored on the phone and trusted (heuristic)
- Firebase security rules open to everyone
- Users can make themselves admin or premium in Firestore
- Supabase auth settings in the local config (check the hosted project)