Skip to content

soc: apple: sep: Touch ID lockout that a password re-arms, matched like a macOS prompt - #904

Merged
RyanTheTide merged 7 commits into
integration/aurorafrom
fix/sep-touchid-lockout
Nov 7, 2026
Merged

RyanTheTide merged 7 commits into
integration/aurorafrom
fix/sep-touchid-lockout

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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_RESULT status 0x1, "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 0x0228 throughout. The request shapes were identical to ours (image init 167 bytes, frame relay, assessment, result, policy). The per-touch sequence was not:

macOS prompt Linux before
Match operation (0x7d) one per prompt, kept across touches one per touch
MATCH_CANCEL (0x0b) only when the prompt ends after every touch
After a no-match further frames of the same touch (0x65 + 0x3e each), then 0x0c, then MATCH_POLICY straight to MATCH_POLICY
SAVE_LOCKOUT (0x70) after every result only at a re-arm
Match flags 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:

  • Match class. Every match uses the LocalAuthentication class (0x88); 0x89 is only for the macOS login window's keybag unlock, which Linux doesn't do.
  • One prompt = one match operation. A prompt is one open of the Touch ID device; fprintd claims it for one PAM authentication. The match operation and its unlock evaluation stay open across that prompt's touches. MATCH_CANCEL is 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.
  • No-match tail. After a no-match, the driver relays the further frames the sensor queued for the same touch. Each is followed by RETRY_CAPTURE_INFO (0x3e). Then comes MATCH_RETRY_FINALIZE (0x0c) before MATCH_POLICY, so the touch counts as one result. The names describe what the opcodes do; Apple's own names are unknown.
  • Lockout record. SAVE_LOCKOUT after every answered result.
  • Three-try limit on the host. After three failed matches in a row, Touch ID refuses without a capture until a password authentication re-arms it.
  • Carried over from the test series: a password-mode verify of the designated key bag at the re-arm, with the cold-match credential set up again; the unlock evaluation context sent as the match credential; background operation results collected; catacombs saved user-then-master after a template update; the sensor kept registered between verifies; MATCH_POLICY read 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

  • MacBook Neo (J700), with a finger, twice (fleet20 + this tree), using sudo -k; sudo true with pam_fprintd:
    • Enrolled finger matches.
    • Three wrong touches in one prompt each come back as a plain no-match. The no-match tail ran each time (0x0c status 0), and the enclave never refused.
    • The host limit asks for the password; the re-arm returns status 0.
    • The enrolled finger then matches right away, with no reboot.
  • No-finger lifecycle gate: boot in the recorded lockout with the identity restored; root re-arm; empty verifies with 0x7d and MATCH_CANCEL balanced; catacombs unchanged; 0 driver errors; SELinux enforcing, 0 AVC.
  • checkpatch: 0 errors; the only warnings are lines over 100 columns, which this file already has throughout. KUnit and W=1 results are in a comment below.

Userspace needs no change: Fedora's pam_fprintd gives 3 tries per authentication, and the re-arm helper is unchanged.

🤖 Generated with Claude Code

…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]>
RyanTheTide and others added 3 commits November 4, 2026 20:14
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]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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
@RyanTheTide RyanTheTide changed the title soc: apple: sep: Report the Touch ID lockout and re-arm it after a password soc: apple: sep: Touch ID lockout that a password re-arms, matched like a macOS prompt Nov 7, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Gates on de6bc15 (buildbox, arm64 LLVM):

  • KUnit apple_sep* (qemu arm64): 165/169. apple_sep_touchid_lockout passes, including the new no_match_tail_requests_are_empty and authenticated_match_carries_mode_and_context (0x88). The 4 failures are the apple_sep_host_store creation cases, which already fail on the base tree, so they are not from this change.
  • W=1 drivers/soc/apple/ with the fleet config: 0 warnings.
  • checkpatch --strict: 0 errors, 0 checks; the only warnings are 40 lines over 100 columns, a style the file already uses (98 such lines in the base).

@RyanTheTide
RyanTheTide merged commit e5a1f1d into integration/aurora Nov 7, 2026
3 checks passed
RyanTheTide added a commit that referenced this pull request Nov 7, 2026
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
@RyanTheTide
RyanTheTide deleted the fix/sep-touchid-lockout branch November 16, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant