Join our Newsletter — 33% off our NHI Course
Home› Guides› Firebase Authentication Security Guide: Providers, Token Verification and…
Guide Customer Identity

Firebase Authentication Security Guide: Providers, Token Verification and Abuse Controls

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 19 November 2026 15 min read
On this page

Firebase Authentication is secure by design only when the application around it verifies ID tokens correctly, handles revocation, limits what anonymous and phone sign-in can do, and keeps email enumeration protection switched on. Firebase takes care of password storage, provider integrations and token issuance, which removes a large class of mistakes. What it cannot do is decide how your backend trusts a token, how long a stolen session stays useful, which countries can trigger paid SMS messages from your project, or whether an anonymous user should be able to write data. Those decisions sit with the developer, and they are where most Firebase Authentication weaknesses are found.

This guide covers the parts of Firebase Authentication that matter most for security: choosing and constraining sign-in providers, verifying ID tokens on your server, handling long-lived sessions and revocation, email enumeration protection, anonymous accounts, and SMS abuse controls for phone sign-in. It deliberately does not repeat Security Rules design, which is covered in the Firebase Security Rules Guide.

This is an independent guide from NHI Mgmt Group, based on Google's public Firebase documentation as of November 2026. It is not sponsored or reviewed by Google. Product features change, so confirm settings against Google's current Firebase documentation.

Key takeaways

  • Verify every ID token on your server with the Admin SDK verifyIdToken() method, or with a JWT library that checks every claim Firebase documents: alg is RS256, kid matches a current Google public key, aud is your project ID, iss is https://securetoken.google.com/<projectId>, and exp, iat, auth_time and sub are valid.
  • Firebase ID tokens last an hour, but Firebase states that sessions are long lived: refresh tokens persist until the user is deleted, disabled, or a major account change occurs. Use revokeRefreshTokens() and checkRevoked for sensitive operations.
  • Email enumeration protection is on by default for projects created on or after 15 September 2023, and off for older projects unless you enable it. Turn it on everywhere.
  • Anonymous accounts are real authenticated users to your Security Rules. Constrain what they can do, and enable automatic clean-up (available with Identity Platform) so they do not accumulate.
  • Phone sign-in is, in Firebase's own words, "less secure than the other available methods". Set an SMS region policy so SMS can only be sent to countries you serve; new projects allow no regions by default.

How Firebase Authentication fits into your security model

Firebase Authentication issues a signed ID token to the client after a successful sign-in. That token is then used in two places: by Firebase services such as Cloud Firestore, Realtime Database and Cloud Storage, which evaluate it through Security Rules, and by your own backend, which must verify it before trusting the user ID it contains.

That split is important. Security Rules verify the token automatically. Your own servers, Cloud Functions that accept HTTP requests and any API you expose do not, unless you write the verification code. A backend that decodes a token without verifying the signature, or that accepts tokens from any Firebase project, trusts whatever the caller sends. MITRE ATT&CK tracks the general technique of abusing stolen tokens as Application Access Token (T1550.001).

The rest of this guide follows the life of a Firebase identity: which providers create it, how the token is checked, how long the session lasts and how it is ended, and which abuse controls protect the sign-in and sign-up flows.

Choosing and constraining sign-in providers

Every provider you enable in the Firebase console is an entry point to your app. Treat the list as an attack surface and enable only what your users need.

  • Email and password. The most common provider and the one most exposed to credential stuffing and account enumeration. Pair it with email enumeration protection (below) and with the abuse controls Google recommends for sign-up endpoints.
  • Federated providers. Sign-in through an external identity provider shifts password handling away from your app. Check the redirect and authorised domain configuration carefully, and review the provider list each release so unused providers are disabled.
  • Phone. Convenient but weaker and costly to abuse. Covered in its own section below.
  • Anonymous. Useful for letting users try an app before signing up, but every anonymous session is an authenticated identity in your rules. Covered below.

Firebase's phone authentication documentation advises that phone sign-in should be offered "alongside more secure sign-in methods". The same reasoning applies across providers: where an account holds anything valuable, give users a stronger option and make it the default.

Verifying ID tokens on your server

Google's documentation is clear about the preferred approach: "Use the verifyIdToken() method to verify an ID token". The Admin SDK call succeeds only if "the provided ID token has the correct format, is not expired, and is properly signed", and then returns the decoded token, from which you read uid.

Two warnings from the same page are often missed:

  • Basic verification "does not check whether or not the token has been revoked". Revocation is a separate, optional check covered in the next section.
  • The verification methods "are meant to verify ID tokens that come from the client SDKs, not the custom tokens" you create with the Admin SDK. Do not accept custom tokens as if they were ID tokens.

Verifying with a third-party JWT library

If your backend language has no Admin SDK, Firebase documents the checks a JWT library must perform. Every one matters; skipping any of them creates a bypass.

Claim or headerFirebase requirement
algMust be RS256
kidMust correspond to one of the public keys listed at https://www.googleapis.com/robot/v1/metadata/x509/[email protected]
expMust be in the future (seconds since the UNIX epoch)
iatMust be in the past
audMust be your Firebase project ID
issMust be https://securetoken.google.com/<projectId>, using the same project ID as aud
subMust be a non-empty string and must be the uid of the user or device
auth_timeMust be in the past; the time when the user authenticated

