Vault security and recovery
onQ uses separate controls for the search-index session, individual prompt bodies, backups, and the operating-system keychain. They solve different problems.
Security layers
| Layer | Protects | Key source |
|---|---|---|
| Vault authentication | The local MongrelDB search index and per-vault state | Master password or generated keychain secret |
| Prompt lock | One selected body in .onq/locked/ | Fresh per-prompt key in OS keychain |
| Backup seal | Entire .onqbak payload | Optional independent archive password |
| Full-disk encryption | Files, app profile, caches, swap, and local backups | Operating system |
Vault authentication does not automatically encrypt ordinary Markdown prompt bodies. Unlocked prompts are portable plaintext files. Use prompt locks for selected bodies and full-disk encryption for broad device-at-rest protection.
Authentication modes
Authentication mode is chosen when a vault is created and recorded as password or keychain in .onq/auth-mode.
Master-password vault
The password:
- is supplied by the user;
- is never written by onQ;
- is combined with a random per-vault 32-byte salt;
- is processed with Argon2id;
- must be entered when the vault is opened in a new session.
Current Argon2id parameters:
| Parameter | Value |
|---|---|
| Memory | 64 MiB |
| Iterations | 3 |
| Parallelism | 4 |
| Output | 32 bytes |
The derived key is encoded and passed to the database-open path.
DANGER
There is no password recovery or reset flow. Losing the master password means losing access to the protected search index and its per-vault state. Portable unlocked Markdown files may still be readable directly, but that is not a substitute for a current backup.
Keychain vault
The no-password path:
- generates a 24-word English BIP39 phrase;
- derives a stable secret from that phrase;
- stores the secret under a per-vault key in the OS keychain;
- displays the phrase once and requires an explicit saved acknowledgment.
On normal launch, onQ asks the OS keychain for the secret and opens the vault without an onQ password prompt. The operating system may still require user login, keyring unlock, biometrics, or another platform approval.
The keychain service name is onQ. Per-vault entries are keyed from the vault's salt so several vaults can coexist.
Recovery phrase
The 24-word phrase belongs only to a keychain vault. It is not a recovery path for a password vault and does not recover per-prompt lock keys.
Use it when:
- a keychain entry was deleted;
- the operating-system profile was reset;
- the vault moved to another device;
- onQ reports Encryption key missing from system keychain.
Recovery flow:
- Open the affected vault root.
- Select Recover with recovery phrase.
- Enter all 24 words in order.
- onQ validates the BIP39 checksum and word count.
- onQ derives the secret and verifies it by opening the existing index.
- Only after successful open does onQ write the secret back to the keychain.
Store the phrase offline. Anyone with the phrase and vault files can derive the vault secret.
Prompt locks
Prompt locks protect selected bodies independently from vault authentication.
Lock flow
- A fresh random 32-byte data-encryption key is generated.
- The current body is encrypted with AES-256-GCM.
- The envelope is written to
.onq/locked/<prompt-id>.enc. - The key is base64-encoded and stored in the OS keychain as
prompt:<prompt-id>. - The Markdown body is cleared.
- Frontmatter is updated to
locked: true. - The search row removes plaintext body and character count while preserving the existing semantic embedding.
Metadata remains readable: ID, title, project, tags, favorite state, lock state, and timestamps.
Unlock flow
- Read the per-prompt key from the OS keychain.
- Read and authenticate the AES-GCM envelope.
- Restore UTF-8 body text to the Markdown file.
- Set
locked: false. - Remove the envelope.
- Delete the per-prompt keychain entry.
If the keychain entry is missing, onQ cannot decrypt that envelope. The vault password and recovery phrase do not derive prompt-lock keys.
Prompt-lock limits
Prompt locking does not scrub:
- metadata in the Markdown file;
- a semantic embedding already stored in the protected index;
- previous plaintext snapshots under
.onq/history/; - clipboard history from earlier copies;
- backups or external sync copies made before locking.
Delete sensitive history snapshots and old backups manually if your retention policy requires it. Test recovery before deleting any key material.
Auto-lock and manual lock
Lock vault and idle auto-lock clear the open Vault and database handles from process state. The UI returns to unlock.
Auto-lock policies:
- Lock on quit only, default;
- Idle timeout from 1 to 1440 minutes;
- Disabled.
Activity includes pointer input, keyboard input, and window focus. The policy is evaluated every 15 seconds.
Session lock does not rewrite unlocked Markdown bodies or clear the system clipboard. It protects the open index session, not every local copy of prompt text.
Security audit log
Audit logging defaults to enabled and writes local JSON Lines to:
.onq/audit.logAn entry contains:
{
"at": "2026-07-27T12:34:56Z",
"kind": "vault_lock",
"detail": "idle_auto_lock"
}Depending on the event, detail may expose a local path or prompt ID. The log never leaves the device through onQ, but it is included in full vault backups and any external sync of .onq/.
Disable logging from Settings > Vault when local audit metadata is not wanted.
Backup security
A full .onqbak archive contains the vault tree:
- unlocked plaintext Markdown bodies;
- history snapshots;
- prompt-lock envelopes;
- protected search index;
- audit log;
- installed plugins.
Use the optional archive password when the file may leave trusted encrypted storage. The archive password is not the vault password.
Keychain entries are outside the vault and are not included. A restored keychain vault needs its 24-word phrase when the original keychain entry is unavailable. Locked prompts need their separate per-prompt keychain entries.
Read Backups and portability for the full restore model.
Threat boundaries
| Scenario | onQ control | Remaining action |
|---|---|---|
Someone copies only .onq/search-index | Vault authentication gates normal open | Use a strong password or protected OS account |
Someone reads an unlocked .md file | None; body is intentionally portable plaintext | Use prompt lock or full-disk encryption |
Someone reads a locked .md file | Body is absent; envelope is separate | Protect keychain and old history/backups |
| Malicious process runs as the same user | Can often access files, clipboard, input, and process memory | Rely on OS isolation and endpoint security |
| Device is stolen while powered off | Depends on file state and OS storage | Enable full-disk encryption |
| Clipboard manager records a copied prompt | Outside onQ | Configure or clear clipboard history |
| Untrusted native plugin is enabled | Plugin shares onQ process privileges | Do not install it |
| Sync provider account is compromised | Synced vault copies are exposed according to their file state | Use provider encryption and sealed backups |
Recommended baseline
- Enable full-disk encryption.
- Use a strong unique vault password, or protect the OS keychain account.
- Store the 24-word phrase offline when using keychain mode.
- Keep audit logging only when its local trail is useful.
- Use prompt locks selectively and account for history copies.
- Password-seal backups that leave the device.
- Test a restore before relying on a backup routine.
- Install no untrusted native plugins.
Report a vulnerability
Do not open a public issue. Use GitHub private vulnerability reporting and include version, platform, reproduction steps, impact, and mitigation.