Security and access control
Rowel protects each vault with a password-derived key and keeps that key inside the native app session. It limits access through password checks, failed-attempt backoff, explicit locking, inactivity locking, and optional biometric release from the operating system's secure store. The detailed access sequence is described in Authentication and locking, while platform biometric and secure-store behavior is described in Biometrics and secure storage.
Access model
Vault keys
The vault key is the secret that opens the encrypted database and protects entry data. Password authentication derives it from the master password, while biometric authentication retrieves the same key material only after the device gate succeeds. The frontend does not receive the vault key or a complete decrypted vault; the native session owns the open store and clears the key when access ends.
References: src-tauri/…/session.rs• L54-68 src-tauri/…/vault.rs• L78-97
Device workspace access
The primary workspace acts as the device-level access point. Once its key is known, other workspace keys can be opened from local sealed copies, so one successful password or biometric proof can open the workspaces that belong to this device. These local copies do not replace each workspace's own password protection when the workspace moves to another device.
References: src-tauri/…/appkey.rs• L1-21 src-tauri/…/appkey.rs• L115-134
Password authentication
Password proof
Password unlock first restores a consistent vault state after an interrupted password change. It then reads the public key-derivation settings, derives a candidate key, and asks the encrypted store to verify it. Only a wrong key counts as an invalid password. File, schema, permission, or other open errors keep their own meaning so the system does not punish a correct password for a storage problem.
References: src-tauri/…/auth.rs• L48-77 src-tauri/…/auth.rs• L114-121 src-tauri/…/session.rs• L264-301
Failed-attempt backoff
The app records failed password attempts beside the vault. Three failed attempts are free; later failures add an increasing wait that reaches a five-minute limit. A live wait is checked before key derivation, and a successful unlock clears the backoff. Biometric unlock does not use this password counter because the operating system controls its own prompt limits.
References: src-tauri/…/auth.rs• L23-35 src-tauri/…/auth.rs• L78-129 src-tauri/…/auth.rs• L54-119 src/…/useUnlock.ts• L150-184
Vault locking
Explicit locking
Locking closes the active vault session and clears the in-memory key. It also clears the device workspace key ring, removes lock-scoped clipboard material, stops the old inactivity timer, and emits one lock event for the user interface. Manual lock, tray lock, failed recovery, and inactivity lock use this same end state.
References: src-tauri/…/session.rs• L196-257 src-tauri/…/auth.rs• L205-215
Inactivity locking
The inactivity lock protects an unlocked session after the configured idle period. User input and window focus changes restart the timer. Losing focus starts the timer on every supported platform, and returning after the full timeout locks the vault instead of granting a fresh period. Wall-clock time covers sleep and mobile app suspension, where a normal timer may not run.
References: src-tauri/…/autolock.rs• L15-37 src-tauri/…/autolock.rs• L83-176 src/…/auth.ts• L9-15
Lock-screen handoff
The lock screen waits for the native unlock result before showing the vault. It presents password errors separately from biometric errors and shows the password backoff countdown. After success it enters the main view only when the window is focused, which prevents a vault from appearing behind a native biometric prompt or a suspended mobile window.
The access handoff and its state transitions are covered in Authentication and locking.
References: src/…/useUnlock.ts• L23-44 src/…/useUnlock.ts• L135-185 src/…/lock.test.tsx• L94-170
Biometric access
Biometric enrollment
Biometric access is an opt-in shortcut for an already unlocked vault. Enrollment stores the primary workspace's opaque key material in the platform secure store and records which gate the platform selected. The app checks both secure-store support and biometric availability before enrollment, so the interface does not offer an action that cannot open the active workspace.
References: src-tauri/…/auth.rs• L316-356 src-tauri/…/secure_store.rs• L52-84 src-tauri/…/app.rs• L68-126 src/…/BiometricRow.tsx• L12-48
Biometric unlock
Biometric unlock retrieves the stored app key through its recorded gate, opens the primary workspace or an eligible local workspace key, and starts a normal unlocked session. A missing secure-store item clears the enrollment marker. A cancelled prompt or a temporary platform error keeps the enrollment so the user can try again without an unnecessary re-enrollment.
The full sequence and platform differences are described in Biometrics and secure storage.
References: src-tauri/…/auth.rs• L238-300 src-tauri/…/auth.rs• L302-314 src-tauri/…/secure_store.rs• L326-345 src-tauri/…/secure_store.rs• L542-579 src-tauri/…/appkey.rs• L115-155 src/…/lock.test.tsx• L84-170
Biometric gate types
The app reports the gate that the operating system exposes instead of inferring it from the platform name. Apple devices can report Face ID or Touch ID. Windows uses a Windows Hello key credential to gate access to the stored key material. Unsupported platforms do not expose biometric unlock.
References: src-tauri/…/biometrics.rs• L6-41 src-tauri/…/biometrics.rs• L79-131 src-tauri/…/secure_store.rs• L440-612 src/…/types.ts• L223-233
Native secure storage
Platform protection
The secure-store layer keeps vault key material opaque and lets each platform enforce its strongest available gate. Apple can use an OS-protected keychain item or an explicit biometric check before a plain keychain read. Windows stores only a blob wrapped by a key derived from a Windows Hello signature, so the blob is not useful without another Hello prompt. Other platforms report the feature as unavailable rather than store an ungated key.
On iOS, the shared keychain location also lets the AutoFill extension use the enrolled key. Older items can move to that shared location when they are read, while a cancelled or failed read is not retried through a second keychain location.
References: src-tauri/…/secure_store.rs• L1-37 src-tauri/…/secure_store.rs• L222-345 src-tauri/…/secure_store.rs• L357-409 src-tauri/…/secure_store.rs• L440-665
Recorded gate mode
Enrollment chooses one gate mode and records it beside the enrollment marker. Later retrieval uses that recorded mode only. It never silently changes from an OS-enforced gate to a weaker app-enforced check, and it does not try a different mode when the recorded item is missing. Re-enrollment first removes old mode data so stale key material cannot remain in another store slot.
References: src-tauri/…/secure_store.rs• L31-37 src-tauri/…/secure_store.rs• L177-190 src-tauri/…/secure_store.rs• L312-345 src-tauri/…/secure_store.rs• L542-579 src-tauri/…/storage.rs• L582-613
Key replacement
A master-password change replaces the key that biometric enrollment protects. When the primary workspace changes, the app re-stores the new material and records the newly selected gate. If that write fails, it removes the secure-store item and the enrollment marker. A change to another workspace does not invalidate an enrollment that still protects the primary key.
References: src-tauri/…/auth.rs• L495-525
Access lifecycle
The access lifecycle connects proof, session creation, use, and lock cleanup. This diagram shows the main path; the child page Authentication and locking covers the ordered transitions and recovery rules.
flowchart LR
S[Vault sealed] --> P[Password proof]
S --> B[Biometric gate]
P -->|valid key| U[Unlocked session]
B -->|retrieved key| U
P -->|wrong password| W[Backoff wait]
W --> P
U --> A[Activity or focus]
A --> U
U --> L[Manual or inactivity lock]
L --> S
The same session boundary protects both password and biometric entry. A lock clears the key ring as well as the active session, so a workspace opened through local key material does not remain available after the app locks.
References: src-tauri/…/auth.rs• L38-121 src-tauri/…/auth.rs• L238-300 src-tauri/…/session.rs• L212-257 src-tauri/…/autolock.rs• L105-176
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the persisted biometric gate marker aligned with the secure-store item selected at enrollment. Retrieval must not fall through to another gate mode.
- Keep every path that ends a session aligned with key-ring clearing, clipboard cleanup, timer disarming, and the single lock event.
- Preserve the distinction between an invalid password and a vault-open failure. Only the former may update password backoff state.
- When the primary key changes, update the biometric enrollment and all local workspace key wrappers that depend on the app key.
- Keep the lock screen's biometric availability tied to both platform support and an active workspace key that the enrolled app key can open.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Repeated wrong password attempts | Password unlock is refused for an increasing wait, up to five minutes. | Backoff is checked before key derivation and is reset after a valid unlock. |
| Vault file cannot open for I/O, schema, or permission reasons | The user sees the real open error and the attempt does not increase password backoff. | Only the store's wrong-key result maps to invalid password. |
| User locks the app or the idle period expires | The active key, local workspace keys, clipboard material, and session store are cleared. | All lock paths use the shared session lock operation. |
| Enrolled secure-store item is missing | Biometric unlock stops being offered until the user enrolls again. | Only a proven missing item clears the enrollment marker. |
| Biometric prompt is cancelled or the platform has a temporary error | The vault stays locked, but the enrollment remains available for another attempt. | Cancelled and non-missing secure-store errors do not clear the marker. |
| Primary workspace password changes | Existing biometric key material becomes stale. | The primary change re-stores the new key and gate, or removes the enrollment if the write fails. |
| A workspace key wrapper is stale or cannot be opened | Biometric unlock is not offered for that workspace. | The app validates the wrapper before reporting the workspace as biometric-openable. |
| A secure-store enrollment uses a gate mode different from its recorded marker | Retrieval fails instead of using a weaker or unrelated item. | Enrollment deletes old mode data and retrieval uses only the recorded mode. |
Key files
| File | Why to read it |
|---|---|
| src-tauri/…/auth.rs | Main native entry points for password unlock, lock, biometric unlock, enrollment, and password changes. |
| src-tauri/…/session.rs | Defines the in-memory vault session and the shared lock boundary. |
| src-tauri/…/auth.rs | Defines password backoff and recovery behavior around password changes. |
| src-tauri/…/autolock.rs | Defines inactivity and focus-based locking. |
| src-tauri/…/secure_store.rs | Defines platform secure-store gates, key wrapping, and the recorded enrollment mode. |
| src-tauri/…/biometrics.rs | Defines platform biometric availability and prompt results. |
| src-tauri/…/appkey.rs | Explains how the primary key opens eligible local workspaces. |
| src-tauri/…/storage.rs | Names the persisted markers and sidecars used by access control. |
| src/…/useUnlock.ts | Connects native unlock results to lock-screen states and user messages. |
| src/…/BiometricRow.tsx | Shows how enrollment availability and the selected gate are presented in settings. |