security: lock down open Firestore rules - #31
Open
mdsaif45 wants to merge 1 commit into
Open
Conversation
The Firestore rules allowed 'allow read, write: if true', exposing the entire database to anyone with the (public-by-design) Firebase Web API key that secret scanning flagged. All app data access is server-side via the Admin SDK, which bypasses rules, and the web client uses Firebase only for auth — so denying direct client access has no functional impact. - firestore.rules: default-deny direct client access (allow ... if false), with comments explaining the Admin-SDK architecture and how to widen safely, plus a deploy reminder. - SECURITY.md: correct the Firestore section to match the deployed posture (the doc claimed 'scoped to authenticated users' while the rule was open), and document that the Firebase Web API key is public by design and must not be rotated in response to a scanning alert. Refs #30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the investigation behind secret scanning alert #1 (Google API key). Fixes #30.
TL;DR
The scanner flagged a "leaked" Google API key. That key is a Firebase Web API key — public by design and not the real problem. The investigation instead found that
firestore.rulesallowedallow read, write: if true, exposing the entire database to anyone on the internet. This PR closes that hole.The real vulnerability
Anyone with the (public) Firebase config could read every user's data and write/delete arbitrary documents directly against Firestore.
Why this is safe to fix (no functional impact)
adminDb,server/repositories/firestore/*)Since no legitimate path relies on client-side Firestore access, the rules are set to default-deny (
allow read, write: if false) — the tightest option, with a comment on how to add a narrowly-scoped block if a future feature ever needs direct client access.Changes
firestore.rules— default-deny direct client access; documented the Admin-SDK architecture and afirebase deployreminder.SECURITY.md— the Firestore section previously claimed access was "scoped to authenticated users" while the actual rule was wide open; corrected it to match reality, and documented that the Firebase Web API key is public-by-design and must not be rotated in response to a scanning alert.```bash
firebase deploy --only firestore:rules
```
Until deployed, the live database stays open.
Verification done
adminDb(Admin SDK).frontend/src/lib/firebase.ts) uses Firebase only for auth.firestore.rules(nofirebaseCLI available locally; Firebase validates on deploy).