How to Configure Firestore Encryption at REST

Published
Length
3 min read

Luis Felipe Dias

All posts

Google Cloud turns on firestore encryption at rest by default for every database. You can also set up your own keys in Cloud Key Management Service. Most teams start with the default keys and add custom keys later. Still, teams often grant broad read roles to developers during this setup. Those wide roles let any logged-in user read clear data right away. How firestore encryption at rest works The platform scrambles your documents before it writes them to disk. It breaks data into chunks and

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Google Cloud turns on firestore encryption at rest by default for every database. You can also set up your own keys in Cloud Key Management Service. Most teams start with the default keys and add custom keys later. Still, teams often grant broad read roles to developers during this setup. Those wide roles let any logged-in user read clear data right away.

How firestore encryption at rest works

The platform scrambles your documents before it writes them to disk. It breaks data into chunks and gives each chunk its own key. A master key then wraps those chunk keys to keep them safe. Google handles the key rotation and storage work behind the scenes. When an authorized user asks for a document, the service unscrambles it. This process happens fast and needs no action from your app team.

Some teams need more control over the master keys for compliance rules. You can create a key ring in the cloud key service instead. Then you grant the database service account permission to use that key. You pick this custom key when you create the new database instance. Both the key and the database must live in the same region. If you revoke the key, the database stops serving data right away.

Managing keys and role permissions

Setting up custom keys requires strict role checks across your cloud project. You should separate the person who manages keys from database admins. If one person holds both roles, they control the whole data path. Give the key admin role only to your core security team. Give database roles only to the apps that must read documents.

Many teams make mistakes when they grant roles for local testing. Developers ask for production read access to fix a broken app feature. Admins often grant a broad project role to save time during incidents. That broad role stays active long after the team fixes the bug. Soon, dozens of engineers hold permanent permission to read every production collection.

What storage encryption solves and what stays exposed

Disk encryption protects your data if someone steals a drive from a data center. It also lets you lock all data by turning off your master key. This meets basic storage rules for most industry audits and security checks. It proves that raw files do not sit in plain text on disks.

Encryption at Rest + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, storage encryption does nothing once a valid user logs in. When an engineer or app queries a collection, the database decrypts the data. The service sends plain text back to anyone with a valid read role. Native storage keys only check if the database can read the disk. They do not check what a logged-in user does with the results.

This leaves a big gap during daily support and debugging work. A developer running a test query can pull thousands of customer records. Those records might hold emails, phone numbers, card numbers, or national IDs. Because the developer has a valid role, the database decrypts everything for them. Storage keys cannot stop a bad query or hide sensitive fields in flight. To protect live data, you must control queries at the session level. You also need a way to mask sensitive fields in query results.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.

Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Can I add a custom key to an existing Firestore database?

No, you must pick the custom key when you create the database. To switch keys later, you must export your data to a new database.

Does firestore encryption at rest hide data from project admins?

No, anyone with database read permissions receives plain text data in their queries. Disk encryption only protects files while they sit on physical storage drives.

What happens if I disable my custom master key?

The database loses access to your data once the key is off. All active read and write requests will fail until you restore the key.

The query runs. The emails stay hidden.