How to Configure CockroachDB Encryption at REST

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up cockroachdb encryption at rest by giving each node a store key at startup. CockroachDB then uses that key to generate internal data keys and encrypt disk files. Most teams turn on disk protection and think their data is safe. Still, broad database roles still let logged-in users read plain text rows during a session. How cockroachdb encryption at rest works under the hood CockroachDB uses a two-tier key system to lock down data on disk. First, you create a master store key and plac

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.

You set up cockroachdb encryption at rest by giving each node a store key at startup. CockroachDB then uses that key to generate internal data keys and encrypt disk files. Most teams turn on disk protection and think their data is safe. Still, broad database roles still let logged-in users read plain text rows during a session.

How cockroachdb encryption at rest works under the hood

CockroachDB uses a two-tier key system to lock down data on disk. First, you create a master store key and place it on the host machine. You can also manage this store key through a cloud key service. When a database node starts up, it reads the store key from your chosen location.

Next, the node creates its own internal data key for everyday file work. The node uses your store key to lock and protect this internal data key. The internal data key then encrypts all table files, system logs, and write-ahead logs. Plain text files on the disk get replaced as the storage engine compacts data.

Key rotation follows a simple process during regular operations. You generate a new store key and point the node to both keys. The node reads old files with the old key and writes new files with the new key. This design keeps your cluster online while you rotate keys on every node.

Why teams pair disk keys with role rules

Teams rely on disk encryption to pass audits and protect physical storage drives. If someone steals a hard drive or copies a snapshot, they cannot read the files. The raw blocks on disk stay locked without the master store key.

Along with disk keys, teams set up role-based permissions inside the database. Admins create roles for apps, analysts, and support engineers. They grant read or write rights on whole tables or schemas to these roles. This setup controls who can log in to the cluster and open a session.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Yet this native setup leaves a major gap during daily work. Disk encryption only protects data while it sits idle on the storage drive. Once a user logs in with a valid role, the database decrypts rows in memory. Native roles decide who logs in, not what individual queries return in flight.

Where disk encryption leaves live sessions exposed

When an engineer runs a query, CockroachDB decrypts the blocks and sends plain text results. A developer debugging a slow query might pull thousands of customer rows by mistake. If that role has table read rights, the database returns every column in full by default.

Static roles also struggle when support staff need temporary fix rights in production. Teams often leave high-privilege roles attached to user accounts all week long. Moreover, disk keys do not mask sensitive fields like emails, phone numbers, or card numbers. Masking rewrites matched fields in results, while disk encryption returns raw values to authorized sessions.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Does cockroachdb encryption at rest slow down read queries?

The storage engine decrypts blocks as it reads them from disk into memory. Most workloads see only a small CPU cost because hot data stays cached in memory.

Are database backups encrypted by the node store key?

No, the node store key only protects local storage files and write-ahead logs. You must supply a separate encryption passphrase or key when you run a backup job.

Does disk encryption hide sensitive columns from logged-in engineers?

No, the database decrypts data by default for any user with table read permissions. To protect emails or national IDs in query results, you need runtime data masking.

The query runs. The emails stay hidden.