Skip to content

My Firebase Admin (service account) key leaked. What do I do?

Short answer

A Firebase Admin SDK service-account JSON file bypasses all Security Rules. Delete that key in Google Cloud console → IAM → Service accounts → Keys, create a replacement only if you can't use keyless credentials, and check Cloud Audit Logs and your data. The web firebaseConfig apiKey is public by design and is not this.

Last updated 2026-11-25 · Reviewed by ProofForge

Is it this key?

Format: JSON file with "type": "service_account", private_key_id, and a -----BEGIN PRIVATE KEY----- block

Blast radius: Admin access to Firestore, Realtime Database, Storage and Auth (Security Rules don't apply), plus any other Google Cloud roles the service account has.

The first 10 minutes

WhenDoHow
0–2 minDelete keyCloud console → IAM & Admin → Service accounts → the account → Keys → delete the leaked key ID.
2–5 minReplaceOn Google Cloud hosts, use the attached service account (no key file). Elsewhere, create a new key and store it as a secret, never in the repo or frontend.
5–8 minAuditCheck Cloud Audit Logs for the key ID. Look at Auth users, Firestore and Storage for changes.
8–10 minLeast privilegeTrim the service account's roles, and consider blocking key creation with an org policy.

Stop the next leak

  • Keep the key in a server-side env var. Never use a VITE_, NEXT_PUBLIC_ or EXPO_PUBLIC_ variable or hard-code it in frontend code.
  • Call the provider from your backend or an edge function, and add .env* to .gitignore.
  • Re-scan the live site after every deploy. Keys also leak through JS bundles, source maps and exposed .env or .git paths.

Check your live app

A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.

Read-only. No writes or row contents.

FAQ

Is the apiKey in my firebaseConfig a leak?

No. It identifies the project. Security Rules protect data, so check them.

Does deleting the key break my server?

Anything using that JSON fails until it gets the new credentials.

Why does Admin bypass rules?

The Admin SDK runs with service-account privileges, by design, for trusted servers.

Sources

Related

Read as Markdown · Scan methodology