Skip to content

Lesson 13 of 14 · 16m

Passkeys and WebAuthn

Challenge-response with per-origin asymmetric credentials ends phishing — synced vs device-bound is the real remaining decision.

The two ceremonies

Registration: the server sends a random challenge plus rp (relying party ID), user, pubKeyCredParams, and authenticatorSelection to navigator.credentials.create({publicKey}). The authenticator — TPM, Secure Enclave, YubiKey, phone — generates a fresh keypair scoped to that rp.id, signs an attestation, and returns the public key and credential ID. The server stores credential_id → public_key. Login: navigator.credentials.get({publicKey}) sends a fresh challenge; the authenticator signs challenge + origin + rpId and the server verifies against the stored public key. Challenge-response with asymmetric crypto, per-origin credentials, nothing shared to phish.

Why it's phishing-resistant where TOTP isn't

The binding is the mechanism: the browser asserts the current origin, the authenticator signs that origin into the assertion, and the credential itself is scoped to rpId. evil-bank.example asking for your bank.example passkey gets nothing — the authenticator refuses at the key-selection step. Compare TOTP (RFC 6238): a shared secret producing 6 digits you type — typing is replayable, and real-time relay kits (Evilginx, Modlishka-class AitM proxies) sit between user and site harvesting codes and session cookies live. Passkeys end that class entirely; there's no symmetric secret to relay.

Synced vs device-bound: the real decision

The authenticator data's BE/BS flags tell you whether a credential is backup-eligible — i.e., synced. iCloud Keychain, Google Password Manager, and Bitwarden sync passkeys across devices; a Windows Hello TPM credential or a YubiKey-resident key is bound to hardware and can't be exported. Synced passkeys' security inherits the cloud account syncing them — compromise of the iCloud/Google account replicates the credentials — and consumer attestation can't help you, because attestation: "none" is what the platforms return anyway. Device-bound proves hardware scope but converts lost device into account lockout unless you built recovery. The honest rule: synced for consumer convenience, device-bound plus attestation policy for admin surfaces and regulated environments.

The wrong mental model

"Passkeys are passwords stored in the device." They're asymmetric credentials, generated per-origin, that never leave the authenticator — nothing the server stores is replayable. And "device-bound is always more secure" — it's more scoped; the lockout-and-recovery cost is a product decision, not a free upgrade.

The parts that still break

userVerification: "required" forces the local gesture (biometric/PIN) — without it you're accepting possession-only assertions. Recovery is the actual product problem: passkey-only accounts need a second credential enrolled or a recovery path, because phones get traded in. Conditional UI (passkeys in the autofill sheet via mediation: "conditional") is the UX pattern that makes it usable in 2025. And WebAuthn Level 3 reached W3C Recommendation in April 2025 — the spec is done moving under you.

Two registration options that matter and get skipped: excludeCredentials — the credential IDs the user already has — prevents duplicate passkeys per account and stops the "same authenticator, five keys" mess. authenticatorSelection is where you state residency and verification policy (residentKey: "required" for discoverable credentials that identify the account by themselves; authenticatorAttachment to demand platform vs cross-platform hardware when you actually mean it). On the authentication side, allowCredentials lists which credential IDs are acceptable for this user — leave it empty and you get the discoverable-credential flow where the passkey itself says which user is signing in, which is the passkey-first UX Apple/Google push. Signatures also need the sign counter honored (signCount in authenticator data): a counter that doesn't move is a cloned-authenticator signal on devices that implement it.

What to actually do

Generate challenges server-side (≥128 bits, single-use, short-lived). Verify origin + rpId + signature server-side; store credential_id → pubkey → user. Require userVerification. Enroll at least two credentials before letting a user disable passwords, and keep a staffed recovery flow — that, not the ceremony code, is where passkey deployments die.

Keep reading

Related articles from the SudoSecurity blog.