How to Configure DuckDB Encryption at REST
You set up duckdb encryption at rest by using disk ciphers or secret keys. The database engine or the host system locks the local data files with a secret key. Many teams store analytics files on laptops, cloud volumes, or shared servers. If a user gets broad file permissions, they can copy the whole database file. Without file locks, anyone with that file can read every table inside it. How duckdb encryption at rest works in practice DuckDB runs inside your app and stores data in a single lo
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 duckdb encryption at rest by using disk ciphers or secret keys. The database engine or the host system locks the local data files with a secret key. Many teams store analytics files on laptops, cloud volumes, or shared servers. If a user gets broad file permissions, they can copy the whole database file. Without file locks, anyone with that file can read every table inside it.
How duckdb encryption at rest works in practice
DuckDB runs inside your app and stores data in a single local file. To protect that file on disk, teams use two main methods. The first method uses full disk locks on the host drive or cloud volume. The host system scrambles every block written to the storage drive. When the host boots up and mounts the drive, the system unlocks the files.
The second method uses database level secret keys during the session start. When a user opens a database file, they pass a secret key to the engine. The engine uses that key to scramble data blocks before it writes them to disk. It also uses that key to manage blocks when it reads them back into memory. Temporary files that spill to disk during big queries also get locked with this key. If someone steals the raw file without the key, they only see random bytes.
Where key management fits in the workflow
A strong cipher only works if you keep the secret key safe. Many teams put keys in local scripts or plain text files on the server. That habit defeats the purpose of locking the database file. If an attacker reads the disk, they find both the locked file and the key.
Instead, teams should store keys in a cloud key manager. When the app starts, it asks the key store for the secret key in memory. The app then passes that key to the database session to open the file. Teams should also rotate these keys on a regular schedule. To rotate a key, you read the old file and write a new locked file.
Encryption at Rest + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What disk locks solve and what they leave open
Locking files at rest stops threats from stolen laptops, lost backups, or bad disk snapshots. It makes sure that raw storage blocks stay unreadable without the secret key. Storage admins who manage the cloud volumes cannot read the raw database files either. This setup helps teams meet basic data security rules for stored files.
Still, disk locks only protect data while the file sits idle on the drive. Once a user or script opens the database with the valid key, the lock opens. The native setup decides who opens the file, not what individual queries do in flight. Any person or app with the key can run any SQL statement they want. They can drop tables, export full customer records, or read sensitive fields in plain text. Disk locks also do not create an audit log of who ran which query. To control live queries, you need runtime rules and field masking on the session itself. Masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results.
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 DuckDB lock temporary files during large queries?
Yes, when you open a locked database with a secret key, temporary spill files get locked too. This prevents plain text data from leaking onto the local disk during big sorts or joins.
Can I use cloud volume locks instead of database keys?
Yes, cloud volume locks protect against physical disk theft and bad snapshots. Still, any user who logs into the running host can still copy the unlocked file.
Do file locks hide sensitive columns from analysts?
No, once an analyst opens the file with the key, they see all columns in plain text. You need dynamic data masking to rewrite emails or card numbers in query results.
Related guides
In this post