PC-012CRITICALUnignored Files

Unignored Firebase / GCP Service Account JSON

Flags unignored Google Cloud and Firebase Admin SDK JSON credential files (*firebase-adminsdk*.json, service-account*.json) that embed raw RSA private keys.

Rule Slug
unignored-firebase-service-account
Affected Files
*firebase-adminsdk*.json, service-account*.json, *service_account*.json
Detection Method
.gitignore Cross-Check
Live Rule Tester100% Browser-Local
CRITICAL: "my-app-firebase-adminsdk-8x2k1.json" is NOT ignored by .gitignore and will be committed!

Vulnerable Pattern vs. Hardened Fix

Vulnerable Pattern
# Project tree with unignored admin key
├── src/
├── package.json
├── .gitignore
└── my-app-firebase-adminsdk-8x2k1-a1b2c3d4e5.json  # NOT IGNORED!
Recommended Fix
# .gitignore
*firebase-adminsdk*.json
service-account*.json
*service_account*.json

# And load via runtime secret or ADC instead of checking in JSON files:
# const app = initializeApp({ credential: applicationDefault() });
Recommended .gitignore Patch
*firebase-adminsdk*.json
service-account*.json
*service_account*.json

Why This Fails in Production

When you download a service account key from the Firebase Console or Google Cloud IAM, Google generates a JSON file containing both the service account email and a complete unencrypted PKCS#8 RSA private key (private_key). Unlike client-side Firebase configuration objects, a Firebase Admin SDK service account operates with full administrative privileges, bypassing all Firestore Security Rules, Realtime Database rules, Cloud Storage rules, and Firebase Authentication restrictions.

If an unignored *firebase-adminsdk*.json or service-account.json file is pushed to a Git repository, an attacker can immediately impersonate the service account using Google’s standard OAuth2 JWT exchange. Within seconds they can export every user account and password hash via Firebase Auth Admin APIs, dump or wipe entire Firestore databases, download private Cloud Storage buckets, or escalate across linked Google Cloud IAM roles such as BigQuery, Pub/Sub, or Cloud Run.

Developers frequently drop the downloaded JSON file straight into the project root or a config/ folder while testing GOOGLE_APPLICATION_CREDENTIALS locally, intending to delete it before committing. Without explicit patterns in .gitignore, a routine git add -A sweeps the JSON key directly into version control.

For production workloads deployed on Cloud Run, App Engine, GKE, or GitHub Actions, eliminate static JSON key files entirely by attaching a Workload Identity / runtime service account. For local development, store the key outside the repository (or verify it is strictly ignored) and use gcloud auth application-default login.

Remediation Steps

  1. 1Add *firebase-adminsdk*.json and service-account*.json to your root .gitignore immediately.
  2. 2If the JSON file was ever pushed to Git, immediately delete the compromised key ID in Google Cloud Console -> IAM & Admin -> Service Accounts -> Keys.
  3. 3Use gcloud auth application-default login locally and Workload Identity Federation in CI/CD so no static JSON key files exist on disk.
  4. 4If a non-GCP host requires credentials, inject the JSON payload or individual fields via encrypted environment variables instead of committing a file.

Frequently Asked Questions

Is google-services.json or GoogleService-Info.plist the same as a service account JSON?
No. google-services.json (Android) and GoogleService-Info.plist (iOS) contain public client SDK identifiers without private keys. Service account JSON files (*firebase-adminsdk*.json) contain raw RSA private keys with full admin privileges.
What if I rename the downloaded JSON file to credentials.json?
Even if renamed, PushCheck’s Private Key Block rule (rule #6) inspects the file content and catches the embedded -----BEGIN PRIVATE KEY----- block inside any JSON file.
How does Google Cloud recommend authenticating without JSON keys?
Use Application Default Credentials (gcloud auth application-default login) locally, attached service accounts on GCP runtimes, and Workload Identity Federation for GitHub Actions or AWS.

Related Unignored Files Rules

Scan local project folder →