Skip to content
Vaulthalla LogoVaulthalla

Encryption

Understand how Vaulthalla protects master keys on Linux (TPM2) and macOS (Secure Enclave), per-vault encryption, S3/R2 upstream encryption, key rotation, and export risk.

Vaulthalla combines host-protected master keys (TPM2 on Linux, the Secure Enclave on macOS), per-vault AES-256-GCM keys, per-file encryption metadata, and optional upstream S3/R2 encryption. Operators should understand these layers before changing vault encryption policy or planning recovery.

Key Layers

Layer Purpose
Host key protection Protects Vaulthalla master keys on the host: TPM or swtpm on Linux, the Secure Enclave on macOS.
Vault master key provider Encrypts stored per-vault keys.
Per-vault AES-256-GCM key Encrypts file content for a vault.
Per-file IV and key version Lets Vaulthalla decrypt the correct ciphertext with the correct vault key version.
S3/R2 storage layout Records whether remote object bodies are Vaulthalla-encrypted and how the bucket is organised: opaque_v1 (new encrypting vaults) or path_v0 (older ones).

How Master Keys Are Protected

Master keys (the vault master key, the database password, API-key and S3 gateway secrets) are sealed by a platform backend before they are stored. vh status names the backend in use.

Platform Backend What protects the keys
Linux TPM2 (hardware TPM, or the managed swtpm) The keys are sealed to the TPM; a copy of the state directory alone doesn't unseal them on another host.
macOS Secure Enclave (secure-enclave) Each key is wrapped to its own Secure Enclave key (ECIES: P-256 key agreement, AES-256-GCM). Unwrapping needs this Mac's Secure Enclave, so a copy of the state directory doesn't open on another Mac.
macOS where the Secure Enclave can't be used (some virtual machines), or a development build file The keys are 0600 files inside the 0700 state directory, owned by _vaulthalla. Nothing binds them to the machine: they are as safe as the directory's permissions and, at rest, FileVault. vh status reports secrets backend: file (development: no hardware binding).

The Secure Enclave On macOS

The daemon creates its Secure Enclave keys itself, the first time it starts under launchd, and only the daemon can use them. A key is bound to the launchd context that created it: the same blob can't be opened from sudo, a login session or a copy of the daemon started by hand, even as root. That is why nothing else ever reads a sealed secret on macOS: the installer hands the database password to the daemon (through the one-time run/db_password file), and vh secret and vh vault keys ask the daemon.

  • Upgrades keep every key: they aren't bound to the program's signature, so a new version opens them.
  • Installs from before the Secure Enclave backend sealed with the file backend. The first start of the new version reads each file, seals it into the Secure Enclave, and deletes the plaintext file. Nothing else changes, and nothing is lost if the move is interrupted.
  • Another Mac, or a Mac whose macOS was erased and reinstalled, can't open the sealed keys. Recover from GPG-encrypted vault key exports and internal secret exports: see macOS Key Recovery.
  • Restarts and FileVault: the keys are usable from the first unlock after boot. With FileVault on, a cold boot stops at the FileVault login before any daemon runs, so Vaulthalla starts only once someone unlocks the disk. For an unattended restart, use sudo fdesetup authrestart, which unlocks the disk once on the way back up: the daemon starts at the login window, before anyone logs in. See Restarts And FileVault.

Keep FileVault on regardless: the vault data and the database sit on the same disk.

TPM Selection On Linux

At startup on Linux, Vaulthalla uses TPM configuration in this order:

  1. Explicit TCTI overrides such as VH_TPM_TCTI, TSS2_TCTI, or TPM2TOOLS_TCTI.
  2. Hardware TPM devices such as /dev/tpmrm0 or /dev/tpm0.
  3. The local swtpm service on the managed localhost ports.

If no usable TPM path exists, encryption initialization fails and the service cannot safely run.

Software TPM State

When swtpm is used, its state is stored under:

1/var/lib/swtpm/vaulthalla

