How to Configure Postgres Encryption at REST

Published
Length
3 min read

Luis Felipe Dias

All posts

You configure postgres encryption at rest by encrypting the underlying storage volume, file system, or cloud disk where the database stores its files. Teams also pair storage encryption with column-level functions or app encryption to protect sensitive fields. Most engineering groups enable volume encryption through their cloud provider or operating system and assume their data is safe. Still, storage encryption only protects physical media. Overly broad database roles still expose plain text da

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 configure postgres encryption at rest by encrypting the underlying storage volume, file system, or cloud disk where the database stores its files. Teams also pair storage encryption with column-level functions or app encryption to protect sensitive fields. Most engineering groups enable volume encryption through their cloud provider or operating system and assume their data is safe. Still, storage encryption only protects physical media. Overly broad database roles still expose plain text data to any logged in user.

How postgres encryption at rest works in practice

Database engines write table data. Indexes, Write-Ahead Logs, and temporary files to disk blocks. When you enable full disk or volume encryption. The operating system or cloud storage layer encrypts these blocks. Writing them to physical drives. When the database process reads a block back into memory. The storage layer decrypts it transparently.

Because the storage layer handles decryption by default for the running database service anyone who can query the database sees unencrypted data so, admins must combine disk encryption with strict internal role design in PostgreSQL, admins create group roles to manage rights across many users and grant single users membership in those group roles to restrict sensitive fields. Admins can grant the select rights on exact columns of a table or view. The entire table.

Admins also lock down built-in defaults. The special role name PUBLIC grants rights to every role on the system receiving database connect, temporary table creation, and function execution rights by default. Object owners must revoke these defaults to tighten security in PostgreSQL 15 and later, the default setup no longer lets every user create objects in the public schema. Though upgraded databases still require admins to revoke that creation rights from PUBLIC.

What storage encryption solves and what it leaves open

Volume encryption protects your team if someone steals. A physical hard drive or gains blocked access to raw cloud snapshots. It satisfies basic stack audit checks and protects inactive backup files. They sit on encrypted storage targets. Pairing disk encryption with column-level select rights reduces exposure inside the database.

Yet a major daily gap handles the session cleanly during live tasks. Storage encryption and static role grants only decide whether disk blocks are scrambled and who can log in they do not inspect or control what single statements do in flight once a session begins. Remember that granting the select rights on a table or exact columns also allows the user to export those rows in bulk.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

When an engineer or support user authenticates with a valid role the database engine and the underlying storage layer. Decrypt the data for their session if that user runs a broad query against a customer table the database returns plain text PII, secrets, or financial records directly to their screen. Native role management cannot redact sensitive values on the fly or require peer approval for a single risky statement.

Closing the gap during live database sessions

To protect data both on disk and in use teams need controls that operate at the query and result layer. Instead of relying only on disk encryption and static role assignments. Engineering teams place a policy enforcement layer between users and the database.

This approach lets admins inspect every statement. Execution and filter every result set before it reaches the client even when the storage layer decrypts blocks for a valid query real-time data masking can hide sensitive fields in the returned rows. Teams can also require approval workflows for sensitive queries. Keeping standard fixing fast and safe.

Check every Postgres query on the wire

Database roles and network rules decide who can open a session. They do not read what each SQL statement does after login. With hoop.dev, you run an open-source proxy, a sidecar for your Postgres, inline in the Postgres wire protocol. 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 apps and agents keep their login details and change only the host and port in the connection string their tool uses.

Before a query runs, hoop.dev guardrails refuse bad deletes or drops with a real Postgres error, or hold risky queries for approval. On the way back, hoop.dev data masking rewrites sensitive values in returned rows in memory, and every verdict goes to the audit trail. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for HIPAA, GDPR, and PCI DSS. See the code on GitHub.

Frequently asked questions

Does postgres encryption at rest protect against compromised database credentials?

No storage encryption only protects data when it sits on disk drives or snapshots. Once a user authenticates with valid keys. The storage system decrypts the requested blocks transparently and returns plain text results.

How can I restrict access to specific sensitive columns in PostgreSQL?

You can grant the select rights on exact columns of a table view, or materialized view rather than the whole object. Keep in mind that anyone with select rights on those columns can still export them. You mask the data in flight.

Do new PostgreSQL users get access to the public schema by default?

In PostgreSQL 15 and later. Users cannot create objects in the public schema by default. Still, every role still inherits default connect and execution. Rights assigned to the PUBLIC group. An admin revokes them.

The query runs. The emails stay hidden.