Firebase also states that the signature must be verified with the public key matching the token's kid, and that you should "Use the value of max-age in the Cache-Control header of the response from that endpoint to know when to refresh the public keys." Hard-coding the keys, or caching them indefinitely, will eventually break verification or leave you trusting retired keys.

Verification mistakes to look for

  • Decode without verify. Reading the payload of a JWT is not verification. Look for code that base64-decodes the token or calls a library's decode function without a signature check.
  • Missing audience and issuer checks. A token signed by Google for a different Firebase project has a valid signature. Only the aud and iss checks stop a token from another project being accepted by yours.
  • Algorithm not pinned. Libraries that accept the algorithm named in the token header can be tricked. Pin RS256.
  • Trusting client-supplied user IDs. Any API that accepts a user ID in the request body or query string instead of reading uid from the verified token lets one user act as another.

The general principles are covered in the JWT Security Guide, and common error messages in the JWT Validation Errors Troubleshooting Guide.

Sessions, refresh tokens and revocation

Firebase's session management documentation states: "Firebase ID tokens are short lived and last for an hour". It also states that "Firebase Authentication sessions are long lived": the client SDK uses a refresh token to obtain new ID tokens, and refresh tokens expire only when one of the following occurs:

  • "The user is deleted"
  • "The user is disabled"
  • "A major account change is detected for the user. This includes events like password or email address updates."

Firebase adds that "Password resets also revoke a user's existing tokens". In practice this means a refresh token stolen from a device remains useful until one of those events happens. For a compromised account or a lost device, the Admin SDK provides revokeRefreshTokens(uid); Firebase gives the example of revoking tokens "when a user reports a lost or stolen device". After revocation, the user record's tokensValidAfterTime records the cut-off.

Checking revocation

Revoking refresh tokens stops new ID tokens being issued, but an ID token already issued can remain valid until it expires within the hour. To reject those, Firebase documents two approaches:

  • On your server: pass the checkRevoked flag to verifyIdToken. Firebase notes that "performing this check on your server is an expensive operation, requiring an extra network round trip". NHI Mgmt Group recommends using it for sensitive operations such as changing credentials, payment actions and administrative functions, rather than on every request.
  • In Security Rules: store a revocation time per user and compare it against the token's auth_time. Firebase's documented Realtime Database example is auth.token.auth_time > root.child('metadata').child(auth.uid).child('revokeTime').val().

Build revocation into your incident response for customer accounts: when a user reports takeover, reset or disable as appropriate, revoke refresh tokens, and record the revocation time so rules and servers reject tokens issued before it. The Credential Stuffing Attack Response Playbook covers the wider response.

Email enumeration protection

Account enumeration is an attack where someone tries to "guess or confirm users in a system by passing an email address to the API and checking the response". Confirmed addresses are then used for targeted credential stuffing and phishing. Google's Identity Platform documentation describes email enumeration protection, which stops the service from revealing whether an address is registered, and gives the Firebase console steps for it.

Default status

Google states: "If you created your project on or after September 15, 2023, email enumeration protection is enabled by default." For older projects, it "is not automatically enabled". Google recommends enabling it on all projects. Check this first on any long-lived Firebase project.

What changes when it is on

  • The createAuthUri REST API and the fetchSignInMethodsForEmail client method no longer return the list of sign-in methods for an address.
  • Invalid sign-in attempts return a single INVALID_LOGIN_CREDENTIALS error, rather than distinguishing an unknown user from a wrong password.
  • Password reset and email verification responses no longer indicate whether an email was sent.
  • Email address changes must be verified first, using verifyBeforeUpdateEmail on Web and Android or sendEmailVerification(beforeUpdatingEmail:) on iOS.
  • Linking an email and password credential to an existing account with linkWithCredential and an EmailAuthCredential no longer works; Google documents using the signUp REST API with the user's ID token instead.
  • Anonymous user linking with an email fails on older SDKs: Android before 22.3.0, iOS before 10.18.0 and Web before 10.6.0.

Enabling it

In the Firebase console, go to Authentication settings, open User actions under User account management, select Email enumeration protection (recommended) and save. It can also be set through the Identity Toolkit v2 config endpoint with updateMask=emailPrivacyConfig and enableImprovedEmailPrivacy set to true. Google states that disabling it is possible but "not recommended in the long term".

One gap remains: sign-up still returns EMAIL_EXISTS for registered addresses. Google recommends App Check, reCAPTCHA or alternative sign-in methods to limit abuse of sign-up endpoints. For design patterns that apply across your app, see the Account Enumeration Prevention Guide.

Anonymous authentication

Firebase describes anonymous accounts as a way "to allow users who haven't yet signed up to your app to work with data protected by security rules". A call to signInAnonymously creates a real user with a uid, and that user passes any Security Rule that only checks request.auth != null.

