CCyberwiki

Passkeys and WebAuthn

Passkeys and WebAuthn
TypeSign-in credential and browser API
Also known asFIDO2 credential, discoverable credential, WebAuthn credential
StandardsW3C Web Authentication (WebAuthn) Level 3; FIDO Alliance CTAP
OWASP Top 10A07:2025 Authentication Failures
ReplacesPasswords, or a password plus a one-time code
RequiresHTTPS, a supporting browser and an authenticator

When a user creates a passkey on example.com, their device generates a new key pair for that site. The private key stays in the device or the user's password manager; the site stores only the public key. To sign in later, the site sends a random challenge, the device signs it after the user unlocks it with a biometric check, a PIN or a pattern, and the site checks the signature against the public key it holds.12 The signature proves that the user holds the private key without any secret travelling over the network.2

Passkeys are built on the FIDO2 specifications.1 In a browser they are created and used through the Web Authentication API (WebAuthn), whose Level 3 edition became a W3C Recommendation on 25 August 2026.3 The API runs only on pages served over HTTPS.2

Registration and sign-in

WebAuthn calls the site the relying party and the device that holds the key the authenticator. An authenticator can be built into the browser or the operating system, such as Windows Hello, or it can be a separate security key on USB or Bluetooth.2

To register, the server sends the browser a challenge of at least 16 random bytes, plus the user's details and the site's name. Page code passes these to navigator.credentials.create(), and the authenticator, after the user consents, makes the key pair and returns the public key, optionally with an attestation, a signed statement about which model of authenticator made the key. The server confirms that the challenge is the one it sent and that the request came from the expected origin, then saves the public key against the account.2 Attestation is optional, and a site that reads it should not keep an allowlist of authenticator models.2

Sign-in uses navigator.credentials.get() with a fresh challenge. The authenticator signs it with the private key for that site, and the server checks three things: the signature against the stored public key, the challenge against the one it issued, and the relying party ID against its own.2 A passkey is a discoverable credential: the authenticator stores the user handle and credential ID next to the private key, so the user can sign in without typing a username first.4 For autofill, the username field gets autocomplete="username webauthn" and the page calls get() with mediation: "conditional" when it loads; once the user clicks the field, the browser lists the matching passkeys next to any saved passwords.2

Binding to the site

Every passkey belongs to one RP ID, a domain name. By default it is the domain of the page that created it; a page may instead name a parent domain, so login.example.com can register a passkey for example.com, but it cannot name example.net.3 The browser uses the credential only on origins that match its RP ID. The authenticator data that comes back with each signature contains a SHA-256 hash of the RP ID, and the server must compare it with the hash of its own.3

The RP ID binding makes passkeys phishing-resistant authentication. A Phishing page on a look-alike domain has a different origin, so the browser offers it no passkey for the real site, and any signature it obtains would not verify.32 The design also changes what a database leak exposes. A stolen table of public keys cannot be used to sign in, and unlike stored passwords the keys need no hashing.2 Credential stuffing has no reused secret to try.2

Presence, verification and syncing

The authenticator sets flags in its response. User Presence (UP) shows that someone touched the device, for example by pressing the button on a security key.4 User Verification (UV) shows that the device also checked a PIN or biometric. NIST requires verifiers to request UV as preferred and to treat a response without it as a single-factor credential.5 With userVerification: 'preferred' the flag can come back false; 'required' makes every sign-in multi-factor in one step, the device plus the PIN or biometric that unlocks it.6

Whether a credential may be backed up is fixed when it is created and reported in the same flags. A backup-eligible credential is a multi-device credential; one that is not is a single-device credential.3 Synced passkeys follow the user to a new phone through a provider's cloud sync or restore. Device-bound passkeys stay on one authenticator, typically a FIDO2 security key.4 A phone can also sign in on a nearby laptop over the FIDO "hybrid" transport: the laptop shows a QR code for the phone to scan.46 NIST treats a synced key as copied and therefore exportable. It allows synced passkeys at its middle assurance level, AAL2, provided the sync account itself is protected by multi-factor sign-in, and forbids them at AAL3.5

Authenticators may return a signature counter that rises with each use. A counter that fails to rise can mean a cloned key or a faulty authenticator, and the spec leaves the response to each site.3 Some platform authenticators, Touch ID on macOS among them, always return zero, and then the counter detects nothing.6

Server verification

A maintained library does the parsing and the signature checks. With @simplewebauthn/server in Node.js, the server keeps the challenge it issued, passes the expected origin and RP ID on every call, and stores the new counter afterwards:6

import { verifyAuthenticationResponse } from "@simplewebauthn/server";

const verification = await verifyAuthenticationResponse({
  response: req.body,
  expectedChallenge: savedOptions.challenge, // saved when the options were issued
  expectedOrigin: "https://example.com",
  expectedRPID: "example.com",
  credential: {
    id: passkey.id,
    publicKey: passkey.publicKey,
    counter: passkey.counter,
    transports: passkey.transports,
  },
});

if (verification.verified) {
  await saveUpdatedCounter(passkey, verification.authenticationInfo.newCounter);
}

The docs advise one database row per credential, linked to the user.6

Downgrade through other sign-in methods

A passkey protects only the sign-in that uses it. In August 2025 Proofpoint researchers built a page for the Evilginx adversary-in-the-middle kit that presented itself to Microsoft Entra ID as a browser the service does not support for FIDO sign-in, such as Safari on Windows. The real sign-in page then showed an error and offered the user's other methods; a user who picked an authenticator-app code had their password and session cookie relayed to the attacker, who loaded the cookie into their own browser.7 The method needs a second sign-in option on the account, which most admins keep for account recovery. Proofpoint had not seen it used in real attacks when it published.7 A stolen session cookie bypasses any sign-in method; Session hijacking covers that path.

Prompt for a coding agent

Review the passkey (WebAuthn) code in this project. Check that the server generates a fresh random challenge for every registration and sign-in, stores it server-side for that user, and rejects a response whose challenge does not match or has been used before. Check that every verification passes the exact expected origin (https, no trailing slash) and RP ID, that user verification is required where the passkey is the only sign-in step, that the public key, credential ID and counter are stored per credential, and that the counter is updated after each sign-in. Use a maintained library for parsing and signature checks rather than hand-written code. List the fallback sign-in methods that remain on an account with a passkey. Report each file and line you changed.

See also

References

  1. a b "FIDO Passkeys: Passwordless Authentication". FIDO Alliance.
  2. a b c d e f g h i j k "Web Authentication API". MDN Web Docs. Mozilla.
  3. a b c d e f W3C Web Authentication Working Group (25 August 2026). "Web Authentication: An API for accessing Public Key Credentials Level 3". W3C Recommendation.
  4. a b c d "Terms". passkeys.dev.
  5. a b "NIST SP 800-63B-4, Digital Identity Guidelines: Authentication and Authenticator Management". NIST (2025).
  6. a b c d e "@simplewebauthn/server", version 14.1.x. SimpleWebAuthn documentation.
  7. a b Miron, Y. (12 August 2025). "Don't Phish-let Me Down: FIDO Authentication Downgrade". Proofpoint Threat Insight.