Skip to content

soc: apple: sep: Touch ID and password keys under a user's bag - #1767

Draft
RyanTheTide wants to merge 2 commits into
mainfrom
passkeys2/acl-and
Draft

RyanTheTide wants to merge 2 commits into
mainfrom
passkeys2/acl-and

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

SEP_KEY_CREATE_USER gains the other macOS key policies under a user's own bag, behind a new INFO.features bit SEP_KEY_FEATURE_USER_POLICIES (set with FEATURE_PASSWORD on the variant-5 key store):

  • SEP_KEY_CREATE_BIOMETRY_CURRENT_SET / _ANY: Touch ID only. SIGN_PASSWORD and UNSEAL_PASSWORD refuse these keys.
  • BIOMETRY_* | SEP_KEY_CREATE_DEVICE_PASSCODE | SEP_KEY_CREATE_AND (new bit 0x10): Touch ID and the bag's password. ock, okd and osgn each carry one flat constraint {cbio, cup: true, pkofn: 2}; oa and odel stay free.

An AND key is used through SIGN_PASSWORD / UNSEAL_PASSWORD. The call waits for a match like a biometric key; after the match the enclave verifies the bag's password into the same context (VERIFY_SECRET) and the one operation runs there. A refused password returns ENOKEY (EACCES stays a finger that did not match) and nothing runs. SIGN / UNSEAL refuse an AND key with EINVAL before a touch.

Self-test modes 13 (match only, needs a finger), 14 (password only) and 15 (neither) check that the enclave refuses each one-credential case on its own. The signing arm is the production SIGN_PASSWORD call.

Tests: new KUnit cases for the policy table, the AND list bytes (compared against the biometric list) and v2 handle round trips with the password-call and SIGN gating per policy.

Hardware: not yet run. Rows to run on the Neo and J616s: modes 14 and 15 (no finger), then mode 13 and SIGN_PASSWORD + touch (finger), plus a wrong password + touch (ENOKEY).

macOS lets a Secure Enclave key need both Touch ID and the device
passcode (.biometry* | .and | .devicePasscode), or Touch ID alone.
Under a user's own key bag /dev/sep-key only made .userPresence keys
(Touch ID or the password) and keys with no list, so a site rule like
"this bank needs my finger and my password" had nothing to map to.

SEP_KEY_CREATE_USER now also takes, when INFO lists
SEP_KEY_FEATURE_USER_POLICIES (it comes with the per-user bags):

 - SEP_KEY_CREATE_BIOMETRY_CURRENT_SET or _ANY: the biometric list the
   identity-bag keys already use, under the user's bag. The password
   calls refuse these keys.
 - one of those with SEP_KEY_CREATE_DEVICE_PASSCODE | SEP_KEY_CREATE_AND:
   the AND list. ock, okd and osgn each carry one flat constraint with
   the biometric clause (cbio), the user passcode clause (cup, true) and
   the required count (pkofn, 2). oa and odel stay free. This is the
   map the public flags builder writes; OR would be the same map with
   pkofn 1 and is not offered.

An AND key is used through SEP_KEY_SIGN_PASSWORD / UNSEAL_PASSWORD. The
call waits for a Touch ID match as a biometric key does; after the match
the enclave verifies the bag's password into the same context
(VERIFY_SECRET), and the one operation runs there. A refused password
fails the call with EACCES and the operation never runs. The kernel
holds the password only for the call and wipes it. SIGN and UNSEAL refuse
an AND key with EINVAL before asking for a touch, since they carry no
password.

The enclave enforces the conjunction from the key's list. Self-test
modes 13-15 check that: a match alone (13, needs a finger), the bag's
password alone (14) and neither (15) must each be refused by the
enclave, with the kernel's own refusal of SIGN bypassed. The production
SIGN_PASSWORD call with a touch is the arm that signs.

Version-2 handles carry the policy in their flags (HANDLE_BIOMETRY,
HANDLE_BIOMETRY_ANY, new HANDLE_AND_PASSCODE); the decoder takes only
the flag sets a policy makes. .devicePasscode alone stays reserved.

KUnit: the policy table (accepted combinations, EOPNOTSUPP without the
feature, malformed ones EINVAL), the AND list's exact bytes against the
biometric list, and handle round trips with the password-call and
SIGN gating for every policy.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
An AND call can fail on either credential. EACCES already means the
Touch ID match failed (or Touch ID is locked out), so a password the
enclave refuses after the match now returns ENOKEY. Userspace can then
ask for the password again instead of for another touch.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 2.

  1. The guarantee this PR adds is never shown. Whether an AND key needs both credentials depends on the enclave evaluating the flat {cbio, cup: true, pkofn: 2} constraint (key.rs:1019-1035) as two-of-two. The kernel only builds the list, and the KUnit cases check the bytes we wrote, not what the enclave does with them. If the enclave ignored pkofn or read the map as one-of-N, SIGN_PASSWORD would still succeed, and a key userspace was told needs a finger and a password would sign with just one of them. Self-test modes 13-15 exist to catch exactly that, and none has run. This needs the hardware row below before it leaves draft. The pass criteria have to include the refusals, not only the success case.
  2. Both commits carry an Assisted-by: LLM trailer. Commits should carry only the human Signed-off-by; the Assisted-by line belongs at the end of the PR body (already there).
  3. key.rs:1771 takes the password out of the job even when take_grant() returns None, and then drops it. If key_touch_sign() is ever called before the grant exists, the later call with the grant runs the operation without VERIFY_SECRET. The enclave then refuses it as EACCES (looks like "finger did not match") instead of ENOKEY. Take the password only when a grant is present.

The rest looks consistent: the policy parser rejects half-ANDs and OR forms; the version-2 handle decoder accepts only the flag sets user_handle_flags() makes; check_password_handle() refuses biometric-only and plain keys; SIGN/UNSEAL refuse AND keys before a touch; and INFO advertises FEATURE_USER_POLICIES under the same Variant5 condition that CREATE_USER checks (:2650, :2732).

HW row: on this head, Neo J700 and J616s, Touch ID enrolled, key_selftest=1 for the test boot only. Pass criteria: mode 15 (neither credential) refused; mode 14 (password only, verify status 0) refused by the enclave; mode 13 (match only) refused by the enclave; SIGN_PASSWORD + matching finger signs and the signature verifies against the public key; wrong password + finger gives ENOKEY; right password + wrong finger gives EACCES; SIGN on the AND handle gives EINVAL with no touch prompt; biometric-only user key signs with a finger and is refused by SIGN_PASSWORD; existing user-presence keys unchanged; 0 AVC, 0 failed units, no new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Closing for now: the two-credential guarantee was never shown on hardware; it can come back with the self-test rows on the Neo and J616s.

@RyanTheTide RyanTheTide reopened this Nov 22, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Reopened and kept as a draft; the comment above lists what it still needs before review.

This branch has not been deployed

No deployments
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