← All fixes

Fix it

Firebase Studio exposed my API key — is it a problem?

High severityCWE-798 (Use of Hard-coded Credentials)

This one has a twist. The Firebase config apiKey that Firebase Studio puts in your client is public by design and is usually not the problem, it only identifies your project. The real risks are two different things: permissive Security Rules that leave your database open, and a service account key, which is a true secret that must never be exposed.

Why it's a problem

Because the client apiKey is meant to be public, people assume Firebase is safe, and that assumption is the risk. What actually protects your data is Security Rules, and a test-mode or allow-all rule lets anyone read and write everything. Separately, a service account key grants full admin access to your project and must be rotated immediately if it ever reached client code or a repo.

How to fix it, in order

  1. 1Confirm which key it is. The client config apiKey is public and expected. A service account key (a JSON credential) is secret. If a service account key was exposed, rotate it in the Google Cloud console now.
  2. 2Lock down Security Rules. Write rules that scope reads and writes to the authenticated owner. Never ship test-mode or allow-all rules.
  3. 3Keep server credentials server-side. Service account keys belong only in server code or trusted environments, never in the client or the repo.
  4. 4Verify access. Try to read data you should not have access to using the public config. If it works, your rules are not restricting anything.

Why Firebase does this

The generated app includes the public config so it can talk to Firebase, which is correct. The gap is that securing the database is a manual Security Rules step the generated code cannot do, and a service account key can be introduced later for admin tasks and mistakenly placed where the client can see it.

Stop it happening again

Treat the client apiKey as public but assume nothing protects your data except your Security Rules. Configure rules on every collection, keep service account keys server-side, and scan for any secret credential that reached the client or repo.

The quick fix

  • The client apiKey is public and usually fine; do not panic over it.
  • Rotate any exposed service account key immediately.
  • Write Security Rules that restrict access; never ship test-mode rules.
  • Keep service account keys strictly server-side.

Want to know if this pattern is already in a repo you shipped? Scan a public repo free, no account needed.

Scan a repo →

Related: Firebase Studio security overview

Firebase Studio Exposed My API Key — Is It a Problem?: Prbl