The authentication ceremony
A passkey sign-in proves that the private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner. behind a registered credential just signed something fresh, for this site, in this attempt. The server never sees the key. It checks a signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message. against the public keyThe half of a key pair that can be shared freely. It checks signatures made with the matching private key and can encrypt data that only that private key can decrypt. it stored at registration, and every value it compares is one it stored or chose itself.
Prove possession without sending the key
The next morning Ava opens Lab Photos' sign-in page at https://auth.photos.example, chooses Sign in with a passkey and touches the fingerprint reader. She never types her address. Behind that single touch, Lab Photos' server has to answer a precise question: did the private key that belongs to a credential it registered just sign something fresh, for this site, in this attempt?
Lab Photos cannot ask to see the key. It holds only what The registration ceremony stored: the credential ID, the public key, the user handle and the last signature counter. So it sends a new challenge and asks the authenticatorSomething a person controls and uses to prove control of an account, such as a memorized password, an app that generates one-time codes, or a security key. It counts only after it has been registered to that account. to sign it. A valid signature over that challenge proves possession without anything secret crossing the network, and the checks around the signature make sure the proof is for this sign-in and nothing else.
The signed answer the authenticator returns is called an assertion. The same three parties take part as at registration: Lab Photos' server as the relying partyAn application that accepts and relies on a sign-in from another service, the name used in OpenID Connect and for passkeys. SAML calls the same role a service provider., Ava's browser as the client, and the authenticator that holds her passkey.
The request options
Registration began with creation options passed to navigator.credentials.create(). A sign-in begins the same way with a different call: the sign-in page asks the server for request options and passes them to navigator.credentials.get(). They are much shorter than the creation options, because nothing new is being made:
{
"challenge": "Vb3qT9mXe2LkR7uNw4ZsY1oCh8fAjD6gPi0Ht5EyKcM",
"rpId": "photos.example",
"allowCredentials": [],
"userVerification": "required",
"timeout": 300000
}The server saves the challenge with its purpose (sign-in), a deadline five minutes away to match timeout, and the browser it was sent to, usually by setting a short-lived cookieA small value that a website asks the browser to store and send back with later matching requests. Cookies commonly carry a session identifier, so the site can recognize an ongoing sign-in without your password. with the options. rpId names the relying party whose credentials may answer, under the same rule as at registration: it must be the page's own host or a registrable parent of it, so auth.photos.example may ask for photos.example.
allowCredentials is empty, and that is what makes this a discoverable sign-in. The server does not yet know who is signing in, so it lets the authenticator offer any credential it holds for photos.example. This is why Ava registered a discoverable credential: her authenticator can find it without being told its ID. If she has two Lab Photos accounts on the same device, the browser shows both names and lets her choose.
The other style starts with the account. If Ava typed her address first, Lab Photos could look up her credentials and list their IDs, each with its transports, the ways the browser can reach that authenticator (internal for one built into the device, hybrid for a phone nearby, usb and nfc for a security keyA small physical device, plugged in or held near a phone or computer, that holds credentials and uses them to prove you have it. It is an authenticator that resists phishing.):
"allowCredentials": [
{ "type": "public-key", "id": "i6Jq4RxkGkJdNqP6j3mrFw", "transports": ["internal", "hybrid"] },
{ "type": "public-key", "id": "Kq3w9xY2bVd1nRtE7uLs0A", "transports": ["usb", "nfc"] }
]This style also works with non-discoverable credentials, which the authenticator cannot find on its own, such as a security key registered as a second step: given the ID, the authenticator recognizes its own credential. But it tells anyone who types Ava's address which kinds of authenticator she has, which is one reason discoverable sign-in is the usual choice for passkeys.
What comes back
The browser builds clientDataJSON again, now with type set to webauthn.get, so this answer can never be passed off as a registration:
{
"type": "webauthn.get",
"challenge": "Vb3qT9mXe2LkR7uNw4ZsY1oCh8fAjD6gPi0Ht5EyKcM",
"origin": "https://auth.photos.example",
"crossOrigin": false
}The authenticator finds Ava's credential, checks her fingerprint and produces the assertion. Its authenticator data is the short form, 37 bytes, because no new credential is being described: the 32-byte rpIdHash, a flags byte of 0x1d (UP and UV set, BE and BS set because her passkey syncs, AT clear) and a four-byte signCount. The authenticator then signs the authenticator data followed by the SHA-256 hashTurning data into a short, fixed-size value called a hash, in a way that cannot be reversed and where changing one character changes the result completely. Services store password hashes instead of passwords, and signatures are made over a hash. of clientDataJSON, using the private key it kept at registration. Ava's passkey is an ES256 key, so the signature is ECDSA with the P-256 curve. The page receives:
| Field | What it holds |
|---|---|
id | The credential ID, i6Jq4RxkGkJdNqP6j3mrFw |
clientDataJSON | The JSON above |
authenticatorData | The 37 bytes |
signature | An ECDSA signature over authenticatorData and the hash of clientDataJSON |
userHandle | P76oYjzHeIMH_he0IpY-elnmigO5e6ITTGrXPE5ttKY, the handle stored with the credential at registration |
Because the signature covers both pieces, nothing in them can be changed without breaking it. The browser's statement of the challenge and origin and the authenticator's statement of the relying party and flags are bound together under one key. The userHandle is how a discoverable sign-in says whose account the credential belongs to; it is the random value Lab Photos chose for Ava's account, not her address.
Checking the assertion
Section 7.2 of the WebAuthnThe W3C browser API that lets a website register and use public-key credentials, such as passkeys and security keys. The site sends a challenge, and the authenticator signs it with a key scoped to that site. specification lists the server's steps, and a maintained WebAuthn library performs them. In the order Lab Photos performs them:
- Open the saved challenge for this browser. It must exist, be for a sign-in, be unused and be within its deadline.
- Look up the credential by
id. IfallowCredentialswas not empty, the ID must be one of those listed. An unknown ID ends the attempt: the server has no public key to check the signature with, so a perfectly good signature from an unregistered key proves nothing. - Identify the account. In a discoverable sign-in the credential record names its owner, and the returned
userHandlemust equal that owner's handle. In an account-first sign-in, the credential must belong to the account that was named. - Decode
clientDataJSON:typeiswebauthn.get,challengeequals the saved challenge andoriginis one Lab Photos expects, herehttps://auth.photos.example. - In the authenticator data,
rpIdHashequals SHA-256 ofphotos.example, UP is set, UV is set if verification was required, and BS is not set without BE. - Verify the signature over the authenticator data and the hash of
clientDataJSONwith the stored public key. - Apply the signature counter rule, described below.
Then the server marks the challenge used, saves the new counter and the current BS flag, and only after all of that creates Ava's sessionThe ongoing connection between later requests and an earlier sign-in, so you are not asked for your password on every click. It is often tracked with a cookie holding an unpredictable session identifier..
Presence and verification in the flags
The UP and UV bits answer different questions. UP says someone was there: a touch on a security key, a tap on a prompt. UV says the authenticator checked that it was its owner, with a PIN, a pattern or a biometric. Ava's touch on the fingerprint reader produced both, so with BE and BS set for her synced passkey the flags byte reads 0x1d.
Suppose Lab Photos requires verification, but a security key that supports only touch answers instead. Its signature is genuine and its flags read 0x01. The browser normally stops this earlier, because userVerification: "required" tells it not to accept an answer without verification. The server checks the bit anyway, because it relies only on what is inside the signed data. A browser can be buggy or out of date, or a script can call the server directly without any browser; the flags cannot be changed without breaking the signature.
When UV is set, the authenticator has combined something Ava has, the device holding the key, with something she knows or is. That is why a verified passkey sign-in can count as two factors on its own, while a touch-only key is one factor. A sign-in that pairs a password with a touch-only key also uses two factors, the password and the key.
Signature counters
Registration stored a signCount of zero. An authenticator may increase that counter each time it signs, so the server can spot a cloned credential, a private key copied out of one authenticator into another: the two copies would count separately, and sooner or later one would report a counter lower than one the server has already seen. The rule in section 6.1.1 of the specification is simple. If the stored counter or the new one is not zero, the new one should be greater than the stored one. If it is not, the server cannot tell which copy is genuine, and it decides by policy what to do, from refusing the sign-in to recording a warning for review.
Ava's passkey syncs through her password manager and reports zero every time, as many do. A synced passkey lives on several devices at once, and a single counter cannot stay in order across them, so its provider reports zero. A counter of zero means the authenticator does not count, and the server must not treat it as a clone. In practice, counters help with some security keys that keep their key on one device and say nothing about synced passkeys, so they are evidence to record, not the defense that keeps a stolen key out.
One session for the intended account
Each check closes a different door. The consumed challenge means a captured assertion cannot be submitted again, even a minute later. The deadline means an assertion made and held for later is refused. The origin and rpIdHash mean an assertion made for another site never matches: a lookalike page at https://photos-login.example cannot even ask for a photos.example credential, because the browser refuses a relying party ID that is not the page's domain or a parent of it. The user handle and the credential record mean a valid signature from one person's passkey cannot open another person's attempt. If Ava's credential answers a sign-in that was started for Cora's account, the account in the attempt and the owner of the credential disagree, and the server refuses.
Two requests can arrive with the same assertion at the same moment, for example from a page that retries too eagerly. The server consumes the challenge in one atomic step, a single change that either happens completely or not at all, so only one of them can succeed. Every refused path ends without a session, and the person sees a short, general message rather than which check failed.
A successful assertion proves that Ava's authenticator took part in this sign-in for Lab Photos. It does not decide what she may do after signing in; the service's permissions do. And her account is only as strong as its weakest way in, so recovery and any remaining password path matter as much as the passkey.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Decode a passkey sign-in and see the server refuse what does not fitSign one account in with a passkey, decode the assertion and its counter, see an unstored key, a reused answer, an expired attempt and the wrong account refused, and watch another site get nothing.