Skip to main content
LowSecretsOWASP A07:2021CWE-798

How to fix: Firebase API key (public) in source

Firebase Web API keys (AIzaSy*) are public by design. Security depends on Firestore rules / App Check.

Why it matters

Firebase Web API keys are intentionally public. Their presence alone is not a vulnerability. The risk is that weak Firestore or RTDB security rules combined with the exposed key allow unauthenticated read or write access to your entire database.

Firebase Web API keys (AIzaSy*) are public by design. Security depends on Firestore rules / App Check.

How to fix it

  1. 1Enable Firebase App Check to block unauthorized clients
  2. 2Review Firestore and RTDB security rules to ensure no data is readable without authentication
  3. 3Restrict the API key to specific Firebase services in Google Cloud Console

Code examples

Firestore rules: require authentication

JavaScript
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // Default deny
    match /{document=**} {
      allow read, write: if false;
    }

    // Users can only read/write their own documents
    match /users/{userId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }
  }
}

Firebase App Check: enforce in production

JavaScript
import { initializeApp } from 'firebase/app';
import { initializeAppCheck, ReCaptchaV3Provider } from 'firebase/app-check';

const app = initializeApp(firebaseConfig);

// Enable App Check to block unauthorized clients
initializeAppCheck(app, {
  provider: new ReCaptchaV3Provider(process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY!),
  isTokenAutoRefreshEnabled: true,
});

References

Detected automatically by VulnRadar. The check id is secret-firebase-api-key-public, stable across every scan so you can filter or diff on it.

See every secrets check

Questions

How severe is Firebase API key (public) in source?
VulnRadar rates this low severity in the secrets category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id secret-firebase-api-key-public, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Firebase API key (public) in source map to?
It maps to CWE-798. In the OWASP Top 10 it falls under A07:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for firebase api key (public) in source

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Firebase API key (public) in source | VulnRadar