Lifecycle and security · Engineering

Encryption at rest: threat model and key rotation

Volume encryption, vault collections, backup encryption, and the places plaintext still leaks.

“Encryption at rest” is not one feature. It is a set of layers that protect different things against different attackers. A database can have encrypted backups and still leave plaintext on disk. It can have an encrypted volume and still log document bodies.

NonoDB stores standard collections as plaintext JSON in LMDB. It has no native volume encryption. Protect the data directory with LUKS, ZFS encryption, or a cloud block volume, and use vault collections when individual document bodies also need application-level encryption.

The layers

Layer Protects Does not protect
LUKS / ZFS / cloud volume Whole data directory, free pages, indexes, sidecars, staged backups while locked Data while the volume is unlocked; keys on the same disk
Vault collections Document bodies at rest, including backups/snapshots, without the tenant key _id, tenant_id, indexes, metadata, daemon memory
age / restic backup encryption Backup copies in the destination The live volume or a compromised host
TLS / mTLS Data in transit Data at rest or secrets in memory

Use volume encryption as the baseline. Use backup encryption as well; an encrypted live volume does not make an unencrypted object-store copy safe.

What volume encryption does not cover

Volume encryption protects a powered-off or removed disk. It does not protect against:

  • a host administrator while the volume is unlocked;
  • a compromised daemon;
  • a process that can read the filesystem;
  • swap or hibernation files;
  • core dumps;
  • temporary backup staging;
  • copied data.mdb files outside the encrypted volume;
  • logs that contain document content.

Disable core dumps for the daemon (LimitCORE=0 in systemd) and disable or encrypt swap. Keep the Unix socket and TCP listener protected by filesystem permissions and authentication.

LUKS and ZFS

LUKS encrypts a block device; the filesystem and NonoDB are unchanged. Mount it before starting the daemon and before any backup or restore.

ZFS can encrypt a dedicated dataset and still use compression:

Terminal window
sudo zfs create \
-o compression=zstd \
-o encryption=on \
-o keyformat=passphrase \
-o keylocation=prompt \
tank/nonodb

A raw key file can support unattended unlock, but it must not live on the same unlocked pool. Store it separately and document recovery.

For Docker, encrypt the host directory or block device backing the bind mount. Do not put the data only in an unencrypted container layer. If you use a named volume, verify its mountpoint is on encrypted storage.

Backup keys

Encrypted backups are only as recoverable as their keys.

For native age backups:

Terminal window
nonodb-cli backup-keygen /etc/nonodb/backup-identity.txt

The identity file is the private restore key. Keep it out of the backup destination and out of the database volume. Restore with NONODB_BACKUP_IDENTITY_FILE pointing at the identity. A lost identity makes encrypted native backups unrecoverable.

For restic, keep the repository password in a protected file or secret manager and use RESTIC_PASSWORD_FILE.

A practical key policy:

  1. Keep volume keys, vault tenant keys, backup keys, TLS private keys, and tokens in different scopes.
  2. Escrow a recovery copy in a different failure domain.
  3. Test key recovery during a restore drill.
  4. Rotate on schedule and after suspected exposure.
  5. Keep old keys until every backup/revision that needs them has expired.
  6. Record who can restore and how to revoke.

Vault boundaries

Vault encrypts the whole document body with a per-tenant key. The stored envelope keeps _id, tenant_id, and kid plaintext so lookup and tenant isolation work.

It does not protect indexes, collection metadata, TTL metadata, query patterns, or the daemon’s plaintext view while serving a request. Vault is not end-to-end encryption.

Key rotation is an offline read-with-old-key/write-with-new-key procedure; the daemon does not keep a keyring of retired keys. Back up tenant keys separately from the database. Losing the key means losing the bodies.

Key rotation checklist

  • Take a verified backup before rotating anything.
  • Test unlock and restore in a scratch environment.
  • Rotate vault keys by re-encrypting documents, not by editing envelopes.
  • Keep old backup keys until old backups expire.
  • Verify a real restore after rotation.
  • Document how to revoke a compromised key and what data becomes unreadable.

The honest summary

NonoDB does not make encryption automatic. It gives you vault collections for document bodies and expects the host, backups, and keys to be handled by the operator.

For many small deployments, volume encryption plus encrypted backups is the right baseline. Add vault only for the documents that need application-level encryption, and accept the query restrictions that come with it.

The encryption guide, vault guide, and backup guide cover the details.

All engineering notes →Read the docs