new: drive vas from your AI agent over MCP · Cursor, Claude Code, Windsurf
Netlify
+
Firebase

Netlify + Firebase Security

Netlify's JAMstack architecture and Firebase's real-time capabilities are a strong pairing. The security risk sits at the boundary: client-side Firebase rules and server-side credential handling in Netlify Functions.

Why Netlify + Firebase?

Firebase is a popular backend for sites hosted on Netlify. The Firebase client SDK works directly from the browser, while Netlify Functions handle server-side Admin SDK operations. This gives Netlify apps a full backend without managing servers — but introduces two distinct security configurations.

Common Vulnerabilities

These are the security issues we find most often in Netlify apps using Firebase.

critical

Firebase Admin Credentials Exposed at Build Time

Netlify build-time environment variables are embedded into static assets. Admin SDK credentials that should stay in Netlify Functions may leak into the client bundle if referenced in the wrong context.

critical

Firestore Test Mode Rules

Netlify adds no protection to client-side Firestore access. If Security Rules are in test mode, any visitor can query the entire database directly.

high

Function Environment vs Build Environment Confusion

Developers may set Firebase Admin credentials as Netlify site variables rather than scoping them to functions only, making them available during the build process unnecessarily.

high

Unprotected Netlify Function Endpoints

Netlify Functions that use Firebase Admin SDK may lack authentication checks, allowing anyone to trigger Admin-level database operations via public function URLs.

What We Check for Netlify + Firebase

Build vs Function Variable Scope

Verify Firebase Admin credentials are scoped to functions only and not injected into the build process.

Security Rules Testing

Query Firestore as an unauthenticated user to confirm test mode rules are not deployed.

Netlify Function Authentication

Check that Netlify Functions using Firebase Admin SDK verify the caller's identity before processing requests.

Client Bundle Credential Scan

Inspect the deployed JavaScript bundle for service account keys that should only be in server-side functions.

Quick Security Wins

Apply these fixes right now to improve your security.

Set Firebase Admin credentials in Netlify as 'Functions-only' scoped variables, not site-wide build variables
Deploy Firestore rules separately: firebase deploy --only firestore:rules
Add auth verification to every Netlify Function that uses Admin SDK: verify a Firebase ID token before processing
Add a Content-Security-Policy header in netlify.toml
Rotate Firebase Admin credentials immediately if they appeared in any build log or client bundle

The Bottom Line

Netlify + Firebase is a capable combination, but its two-layer architecture means two separate security configurations. Firestore Security Rules protect client-side access; proper credential scoping and auth checks protect Admin SDK operations in Netlify Functions.

Secure Your Netlify + Firebase App

Find Security Rules misconfigurations, exposed credentials, and other vulnerabilities before attackers do.

Start Security Scan

Frequently Asked Questions

Can Netlify build environment variables leak into client-side Firebase code?

Yes. If you reference a Netlify environment variable in code that runs during the build, its value may be embedded in the output HTML or JavaScript. Firebase Admin credentials should only be accessed inside the netlify/functions directory.

How do I authenticate users calling my Netlify Functions with Firebase?

Have the client send a Firebase ID token in the Authorization header. In the Netlify Function, verify it with Admin SDK: const decoded = await admin.auth().verifyIdToken(idToken). Reject requests with missing or invalid tokens.

Does deploying to Netlify update my Firebase Security Rules?

No. Netlify and Firebase are completely separate services. Your Firestore Security Rules are managed through the Firebase CLI or console. A Netlify deploy has no effect on them.

Should I use the same Firebase project for Netlify deploy previews?

For production apps, use a separate Firebase project for non-production environments. In Netlify, you can set context-specific environment variables to point preview deployments at a development Firebase project.