Skip to content

Security: keep enrolled LUKS2 tokens from passing LUKS key checks - #275

Merged
maralcbr merged 1 commit into
mainfrom
mac/sec-luks-token-keys
Sep 25, 2026
Merged

maralcbr merged 1 commit into
mainfrom
mac/sec-luks-token-keys

Conversation

@maralcbr

Copy link
Copy Markdown
Owner

Security fix for the frozen branch. It is the same fix as omacom#549.

cryptsetup open --test-passphrase tries every enrolled LUKS2 token that needs no PIN (TPM2, FIDO2, keyring) before the key it was given, and reports the token's slot whatever that key was. Here it decided which slot a password opens and whether it opens the disk:

A token a previous owner left behind therefore passed for any password. Provisioning could record the token's slot as the owner's, and the generic re-key could keep only that slot and kill the owner's new one. Slot listings also counted luks2-keyring token lines as keyslots, including in omarchy-apple-silicon-boot-check.

Key checks now pass --token-type passphrase-only (a type no token has), or compare the slot a key opens with the slot it should hold. Slot listings read only the Keyslots: section. luks_slot_for now also runs cryptsetup under LC_ALL=C, since it parses cryptsetup's English output.

Testing

  • drive-password-test.sh runs against a real file-backed LUKS2 volume with an imported systemd-tpm2 token and a live luks2-keyring token, whose key is in the session keyring. The test first shows that a bare open with a wrong key reports the token's slot. It skips where the kernel keyring is out of reach.
  • Fake-token cases cover provisioning (owner slot, a resumed run with a wrong password, a wrong recovery key, and a token numbered like a missing recorded slot), factory reset and the boot check's luksDump parse.
  • Each production change was reverted one at a time, and a test fails for each one. The one exception is the factory-reset slot listing, where the old parse was not wrong.
  • ./test/all as a non-root user in an arm64 Arch container (cryptsetup 2.8.8, seccomp unconfined so the live token runs): the only failures are the same 4 environment failures as origin/main (no omarchy-pkgs checkout, Plymouth publish). The targeted files were rerun after the last test additions.
  • Not run: hardware, or a real TPM2 or FIDO2 token.

Second review: no problems found in the production code. The two missing tests it raised (the slot listing in omarchy-provision-owner, and the resumed-run owner check) were added. Fable re-check owed.

cryptsetup open --test-passphrase tries every enrolled LUKS2 token that needs
no PIN (TPM2, FIDO2, keyring) before the key it was given, and reports the
token's slot whatever that key was. First-boot owner provisioning, the Apple
re-key verification, factory reset and omarchy-drive-password all used it to
decide whether a password opens the disk and which slot holds it, so a token a
previous owner left behind passed for any password: setup could record the
token's slot as the owner's and never add the owner's password.

Key checks now allow only a token type no token has, or compare the slot a key
opens with the slot it should hold. Slot listings read only luksDump's
Keyslots section, since a luks2-keyring token line looks like a keyslot.
@maralcbr
maralcbr merged commit 23a31df into main Sep 25, 2026
5 checks passed
@maralcbr
maralcbr deleted the mac/sec-luks-token-keys branch September 25, 2026 14:47
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