Repository navigation
Description
Problem
tsm unlocks the vault only with a fingerprint. TouchIDAuth uses the policy .deviceOwnerAuthenticationWithBiometrics. When Touch ID is not available, the user cannot unlock the vault. For example, Touch ID is not available when a Magic Keyboard with Touch ID loses its pairing and the lid is closed, or when Touch ID is locked after too many failed attempts.
The only other path is the recovery passphrase (tsm init --recover). This path has these limits:
- The user must set the passphrase during
tsm init. It is optional. - It needs an interactive terminal.
- It works only when the daemon has not loaded the vault. If another session is unlocked, the daemon ignores the passphrase and requires Touch ID.
Recommendation
Make the assurance level a vault setting. Let the user select it during tsm init, together with the TTL.
Unlock policy setting
Two values:
| Value | LocalAuthentication policy | Result |
|---|---|---|
biometric (current behavior) |
.deviceOwnerAuthenticationWithBiometrics |
Fingerprint only. |
device-owner |
.deviceOwnerAuthentication |
Touch ID first. The dialog also has a "Use Password…" button. If Touch ID is not available or is locked, macOS asks for the login password. If Apple Watch unlock is on, the watch also works. |
With device-owner, a person who knows the Mac login password can unlock the vault. The user must make this decision. Do not make it the default without a decision.
Optional: apply the setting only to vault unlock. Keep the fingerprint-only check for secrets with "confirm": true.
tsm init asks for the settings
After the recovery passphrase question, tsm init asks:
- Unlock policy:
biometricordevice-owner. - TTL (Go duration, default
30m).
Add flags for non-interactive use. For example: tsm init --unlock-policy device-owner --ttl 1h.
Add tsm config set unlock-policy <value> so that the user can change the setting on an existing vault.
Design points
- Where to store the setting. The TTL is in the encrypted vault payload. The daemon must know the unlock policy before it decrypts the vault, so the policy cannot be only in the encrypted payload. Possible solution: keep a plaintext copy in the envelope to select the policy, and an authenticated copy in the payload. After decryption, compare the two values. If the plaintext value is weaker, lock the vault and show an error. This prevents a downgrade by a person who can write the vault file.
- Changes need the current policy. To change from
biometrictodevice-owner, the user must first pass a fingerprint check. - Headless detection.
TouchIDAuth.canAuthenticate()usescanEvaluatePolicyto refuse cleanly with no GUI session (ssh, cron, CI). With.deviceOwnerAuthentication,canEvaluatePolicyis true when a login password is set, so this check does not find headless sessions. Use a different signal for headless sessions. If not,tsm runover ssh can wait for a dialog that nobody can see. - Error -32004. With
device-owner,authUnavailable(PR fix(tsmd): report why Touch ID is unavailable instead of "Authenticat… #24) almost never occurs. It must stay forbiometricvaults. - Plugin skill. Update
plugin/skills/credential-usage/SKILL.mdin the same change.
Related: tsm init on an existing vault
At this time, tsm init shows the recovery passphrase form first. Then it calls vault.init. The daemon refuses because the vault file exists (Vault.swift:110). The error is "Vault already initialized" with the generic code -32603. The vault and the Keychain key do not change, but the user filled in the form for no result.
Fix in the same change:
- Before the form opens,
tsm initchecks if a vault exists (vault.status). If a vault exists, it stops immediately and tells the user to usetsm config setfor the settings. - Give
alreadyInitializeda specific error code. - If a recovery passphrase must be added to an existing vault, add a
tsm configcommand for it. At this time, a user who did not set a passphrase duringtsm initcannot add one.
Activity