Files
CustosPublic/docs/THREAT_MODEL.md
T

66 lines
5.5 KiB
Markdown

# Threat model
Custos keeps one person's (or one household's) secrets in one encrypted file on their own disk, synced
as a plain file (e.g. by Arca to their own Nextcloud). This page says what that protects against and,
just as plainly, what it does not.
## Assets
- The secrets in the vault: passwords, API keys, TOTP seeds, Wi-Fi keys, card numbers, notes.
- The master password and the 256-bit vault key it unwraps.
## What is protected
| Attacker | Has | Gets | Why |
|:--|:--|:--|:--|
| Thief or sync server | The `.custos` file (any number of old versions) | Item count and sizes roughly (the ciphertext length), the KDF parameters. Nothing else. | XChaCha20-Poly1305 over the whole body; titles, URLs and usernames are inside it too. |
| Offline guesser | The file and a GPU farm | One Argon2id evaluation (64 MiB, 20 passes by default, ≈ 0.75 s on a desktop CPU) per guess | A 4-word memorable password with digits (~65 bits) is out of reach; a weak master password is not. **The master password is the whole defence here.** |
| Tamperer | Write access to the file | Can destroy it, or roll it back to an older version they saw. Cannot change, reorder, add or remove items unnoticed. | The header is the body's AAD; each slot's parameters are its wrap's AAD. |
| Share server operator | Every share blob, its id, size, expiry, view count, the uploader's login and the recipients' IP addresses | Nothing of the secret | The key is in the link's `#fragment`, which browsers never send; the server stores ciphertext only (docs/SHARE.md). |
| Someone who gets a share link | The link (chat history, a forwarded mail) | The secret, if the share still has views left; with a password share, also one Argon2id evaluation (19 MiB) per password guess | That is what a link is. Use 1 view (the default): once it is opened, it is gone, and the sender learns about interception when the recipient finds it used. |
| Link-preview bot | The link, fetched by a chat app | Nothing; the view is not used | The page asks for a click on *Reveal* before it fetches the share. |
| Someone who crashes the machine mid-save | — | Nothing | Atomic save: temp file, fsync, rename; the previous version is kept as `.bak`. |
## What is NOT protected
- **A compromised OS or a malicious process running as you.** While the vault is unlocked, the key and
the decrypted items are in the app's memory. Malware with your privileges can read that memory, log your
keystrokes as you type the master password, or read the screen. No password manager defends against this.
- **A memory dump while unlocked** (crash dump, hibernation file, swap). Secrets are held in zeroizing types
and wiped when dropped, which shrinks the window; it does not close it. Copies may remain where the
standard library or the JSON parser moved a buffer, in the webview (the desktop app shows a revealed
value there), and in OS buffers. Use full-disk encryption (BitLocker) for the hibernation file and swap.
- **The clipboard.** A copied secret is readable by every process until it is cleared (30 s in the
desktop app), and by any clipboard manager that ignores the "exclude from history" marker.
- **Auto-type** sends keystrokes to whatever window has focus. The app re-checks the target window before
typing, but a window that steals focus at the wrong moment can receive them.
- **Device unlock (Windows Hello).** The blob on disk is only as strong as the device key behind it: anyone
who can make Windows Hello sign as you on that machine (your PIN, your face, or malware running while
you approve a prompt) can unlock the vault there. It does not help an attacker who has only the vault file.
- **Rollback.** Someone with write access to the synced file can replace it with an older version.
Custos does not detect that (there is no trusted counter to compare against).
- **Shoulder surfing and QR codes.** A revealed password or a shown QR code is readable by anyone who
can see the screen.
- **Metadata.** File size and modification times reveal roughly how much is stored and when it changed.
- **Side channels.** No effort beyond what the RustCrypto crates provide (constant-time tag comparison).
- **The web vault trusts the server that serves its code.** In the browser, the page, its JavaScript and the
WebAssembly come from the home server on every visit. Whoever controls that server (or its TLS
certificate) can serve a modified page that sends the master password away the next time someone unlocks
in the browser. The desktop app does not have this problem. Authelia keeps strangers out; it does not
protect against the server itself. The same holds for the share page and the recipient.
- **Browser memory.** In the web vault the key and the decrypted items live in WebAssembly memory, and a
revealed or copied value passes through JavaScript strings, which cannot be wiped. Lock (or close the tab)
when done.
## Design rules that follow from this
- No custom cryptography: Argon2id (`argon2`), XChaCha20-Poly1305 (`chacha20poly1305`), the OS CSPRNG
(`rand`'s `SysRng`/`getrandom`), `zeroize`. All RustCrypto / rust-random.
- Secret-holding types never print their contents: `Debug` and `Display` give `[redacted]` (tested).
- Errors never contain secret material; a wrong password and a tampered slot give the same error.
- The reader checks KDF parameters against fixed limits before running Argon2, so a crafted file cannot
make it allocate unbounded memory.
- Generated passwords take their randomness only from the OS CSPRNG, and their reported entropy counts only
the random choices (a fixed pattern like capitalisation adds nothing).