That state is sensitive. Back it up only into protected operator backup storage. Restoring it to a different host changes your trust and recovery model.

Per-Vault Keys

Each vault has a generated 32-byte AES key. Vaulthalla encrypts that key with TPM-backed master material before storing it in PostgreSQL. File encryption uses AES-256-GCM and records IV and key version metadata so later reads can find the right key version.

Key rotation creates a new vault key version, decrypts with the old key version, re-encrypts with the current key version, and records rotation state until complete.

Rotation re-encrypts live files only. Retired key versions stay sealed in the database, and recovery data (snapshots, local versions, provider object versions) keeps the version it was sealed with. Restoring such a generation re-seals it under the current key as it is restored, and only after the old key authenticates it; no plaintext is written to disk. Vaulthalla refuses to delete a retired key while recovery data references it, and key exports include those versions.

1vh vault keys rotate <vault> --sync-now2vh vault keys rotate all

Use --sync-now when remote encrypted objects should be brought forward immediately where supported by the sync plan.

Content Format And Conversion

File content is stored in VHF1, an authenticated, chunked format: a header that names the vault, the file and the key version, then 64 KiB chunks that are each authenticated with their position, so truncated, reordered or swapped content is refused and partial reads only ever return authenticated bytes. Builds before VHF1 stored each file as one AES-256-GCM message with no header (the legacy format).

