Repository navigation
soc: apple: sep: Touch ID lockout that a password re-arms, matched like a macOS prompt - #904
Conversation
…ssword After a few failed matches the enclave answers every MATCH_RESULT with status 0x1, and on macOS that is the point where it asks for the password. Here the driver reported it as a refused enclave step, libfprint as "the secure enclave refused a step", and Touch ID failed until a reboot, because nothing ever showed the enclave the secret again. Tell the lockout apart. A MATCH_RESULT of 0x1 now ends the verify with its own status, SEP_BIO_STATUS_LOCKOUT (8), and every verify after it is refused at once, without a capture, so the user is not asked to touch a sensor whose match would be refused anyway. The log says how many matches failed first. Re-arm it the way macOS clears it with the passcode. A new root-only node, /dev/sep-bio-rearm, takes SEP_BIO_LOCKOUT_STATE and SEP_BIO_REARM. fprintd holds /dev/sep-bio open, so the lockout needs a node of its own. REARM needs CAP_SYS_ADMIN and does nothing without a lockout; with one, it sets up the SCRD match credential again (SKS verifies the stored keybag secret into a new context) under the lock that verify, enrolment and deletion hold, and clears the lockout only when that succeeded. The driver never does this on its own: re-establishing the credential on the enclave's refusal would undo the lockout. Userspace calls it only after the user's password has been verified (pam_aurora_touchid and aurora-touchid-rearm, packaged with libfprint's aurora driver). Keep the lockout across a restart. The enclave forgets it (the lockout record restores as EmptyTolerated), and macOS covers that by asking for the passcode after every restart. Linux may offer Touch ID at the login screen, so a restart would hand out a fresh set of attempts. The driver records the lockout in /var/lib/aurora-sep-touchid-lockout.bin and keeps refusing after the next boot until a password re-arms it. A missing or unreadable record is no lockout: only root can remove it, and root can restart anyway. The interface version stays 5: the verify poll is unchanged, and older libfprint builds report status 8 as an unknown driver status. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Re-arming after a password set up a new SCRD match credential, but the enclave kept refusing matches: MATCH_RESULT still answered 0x1. The enclave ends a biometric lockout when the user's key bag is unlocked with its secret. Setting up a match credential does not do it. So REARM now follows the same order as a passcode unlock. It unlocks the designated bag with the stored secret, as activation already does before the restore. Then it sets up a new SCRD match context, and then saves the enclave's lockout record so that a restart does not restore the record from before the lockout. The lockout is cleared only when the unlock and the credential both succeed. The boot path's special unlock moves into a helper that both paths share. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Provision a Linux-owned KEK/VEK record pair on the first password re-arm, persist it atomically in the host-state store, and require an option-2 FV_UNWRAP_VEK before refreshing SCRD and saving lockout state. Carry the already-verified password through the root-only re-arm ioctl and wipe the request and returned opaque key. Add KUnit coverage for the three request layouts and persistent pair format. Assisted-by: LLM
On the MacBook Neo the password re-arm provisions its Linux-owned FV pair: FV_NEW_KEK (0x42) and FV_NEW_VEK (0x40) both answer status 0, and the option-2 FV_UNWRAP_VEK (0x41) of the new pair answers status 0 too, with a 0x98-byte reply image. That reply carries the same 64-byte opaque key as a volume unwrap. The re-arm decoder required a 32-byte key, read from the shorter macOS reply, so it threw away a successful unwrap as EMSGSIZE. The pair was never committed, every password re-provisioned a new one, and the caller reported only that the stored secret had not unwrapped the pair. Check the reply's shape instead of a fixed length: version 0, one complete key blob of 1 to 64 bytes, flags bit 0 and nothing after. The key is never copied out of the reply buffer, which is wiped on drop. Log each failure stage: the SKS status of a refused unwrap, a missing reply, the lengths and flags of an unusable reply (never key bytes), the errno seen by the sbio caller, and a missing or unreadable identity bag. A stored pair that the enclave refuses, or one that no longer decodes, is replaced by a newly proved pair instead of failing for good. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
touchid5: d826bc1 fixes the password re-arm failure seen with touchid4. A mailbox trace of the re-arm on the MacBook Neo showed that FV_NEW_KEK (0x42), FV_NEW_VEK (0x40) and the option-2 FV_UNWRAP_VEK (0x41) all answer SKS status 0. The 0x41 reply carries a 64-byte opaque key (a 0x98-byte image). The re-arm decoder only accepted the 32-byte macOS key size, so it threw the successful unwrap away as EMSGSIZE without saying why. The record pair was never saved, and the caller logged "the stored secret did not unwrap". The decoder now checks the reply's shape (version 0, one key blob of 1 to 64 bytes, flags bit 0, nothing after it) and never copies the key. Every failure stage is now logged without key material: the SKS status, a missing reply, the lengths and flags of an unusable reply, and the errno. A stored pair that the enclave refuses is replaced by a newly proved pair. KUnit: apple_sep_fv_rearm passes 7/7. The full Apple SEP suite is 157/161, with the same four known apple_sep_host_store failures as the base. The finger test on hardware is pending. 🤖 Generated with Claude Code |
…arms it On the MacBook Neo the enclave refused the third Touch ID attempt after two misses (MATCH_RESULT status 0x1 while the user lock state stayed clear), and no password step ended it: only a restart of the enclave did. A trace of a macOS 26.6.2 Touch ID prompt on the same machine (three wrong touches, the password in the same dialog, then a new prompt with an enrolled finger) shows macOS never reaches that refusal. Its three-try limit is LocalAuthentication's own and the enclave lock state stays clear. The request shapes match Linux; the per-touch sequence does not. Match the way macOS does: - Match in the LocalAuthentication class (match flags 0x88). The login window's keybag-unlock class (0x89) is not needed on Linux. - One match operation (OPERATION_DEVICE_LIST) and one unlock evaluation per prompt, i.e. per open of the Touch ID device, which fprintd claims for one PAM authentication. MATCH_CANCEL only when the prompt ends: on a match, at the retry limit, or when the next prompt, a password re-arm, an enrolment or a suspend ends it. - After a no-match, relay the further frames of the same touch (0x65, each followed by RETRY_CAPTURE_INFO 0x3e), then MATCH_RETRY_FINALIZE (0x0c) before MATCH_POLICY, so the touch counts as one result. - Save the enclave lockout record after every answered result. - Enforce the three-attempt limit on the host: after three failed matches in a row Touch ID refuses without a capture until a password authentication re-arms it, recorded across a restart. Also carried here from the test series: the password re-arm verifies the designated key bag in password mode and sets up the cold-match credential again; matches run under an unlock evaluation whose context is sent as the credential blob; the enclave's background operation results are collected and the catacombs saved after a template update (user, then master); the sensor stays registered between verifies; and MATCH_POLICY is read after every result. Tested on the MacBook Neo (J700) with a finger, twice: three misses in one sudo prompt each answered as a plain no-match, the host limit asked for the password, and the enrolled finger matched right after it without a restart. No-finger lifecycle gate, SELinux enforcing, 0 AVC. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
|
Gates on de6bc15 (buildbox, arm64 LLVM):
|
Brings aurora-wip up to the tested release branch: CTXR execmem (#985, #1079), KFIX speaker sleep and resume fixes (#1077, #1080), JPEG v2 (#1072), Jonathan's G17 and USB work (#1073-#1076), brcmfmac flowring count (#1081), ANE H16 startup restart (#1066) and the Touch ID per-prompt match (#904). Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
On the MacBook Neo (J700), Touch ID locks after three wrong touches. That is normal; macOS does the same. The bug: on Linux the password never brought Touch ID back. The enclave kept refusing every match (
MATCH_RESULTstatus0x1, "refused after 2 failed attempts", user lock state clear) until the enclave was restarted by a reboot.Root cause
We traced a macOS 26.6.2 Touch ID prompt on the same Neo: three wrong touches, the password in the same dialog, then a new prompt with an enrolled finger. macOS never reaches the enclave's refusal at all. Its three-try limit belongs to LocalAuthentication ("Application retry limit exceeded"), and the enclave lock state stays
0x0228throughout. The request shapes were identical to ours (image init 167 bytes, frame relay, assessment, result, policy). The per-touch sequence was not:0x7d)MATCH_CANCEL(0x0b)0x65+0x3eeach), then0x0c, thenMATCH_POLICYMATCH_POLICYSAVE_LOCKOUT(0x70)0x88(LocalAuthentication class)0x89(login-window keybag-unlock class)What changes
This PR keeps the original lockout/re-arm design (status 8,
/dev/sep-bio-rearm, the lockout record across a restart). The last commit brings it in line with the macOS prompt:0x88);0x89is only for the macOS login window's keybag unlock, which Linux doesn't do.MATCH_CANCELis sent on a match, at the retry limit, or when the next prompt, a password re-arm, an enrolment or a suspend ends the old one.RETRY_CAPTURE_INFO(0x3e). Then comesMATCH_RETRY_FINALIZE(0x0c) beforeMATCH_POLICY, so the touch counts as one result. The names describe what the opcodes do; Apple's own names are unknown.SAVE_LOCKOUTafter every answered result.MATCH_POLICYread after every result.The test-only steps tried on the way (a bag lock before the re-arm, replaying boot-only SBIO steps) are not in the final tree.
Testing
sudo -k; sudo truewith pam_fprintd:0x0cstatus 0), and the enclave never refused.0x7dandMATCH_CANCELbalanced; catacombs unchanged; 0 driver errors; SELinux enforcing, 0 AVC.Userspace needs no change: Fedora's
pam_fprintdgives 3 tries per authentication, and the re-arm helper is unchanged.🤖 Generated with Claude Code