Skip to content

Make the unlock assurance level a setting, chosen at tsm init with the TTL #25

Open

Description

@tashian

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:

  1. Unlock policy: biometric or device-owner.
  2. 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

  1. 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.
  2. Changes need the current policy. To change from biometric to device-owner, the user must first pass a fingerprint check.
  3. Headless detection. TouchIDAuth.canAuthenticate() uses canEvaluatePolicy to refuse cleanly with no GUI session (ssh, cron, CI). With .deviceOwnerAuthentication, canEvaluatePolicy is 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 run over ssh can wait for a dialog that nobody can see.
  4. 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 for biometric vaults.
  5. Plugin skill. Update plugin/skills/credential-usage/SKILL.md in 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 init checks if a vault exists (vault.status). If a vault exists, it stops immediately and tells the user to use tsm config set for the settings.
  • Give alreadyInitialized a specific error code.
  • If a recovery passphrase must be added to an existing vault, add a tsm config command for it. At this time, a user who did not set a passphrase during tsm init cannot add one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions