trackslash
VAULT-119 P1 For an agent

Mac app: unlocking loops back to the lock screen, so Vault can't be unlocked

0
All issues

Description

Found by Bradley on the Mac app. With App Lock on, coming back to Vault after it has locked never gets past the lock screen. The Touch ID or password dialog appears, and Vault locks again behind it. When the dialog goes, Vault starts unlocking again, the dialog comes back, and Vault locks again, over and over. There's no way to unlock it once it's in the loop.

Likely cause

Not confirmed yet. On macOS, the LocalAuthentication dialog (Touch ID or the Mac's password) belongs to the system, not to Vault, so Vault stops being the active app while it's showing. VaultMacLockTriggers treats NSApplication.didResignActiveNotification as leaving the app: it calls appLock.scenePhaseDidChange(to: .background). In AppLockService.didEnterBackground(), an app that's already locked locks again. That cancels the unlock underway (the lock generation changes) and sets startsUnlockWhenActive. So when the dialog closes, didBecomeActiveNotification starts a new automatic unlock, which shows the dialog, and the cycle repeats.

On iOS, the app's own Face ID prompt only makes it inactive, and AppLockService already allows for that (authenticationService.isAuthenticating). The Mac needs the same distinction. Vault's own authentication dialog coming to the front isn't the user leaving Vault. Going to another app while that dialog is up still is.

The Mac UI tests didn't catch it because they answer authentication with -ui-test-authentication allow, which shows no system dialog. So Vault never resigns active during an unlock in them.

To do

  • Reproduce on a real Mac: lock Vault, switch away and back (and try ⌃⌘L), with Require Unlock set to Immediately and to a delay.
  • Fix it so Vault's own authentication dialog doesn't lock or restart the unlock. Keep every lock trigger in docs/mac-app.md ("Locking") and G86: locking when another app comes to the front, when the screen locks or sleeps, and with Lock Vault.
  • Check the AutoFill sheet's lock observer (VaultMacAutofillLockObserver, VAULT-113) for the same loop, since it also locks when Vault's sheet stops being active.
  • Tests: a VaultMacLockTriggersTests case where Vault resigns active while its own authentication is underway, and the unlock finishes and stays unlocked. Another case where the user goes to another app during the dialog, and Vault locks. If possible, make the UI tests' fake authentication resign the app's active state the way the real dialog does, so a UI test covers it.
  • Update G86 in docs/security-model.md and "Locking" in docs/mac-app.md if the rules change.

Done when

Vault on the Mac unlocks with Touch ID or the Mac's password, then the App Lock Password, every time, with no loop. It still locks on every trigger it locks on today.

GitHub

0

No branches or pull requests linked.

Comments

1
Bradley

Fixed in https://github.com/badbundle/vault-app/pull/726 (merged as 004a9f3a).

  • Cause: as suspected. macOS shows Touch ID and the Mac's password from a process of its own, so Vault stops being the active app while its own prompt is up. VaultMacLockTriggers took that for the user leaving. Vault locked again behind the prompt, threw its answer away, and started unlocking again when it came back, over and over. With Require Unlock at Immediately, the prompt for a locked item, a backup or a setting locked the whole app the same way.
  • Fix: while Vault's own prompt is up, Vault stopping being the active app makes it only inactive, as the iOS app is under its own Face ID prompt. An ordinary app other than Vault coming to the front is still leaving, and locks as before: either the app in front as Vault stops being active, or one that comes to the front afterwards. The agents that show Touch ID and the Mac's password aren't ordinary apps. The AutoFill sheet's lock observer follows the same rule.
  • Tests: new VaultMacLockTriggersTests and VaultMacAutofillLockObserverTests cases. With the fix turned off, the unlock test fails as Bradley saw: a second prompt, still at the Touch ID step.
  • Docs: docs/mac-app.md ("Locking", AutoFill), G86 and G95 are updated. RELEASE.md's Mac checks now unlock with real Touch ID and with the Mac's password, open a locked item with Immediately, and leave during the prompt.
  • Validation: validated with VAULT_SKIP_MAC_UI_TESTS=1 (VAULT-120), as the Mac was locked. The Mac UI tests haven't run on this commit, and real Touch ID hasn't been tried. Both are for when the Mac is next unlocked: a full make validate on main, then RELEASE.md's Mac locking checks.