CLI: unlock with a security key (FIDO2 hmac-secret) instead of the password #35
Loading…
Reference in a new issue
No description provided.
Delete branch "board/989-070253"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase 1 of #989 (board): on a computer that's already signed in, a FIDO2 security key such as a YubiKey can unlock the CLI instead of the password. It works per terminal, so touching the key is how a new terminal gets unlocked.
What it does
plaintext key add NAMEasks for the password once, then the key's PIN and three touches. The key must have a FIDO2 PIN.plaintext key lslists the keys.plaintext key remove NAME|--alldeletes this computer's copy for that key, or for all of them, and ends their sessions.plaintext unlockis new, and any other command in a terminal without a session now asks for the key's PIN and a touch when a key is set up. It falls back to the password when no key is plugged in, the touch times out, or anything else goes wrong.Design (also in DESIGN.md, "Security keys")
plaintext/v1/security-key ‖ account_id ‖ credential id. It is stored in the keychain next to the Secret Key.keyedin the terminal's stored session, soplaintext lockand unlocking in another terminal only forget it locally instead of logging it out, which would break the key. After 30 days, orsessions --end, or a password change (passwdnow ends every key's session), the next touch asks for the password once and reseals a fresh session under the same hmac output. That needs no second touch.script, a pty), and a same-user process could read the credential id and salt and talk to the key itself. With touch only, either could unlock on a stray touch.addchecks this with a third touch: it asks for the output without the PIN and refuses a key that gives the same one, as CTAP 2.0 keys do. A key that gives nothing without its PIN (alwaysUv) passes. A key that hides the credential without the PIN (credProtect 3) is refused with a clear message, since unlocking couldn't find it.plaintext:unlock, which no web origin can claim. Phase 2's sign-in factor will use the server host.passwdand sign-out end this terminal's session even when it is a key's.Crate:
ctap-hid-fido23.6hmac-secret: true, an excludeList (so adding the same key twice fails cleanly), and silentup=falseassertions.authenticatorwas rejected. It defaults to NSS crypto (crypto_rustexists), and it depends on unmaintainedserde_cbor, base64 0.21 and bitflags 1.webauthn-authenticator-rs/fido-hid-rswas rejected because it brings in OpenSSL and tokio.ctap-hid-fido2reaches it through hidapi'slinux-static-hidraw, and hidapi allows only one backend, so the pure-Rustlinux-native-basic-udevcan't be swapped in.fidocfg set incli/build.rs, are enabled only on macOS and on linux-gnu. The static musl release and windows-gnu build exactly as before:cargo treefor musl has no ctap/hidapi/libudev, and clippy for musl is clean in Docker. Those builds say "this build of plaintext can't use security keys". Windows has a second reason: only administrators can open FIDO HID devices, and everyone else must go throughwebauthn.dll.checkjob now installslibudev-dev.Linux permissions
On systemd distributions (Arch included),
60-fido-id.rulesand70-uaccessgive the user logged in at the seat access to/dev/hidraw*for FIDO devices, so no root is needed. On Arch,libfido2adds rules for other setups. The README says so. This still has to be confirmed on the Omarchy laptop with a real key; that is the manual end-to-end test that remains.Browser extension (investigation, nothing built)
chrome-extension://IDRP ID, and since Chrome 122 with any RP ID their host permissions cover.navigator.credentials.storage.sessionand its Secret Key sealed under the password instorage.local. A PRF unlock would seal the Account Key the same way this PR does.Apps (notes only; phones have biometrics)
Tests
core: sealing round-trips, and another output, another account id or another credential givesTampered.cliend to end over real HTTP, with a software authenticator (HMAC per credential, different with and without the PIN):end_sessionsends every key's session, ending this terminal's last, and then drops it here;lockdoesn't break the key;cargo clippy --all-targets -D warningsandcargo testpass on macOS and in Docker on Debian (linux-gnu, with the security key code).cargo clippy -p plaintext-cli --target *-linux-muslis clean too.🤖 Generated with Claude Code