After the upgrade, a background conversion re-seals every legacy local file and every legacy recovery generation (snapshot members, local versions and the upstream backlog in .vh-recovery) as VHF1:

  • It never rotates a key: each item keeps its key version, including generations retained under a retired key.
  • Each item is verified before the legacy form is removed: the legacy authentication tag over the whole file, then the new file is read back in full and its plaintext digest compared with the original's. Anything that doesn't verify (damage, a size that doesn't match the catalog) is left exactly as it was and reported.
  • No plaintext is written to disk; the only file written is the new VHF1 file.
  • A recovery blob that is a hard link of a live file is converted once, together with the file, and stays a hard link.
  • It is resumable: a crash or restart at any point leaves every file readable, and the next pass continues.
  • It pauses while a key rotation or a key salvage of the vault runs, and files open for writing wait for the next pass.
  • It is rate-limited (vaults.format_conversion in Configuration).

S3/R2 vaults with upstream encryption keep their live files' local and bucket copies identical, so those convert with the bucket's layout migration instead (Migrating A Vault To Opaque Storage); their recovery generations convert here. Vaults that store plaintext upstream convert their local copies here.

Check progress:

1vh vault format status all2vh vault format status <vault> --json

state is converted when nothing legacy is left, pending or converting while work remains, blocked during a key rotation or salvage, disabled when the conversion is turned off, and awaiting_layout_migration when only an upstream-encrypted vault's live files are left (vh vault migrate-layout converts them). remaining lists live files and recovery blobs still in the legacy format, as items and bytes on disk.

S3/R2 Upstream Encryption

For S3/R2 vaults, upstream encryption controls whether object bodies uploaded to the bucket are encrypted by Vaulthalla before upload.

With upstream encryption enabled (the default for new S3/R2 vaults), new vaults use opaque storage:

Your storage provider only ever sees encrypted, opaquely named objects. It can't see your file names, folders or contents. It can see how many objects you store, their sizes and when they change.

  • Each file is one encrypted object named by a random id (o/<id>), with no metadata; names, folders and the vault's history live in an encrypted manifest in the same bucket (.vaulthalla/).
  • Decrypting the objects needs this vault's keys, which stay on your server, in your key exports, and wrapped to your recovery kit. With the kit, the vault can be rebuilt on another server from its bucket (see Restore A Vault From Its Bucket); that needs your recovery material, never the bucket by itself.

What Opaque Storage Still Reveals

Opaque storage hides names and contents, not everything. Your storage provider, or anyone with access to the bucket, its access logs or its inventory reports, can still see:

What How exactly
How many files you store The number of objects under o/ (files plus a few bounded metadata objects).
Each file's size The object size minus the 120-byte header and 16 bytes per 64 KiB chunk. There is no padding.
When each file changes, and how often A file keeps one object id, so every overwrite lands on the same object.
What is read and when Which objects are read, and which byte ranges (a ranged read reveals chunk ranges).
Request counts and timing per sync pass Including the manifest root rewrite each pass.
How many versions and deletions Provider versions and delete markers per object.
How many key rotations The key version in each object's header and the number of key envelopes.
Roughly how large the manifest is Its segment sizes follow the number of entries.
That the bucket is a Vaulthalla vault The layout descriptor and the shape of the object names.
Account, region, storage class, creation time The provider's own account data.

It does not protect against whoever runs the server (it holds the keys while it runs), against traffic analysis of connections to the server, or against the provider deleting everything (availability). Active tampering in the bucket (replacing, reordering or rolling back objects) is detected, not prevented.

vh vault info shows a vault's layout. Opaque storage costs about the same in requests as the earlier layout, and less for renames: a rename or move of a file or folder rewrites no object, only the manifest at the next sync pass. An opaque_v1 vault can be rebuilt from its bucket and your recovery kit on another server; see Restore A Vault From Its Bucket.

Vaults From Before Opaque Storage

Encrypting S3/R2 vaults created before release 1.22 keep the earlier layout, path_v0, until you migrate them. File contents are encrypted before upload. File and folder names are visible to your storage provider.

  • Each object is named after the file's path in the vault, so the bucket's provider, and anyone with read access to the bucket, sees file and folder names, the folder tree, object sizes and counts, when objects change, and the provider metadata (encryption status, IV, key version, content hash).
  • Restoring such a vault needs its database as well; a bucket and a recovery kit are not enough (see Restore Vault Keys).

Nothing converts them on upgrade. Migrate each one yourself when you are ready.

Migrating A Vault To Opaque Storage

vh vault migrate-layout moves a path_v0 vault to opaque storage. It re-seals every object in the newer encrypted format, under the same key version (it is not a key rotation), so no content is ever written in plaintext.

    1. Check it can run. The vault must encrypt upstream, its keys must be loaded, no key rotation or salvage may be running, and it needs recovery material that doesn't depend on this server: a recovery recipient or a current key export (Recovery Recipients). A bucket with a protection lock can't be migrated. vh vault migrate-layout <vault> --status shows the layout and any migration.
    2. Start it. vh vault migrate-layout <vault>. It runs in the background. Files stay readable and writable through the mount, the web console and the S3 gateway; the vault's sync waits until the migration is done, and changes made meanwhile upload right after.
    3. Follow it. vh vault migrate-layout <vault> --status shows the state, the cost estimate and what was sent.
    4. Clean up later. The old path-named objects stay untouched in the bucket for a waiting period (7 days by default). After it, vh vault migrate-layout <vault> --cleanup lists what would be deleted, and --cleanup --confirm <vault name> deletes it.

What the migration does:

  • Inventory. It lists the whole bucket, every object, every version the provider keeps and every delete marker, and reads each version's header once.
  • Cost check. It estimates the requests and bytes before anything is written and checks them against your price budget. If the cost can't be priced (no catalog for the provider), start it with --accept-unpriced.
  • Copy and verify. Every retained version, every pending upstream version from local versioning and each file's current content is decrypted, authenticated, re-sealed and written under the file's opaque id, oldest version first. A delete marker becomes a delete marker on that object, so recovery points keep their order and their original times. Each new object is checked twice: the bytes are authenticated before upload, and the provider must prove it holds them (its checksum matches, or Vaulthalla reads the object back and authenticates it). A random sample is always read back.
  • Cutover. One database transaction switches the vault to opaque storage, then the encrypted manifest is published and read back from the bucket alone.
  • If anything fails before the cutover, the vault stays on path_v0, nothing in the bucket is deleted, and vh vault migrate-layout <vault> resumes where it stopped. A bucket that changed since the vault's last sync is refused: run vh vault sync <vault> and start the migration again.

What the cleanup never does:

  • delete anything before the waiting period ends, before the manifest has been verified, or on a bucket with a protection lock;
  • delete anything the inventory didn't list, by prefix or by lifecycle rule: each deletion names one object version;
  • override Object Lock: a version under retention or a legal hold stays, and status shows the date it can go.

Some versions stay on purpose and are listed with their reason: archived (an archive storage class: restore it first), key_unavailable (sealed under a key version this server doesn't hold), unattributed (not Vaulthalla's encrypted content, such as another application's object), not_inventoried (it appeared after the inventory). The migration is complete only when a full listing of the bucket shows no path-named object, version or delete marker; until then status says cut_over, cleanup or cleanup_blocked, and your provider can still read the names in that history. vaults.layout_migration.cleanup_wait_days sets the waiting period (Configuration). The server's health (legacy_content) says whether any legacy content is left on it.

With upstream encryption disabled:

  • Object payloads written by Vaulthalla are plaintext from Vaulthalla's perspective.
  • Provider-side encryption may still exist, but it is outside Vaulthalla's key model.
  • Anyone with bucket read access and provider decryption rights may read uploaded object bodies.

Who Can Read What

These statements are for the deployment Vaulthalla supports today: you run the daemon on your own hardware, with your own bucket or local disk, and you hold the recovery material (key exports, internal secret exports). Valkyrian Labs receives no keys, exports or recovery material and has no access to your server. It remains the software vendor: the updates you install come from it, signed, and you decide when to take them (sudo apt-mark hold vaulthalla pins a version on Linux).

Who Local vault S3/R2, upstream encryption on S3/R2, upstream encryption off
The storage provider, or anyone with bucket access Not involved Encrypted, opaquely named objects; counts, sizes and change times are visible (what remains). Vaults from before release 1.22 (path_v0): file and folder names are visible too Everything: contents and names
Whoever administers the server running the daemon Everything: the daemon holds the vault keys while it runs Everything Everything

Valkyrian Labs does not run your server and receives no keys, exports or recovery material. Recovery works from your bucket and your recovery kit, even if Valkyrian Labs is gone: no account or payment is needed. Hosted or assisted recovery services are planned, not implemented, and enrolling in one would be a separate, explicit choice.

The server holds every vault key while it runs, so protecting that host, its administrators and its updates is part of protecting the data. A vault's contents are only as private as the server that runs it.

Changing Upstream Encryption

Changing upstream encryption on an existing S3/R2 vault is sensitive because objects may already exist in the bucket.

Examples:

1vh vault update archive --no-encrypt --accept-decryption-waiver2vh vault update archive --encrypt --accept-overwrite-waiver

Use these waivers only after deciding how existing objects should be handled. For important buckets, take a backup, run a dry-run, and test on a copy of the bucket first.

Export Vault Keys

Export keys for disaster recovery:

1vh vault keys export all --recipient <gpg-fingerprint> --output vaulthalla-vault-keys.json.gpg

Exporting without a recipient writes unencrypted key material:

1vh vault keys export all --output vaulthalla-vault-keys.json
Unencrypted key exports are live recovery material

Anyone who obtains unencrypted vault keys plus enough vault metadata and file bodies may be able to decrypt vault content. Use GPG-encrypted exports and store them separately from routine host backups.

Export Internal Secrets

Internal secrets such as database and JWT secrets are managed separately from vault keys:

1vh secret export all --recipient <gpg-fingerprint> --output vaulthalla-secrets.json.gpg

See Secrets And Key Export.

CPU Requirements

Vaulthalla's AES-256-GCM path depends on supported CPU and crypto-library features. Production hosts should have AES/PCLMUL-capable hardware support. Development-only overrides may exist, but they are not a production escape hatch.

If the service fails during crypto initialization, check Linux Troubleshooting. Apple Silicon Macs have the required AES instructions.