That is the main risk. If your rules treat "signed in" as "trusted", enabling anonymous authentication makes your data available to anyone who calls one API. NHI Mgmt Group recommends:

  • Writing rules that distinguish anonymous users from users with a permanent provider, and limit anonymous users to their own scratch data.
  • Never granting anonymous users access to other users' data, shared collections, or anything with a cost, such as writes that trigger functions or external calls.
  • Requiring a permanent account before any action that would matter if done at scale by a script.

Upgrading anonymous accounts

When an anonymous user signs up, you can link their new credential with linkWithCredential. Firebase states that "If the call to link succeeds, the user's new account can access the anonymous account's Firebase data." This is useful, but check the interaction with email enumeration protection above if you link email credentials on older SDK versions.

Clean-up and quotas

Anonymous accounts accumulate. Firebase documents automatic clean-up, which requires upgrading to Firebase Authentication with Identity Platform. When enabled, anonymous accounts "older than 30 days" may be deleted; accounts that have been upgraded by linking a sign-in method are not. Before enabling it, you can preview affected users by filtering on is_anon in Cloud Logging.

Firebase also notes that it limits the number of new email and password and anonymous sign-ups from the same IP address in a short period to protect against abuse. Temporary changes to this quota can be requested in the Firebase console. Raise it only for a known event, and set it back afterwards.

Phone sign-in and SMS abuse controls

Firebase's phone authentication documentation is unusually direct about the trade-off: "Authentication using only a phone number, while convenient, is less secure than the other available methods", because "any user that can receive SMS messages can sign in to an account using the device's phone number". Numbers are reassigned and SIMs can be swapped, so treat phone sign-in as a convenience method and offer a stronger option for valuable accounts. See the Phone Number Recycling Guide for the wider risk.

The second risk is cost. Every verification code is a paid SMS sent to a number of the requester's choosing. Attackers who control premium or high-cost number ranges can use sign-in forms to generate traffic they profit from, a pattern described in NHI Mgmt Group's Phone Number Fraud guide.

Controls Firebase documents

  • reCAPTCHA. Firebase states that it "uses reCAPTCHA to prevent abuse" of phone verification requests. On the web you set up a RecaptchaVerifier before sending codes. Do not disable or work around it.
  • SMS region policy. Firebase lets you "Set a policy on the regions to which you want to allow or deny SMS messages to be sent", and states that "Setting an SMS region policy can help protect your apps from SMS abuse." For new projects, "the default policy allows no regions". Use an allow list of the countries you actually serve, rather than a deny list.
  • User notice and consent. Firebase advises telling users they "might receive an SMS message for verification and standard rates apply", and states developers should ensure appropriate end-user consent. Firebase also notes that phone numbers provided for authentication are sent to and stored by Google for spam and abuse prevention.

Monitoring SMS use

NHI Mgmt Group recommends setting a billing alert specific to phone authentication, reviewing verification volume by destination country weekly, and treating a sudden rise in codes sent to a single country or number range as an incident. A spike that does not match user growth is almost always abuse.

Service accounts and the Admin SDK

The Admin SDK that verifies tokens and revokes sessions runs with a service account, and that service account can create users, mint custom tokens and change any account. It is the most powerful non-human identity in a Firebase project. Keep it on the server, prefer the platform's built-in credentials over downloaded key files, never ship it in a client, and restrict who can create keys for it. NHI Mgmt Group's Firebase Credentials Security Guide covers service account keys, API keys and their safe handling.

Common failure patterns

  • Backend trusts unverified tokens. A JWT is decoded but not verified, or aud and iss are not checked.
  • Revocation not wired in. Compromised accounts keep working for the life of the refresh token because revokeRefreshTokens is never called and checkRevoked is never used.
  • Enumeration protection off on an old project. A project created before 15 September 2023 still returns sign-in methods and distinguishes unknown users from wrong passwords.
  • Anonymous users treated as trusted. Rules check only that request.auth is not null, so anyone can read or write by signing in anonymously.
  • Anonymous accounts never cleaned up. Millions of stale identities accumulate.
  • Open SMS regions. The region policy allows every country, or a deny list misses new high-cost ranges.
  • Admin SDK credentials on the client. A service account key is bundled in an app or committed to a repository.

Practitioner checklist

  • Use verifyIdToken() on every backend endpoint, or a JWT library that checks alg, kid, exp, iat, aud, iss, sub and auth_time.
  • Refresh Google public keys according to the Cache-Control max-age value.
  • Read the user ID only from the verified token, never from request parameters.
  • Call revokeRefreshTokens in account takeover and lost device procedures, and use checkRevoked for sensitive operations.
  • Confirm email enumeration protection is enabled, especially on projects created before 15 September 2023.
  • Migrate away from fetchSignInMethodsForEmail and direct email updates to verifyBeforeUpdateEmail.
  • Restrict anonymous users in Security Rules and enable anonymous account clean-up.
  • Set an SMS region allow list, keep reCAPTCHA in place, and alert on SMS volume by country.
  • Disable any sign-in provider the app does not use.
  • Keep Admin SDK service account credentials on the server and rotate or remove downloaded keys.

Standards and references

Related NHI Mgmt Group resources: Firebase Security Rules Guide · Firebase Credentials Security Guide · Top 10 CIAM Security Risks · Account Enumeration Prevention Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.