My Firebase Admin (service account) key leaked. What do I do?
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
| When | Do | How |
|---|---|---|
| 0–2 min | Delete key | Cloud console → IAM & Admin → Service accounts → the account → Keys → delete the leaked key ID. |
| 2–5 min | Replace | On 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 min | Audit | Check Cloud Audit Logs for the key ID. Look at Auth users, Firestore and Storage for changes. |
| 8–10 min | Least privilege | Trim 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_orEXPO_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
.envor.gitpaths.
Check your live app
A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.
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
- Google Cloud: Create and delete service account keys
- Google Cloud: Best practices for managing service account keys
- Firebase: Add the Admin SDK