Vault format
This page describes vault file format v1. Flint never changes the format of an existing vault silently: every change is a numbered migration that runs when a newer Flint opens the vault.
What is on disk
Section titled “What is on disk”| Bytes | Content |
|---|---|
| 0–15 | A random salt, in clear text. It is unique per vault and is not secret |
| 16 onwards | SQLCipher pages: the schema, every row and every index, encrypted |
Nothing else is written. There is no sidecar file and no plaintext header, so hostnames, users, labels, tags, notes, group names, the vault name and the known host keys are all encrypted.
Outside the vault file, the list of recent vaults in
your config folder holds each vault’s path and name in clear text, so flint vault list
works while every vault is locked, and a vault id: 128 random bits, kept inside the
vault in the meta row vault_id (migration 10), so a new master password and salt
leave it as it was. A vault from before migration 10 keeps the id it had, a BLAKE2b hash
of its salt. The id recognises a vault after its file moves, names its activity file and
keys the desktop app’s layout state (ui-state.json, which holds only
that id, random group ids and the random ids of RDP hosts that take only the graphics
pipeline). Nothing from inside a vault is ever written there. While a
change is being written, SQLite keeps a rollback journal next to the file, encrypted as
well, and deletes it when the change commits.
The activity file
Section titled “The activity file”The activity log is not in the vault. Each
machine keeps its own, in a second SQLCipher file in the config folder:
activity/<vault id>.db, the folder owner-only (0700) and the file 0600. A vault that
syncs, through a cloud folder or later a remote vault, never carries it, and the log is
not rewritten on another machine. The file has its own random salt in its first 16 bytes
and is encrypted with its own key, derived from the vault’s master key (below), so it
opens only while its vault is unlocked. Back up activity… copies it as it is, still
encrypted. Its own migrations are numbered apart from the vault’s: 1 creates the log
(time, caller, how it was allowed, token, action, host, command, outcome, bytes cut) and
2 adds the grant that allowed an entry and how its command ended (run_state
running or ended, exit_status, duration_ms, and result, Flint’s error code when
Flint stopped it); entries from before say nothing there. A file the key no longer opens is kept beside it as <id>.db.unreadable
and a new log begins, unless a re-encrypted copy of it waits beside it (<id>.db.new, left
by a master password change cut short, below) that the key opens: that copy takes its
place.
master key = Argon2id(master password, salt) ops 3, memory 256 MiBpage key = crypto_kdf(master key, 1, "flintvlt")secrets key = crypto_kdf(master key, 2, "flintvlt")activity key = crypto_kdf(master key, 3, "flintvlt") the activity file's page key- Argon2id and crypto_kdf come from libsodium. The Argon2id cost is fixed by the format, so a library upgrade cannot change it.
- The page key encrypts the whole file through
SQLCipher (AES-256 with an HMAC-SHA512 per page).
SQLCipher’s own password derivation is bypassed. Its settings are fixed by the format:
cipher_compatibility4, page size 4096, HMAC and KDF algorithm SHA512. - The secrets key encrypts passwords, private keys and passphrases a second time, with XChaCha20-Poly1305 (libsodium). Each sealed value is bound to its row and field, so it cannot be moved to another host or field. Secrets are only decrypted to connect.
A new master password
Section titled “A new master password”flint vault passwd and Settings → Vault → Change master password… draw a new salt and
derive new keys from the new password. Flint then writes a complete copy of the vault
beside it, <vault>.rekey (SQLCipher’s sqlcipher_export under the new page key), seals
every secret again under the new secrets key inside that copy, and checks it opens. The
activity file gets the same treatment (<id>.db.new). The copy is renamed over the vault:
before that rename the old vault is whole, after it the new one is. The activity copy is
renamed next. A copy left by a change that never reached its rename is removed at the
next unlock.
With Remember on this computer on, the new master key is saved under the new salt’s keychain account before the rename and the old account is deleted after it.
Schema
Section titled “Schema”The tables inside the encrypted file change only through numbered migrations, which are never edited once released. Opening a vault applies the ones it lacks, each in its own transaction; a vault from a newer Flint is refused rather than downgraded.
| Migration | Adds |
|---|---|
| 1 | The format parameters (meta), groups, SSH keys, credentials, hosts and host tags |
| 2 | known_hosts: one server key per address (key type and SHA-256 fingerprint), recorded on first connect |
| 3 | hosts.initial_command and hosts.keep_shell: the command an interactive session runs, and whether a login shell follows it |
| 4 | tokens (name, BLAKE2b hash of the secret, scope by group and host id, actions, created, expiry and revocation times; revoked, never deleted) and activity (time, caller, how it was allowed, action, host, command, outcome) |
| 5 | hosts.sudo_password: the password exec --sudo types, sealed with the secrets key like the host’s password; empty means the login password |
| 6 | activity.command_cut: how many bytes of a command past 16 KB were cut (entries from before were cut at 160 characters and say 0). The log’s retention in days is the meta row activity_retention_days (absent: 90) |
| 7 | tunnels: local forwards saved in a host (name, local port, destination host and port, open on connect), removed with their host; a name is unique in its host, whatever its case |
| 8 | hosts.type (ssh for every host saved before, or rdp) and hosts.domain (an RDP host’s Windows domain). An RDP server’s certificate is kept in known_hosts under rdp://<name>:<port>, beside SSH host keys |
| 9 | The activity log leaves the vault: activity is renamed activity_moving, and at the same unlock its rows (with their ids) and the meta row activity_retention_days are copied into this machine’s activity file, then dropped from the vault. A move cut short is finished at the next unlock, with no duplicate |
| 10 | The meta row vault_id, empty: the next unlock writes the id the vault already had (a hash of its salt), and a new vault gets a random one. A new master password keeps it |
| 11 | updated_at on groups, hosts, SSH keys, credentials, known hosts, tunnels and tokens (when the row was last written, in Unix milliseconds; 0 for a row not written since), and tombstones (kind, id and time of each deleted row), so two copies of a vault merge record by record |
| 12 | hosts.rdp_audio (an RDP host’s remote sound: local, remote or off; empty reads as local, and every SSH host keeps it empty) and hosts.rdp_microphone (0 or 1: whether the remote computer may use this computer’s microphone; 0 for every host saved before) |
| 13 | workspaces: tabs saved by name (Workspaces): the layout, the divider positions in thousandths of a share, and the places in order, each a host id or empty, with the alias each host had when it was saved (only to name a host removed since). Names are unique, whatever their case. No foreign key: removing a host leaves its places, which open empty |
A vault that has been opened by a Flint with migration 11 is refused by older builds, one opened with migration 12 by a Flint before 0.27, and one opened with migration 13 by any Flint without workspaces: update Flint on every machine that opens the vault.
Two copies of one vault
Section titled “Two copies of one vault”Every write records when it happened, and every delete leaves a tombstone: the kind of record, its id (a random id, or a known host’s address) and the time. Nothing else of the deleted row is kept, so a removed password is gone from the file. A host’s tags go with the host, and removing a host leaves a tombstone for each of its tunnels.
With those, two copies of the same vault, changed apart (a cloud folder’s conflict copy, or later a remote vault), merge record by record:
- A record changed on both sides keeps the newer write. Two writes of the same millisecond are settled by their content, so both machines keep the same one.
- A delete at least as new as every edit of the record wins; an edit after the delete brings the record back.
- Every other record is kept, whether Flint shows it or not (revoked tokens, keys of servers no saved host points to).
- A workspace is one record: its name, layout, divider positions and places merge as a whole. A place whose host was removed keeps the host’s id and opens as an empty pane.
- Then the vault’s own rules: a name taken on both sides (an alias, a key or credential
name, a tunnel name in its host, a workspace name) is kept by the record written first, and the other is
renamed
web-01-2(a group or a workspace,Prod (2)). A reference to a record gone (a host’s group, jump host, credential or key; a credential’s key) is cleared, a tunnel whose host is gone goes too, and two groups moved under each other are cut apart at the one moved last. A record the merge changed this way reads as written just after its last write, so the change carries over when the other copy merges back.
Both copies must be the same vault (the same id) under the same master password: sealed secrets move from one to the other as they are, and nothing is decrypted to merge. The times are each machine’s clock: a machine whose clock is far off can win an edit it made earlier. A write never records a time older than the one it replaces.
The keychain
Section titled “The keychain”With Remember on this computer ticked at unlock (off by default), the master key, not
the password, is what Flint keeps in the OS keychain. It is stored
as a generic password with service Flint and account vault-<salt in hex> (a new master
password moves it to the new salt’s account). On macOS
it goes in your login keychain, which does not sync to iCloud. On Linux it goes in the
Secret Service’s default collection. Unticking the box, Forget on this device and
flint vault lock delete it.
What this protects against
Section titled “What this protects against”- Someone with the file (a cloud provider, a stolen backup) learns its size and the salt, and nothing else. To read it they must guess the master password, and each guess costs a 256 MiB Argon2id run.
- Someone with your unlocked user session can use a remembered key, as they could use
any logged-in app. Leave Remember on this computer unticked on machines you do not
fully trust, or set
FLINT_KEYCHAIN=off.