Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

The registration ceremony

Adding a passkey looks like one touch of a fingerprint reader, but behind it the server, the browser and the authenticator each add something the server will rely on at every later sign-in. This lesson opens the messages of a registration and the checks a server makes before it stores anything.

Adding a way back into an account

Ava is signed in to Lab Photos and opens her security page at https://auth.photos.example. She already has a security key there, and now she chooses Add a passkey so she can sign in from her phone and laptop without it. Her password manager asks for her fingerprint, and a moment later the page lists a new passkey. Security keys, passkeys, and biometrics described what happened in outline: her authenticator made a key pair and Lab Photos kept the public key. This lesson opens the messages that made it happen, because every check Lab Photos relies on later is set up here.

WebAuthn calls the exchange a ceremony, a word that includes the person as well as the software. There are three parties. Lab Photos' server is the relying party. Ava's browser is the client, and it is the only party that can see which website is asking. The authenticator holds the keys: a computer's or phone's built-in credential store, a password manager, or a security key. Ava's password manager is the authenticator this time.

Registration adds a new way into Ava's account, so Lab Photos treats it like a password change. It checks that the request comes from Ava's own session and asks her to sign in again if her last sign-in was a while ago. Someone who borrowed her unlocked laptop for a minute should not be able to add their own key and walk away with lasting access.

A registration at Lab Photos from the server's options to the stored public key. The private key and Ava's fingerprint stay on her device, and the server stores only what it has verified.

The options the server sends

When Ava chooses Add a passkey, the page's script asks Lab Photos' server how to proceed. The server answers with the creation options, which the script passes to navigator.credentials.create(), the browser function that starts a registration. Here they are in the JSON form browsers can read directly, with binary values written in base64url:

json
{
  "rp": { "id": "photos.example", "name": "Lab Photos" },
  "user": {
    "id": "P76oYjzHeIMH_he0IpY-elnmigO5e6ITTGrXPE5ttKY",
    "name": "[email protected]",
    "displayName": "Ava Archer"
  },
  "challenge": "pX4R1M8vUo0bmY3k2Ew7Qj6dTsL9fGh5aZcN0rKyVuI",
  "pubKeyCredParams": [
    { "type": "public-key", "alg": -8 },
    { "type": "public-key", "alg": -7 },
    { "type": "public-key", "alg": -257 }
  ],
  "timeout": 300000,
  "excludeCredentials": [
    { "type": "public-key", "id": "Kq3w9xY2bVd1nRtE7uLs0A", "transports": ["usb", "nfc"] }
  ],
  "authenticatorSelection": {
    "residentKey": "required",
    "userVerification": "required"
  },
  "attestation": "none",
  "hints": ["client-device"]
}

rp.id is the relying party ID, the domain the credential will belong to. It must be the page's own host or a parent of it that could be registered on its own, the registrable domain that Clients, servers, and addresses described. A page at https://auth.photos.example may use auth.photos.example or photos.example, but never the public suffix example and never an unrelated name such as photos-login.example. Lab Photos chooses photos.example, so the credential works on every site under that domain and on no other.

user describes the account. name and displayName are labels the authenticator shows when Ava later chooses between accounts. user.id is different. It is the user handle, the value the authenticator stores with the credential and hands back at sign-in to say whose account it is. The specification says it must not contain personal information such as a username or email address, because authenticators and password managers store it and may show or sync it. Lab Photos uses 32 random bytes made once for Ava's account; the limit is 64 bytes.

challenge is fresh random data for this one attempt. The server saves it together with the account it is for, its purpose (registration) and a deadline, five minutes here to match timeout, which is in milliseconds. pubKeyCredParams lists the signature algorithms Lab Photos accepts, in order of preference. WebAuthn names them by number from COSE, a standard for signing and encrypting small binary messages that plays the part JOSE plays for JSON: -8 is EdDSA, here with Ed25519, -7 is ES256, ECDSA with the P-256 curve that Digital signatures used, and -257 is RS256. The authenticator uses the first one on the list that it supports. Ava's password manager makes ES256 keys, so her passkey will be -7.

excludeCredentials lists the credentials Ava already has, here her security key. An authenticator that recognizes one of them refuses to make a second credential for the same account, and the browser tells Ava that this device is already registered. Without the list she could fill her account with duplicates from one device and never be sure which one to remove. The transports beside each ID say how the browser can reach that authenticator: usb and nfc for a security key, internal for one built into the device, hybrid for a phone nearby.

authenticatorSelection states requirements. residentKey: "required" asks for a discoverable credential, one the authenticator can find without being told its ID, which is what later lets Ava sign in without typing her address. userVerification: "required" asks the authenticator to check a PIN or biometric. attestation says whether Lab Photos wants evidence about the authenticator's make and model: none means it does not, and Attestation and authenticator models covers the other values. hints suggests which kind of authenticator to offer first, and browsers may ignore it.

What the browser adds

Before involving the authenticator, the browser checks rp.id against the page's origin and refuses outright if it does not fit. Then it writes down what it knows in a small JSON document called clientDataJSON. The server never sends this; the browser builds it. Decoded from base64url, Ava's reads:

json
{
  "type": "webauthn.create",
  "challenge": "pX4R1M8vUo0bmY3k2Ew7Qj6dTsL9fGh5aZcN0rKyVuI",
  "origin": "https://auth.photos.example",
  "crossOrigin": false
}

type separates a registration (webauthn.create) from a sign-in (webauthn.get), so an answer made for one cannot be passed off as the other. challenge is the server's challenge, copied back. origin is the scheme, host and port of the page that called the browser function, as the browser saw it. crossOrigin is true when the call came from an embedded frame of another origin, and then a topOrigin member names the page around it.

The origin is the heart of a passkey's phishing resistance. A lookalike page at https://photos-login.example could copy Lab Photos' options word for word, but the browser would refuse the relying party ID photos.example there, and any client data it did produce would name the wrong origin. Ava cannot be talked into getting the origin wrong, because she never types it.

The browser hands the authenticator a SHA-256 hash of clientDataJSON, together with the relying party ID, the user details and the requirements. The authenticator asks for Ava's fingerprint, makes a new P-256 key pair for this relying party and account, and keeps the private key.

Inside the authenticator data

The authenticator describes what it did in a compact binary structure called authenticator data. Its layout is fixed, so you can read it byte by byte, with each byte written as two hexadecimal digits:

The authenticator data in Ava's registration, byte by byte
BytesFieldAva's registration
0 to 31rpIdHash, SHA-256 of the relying party ID6ddf25aa...3c58bfea, the hash of photos.example
32Flags0x5d, binary 01011101
33 to 36signCount, a signature counter00000000, zero
37 to 52AAGUID, the authenticator model's identifier16 bytes
53 to 54Credential ID length0010, 16 bytes
55 to 70Credential ID8ba26ae11c641a425d36a3fa8f79ab17
71 onwardCredential public key, as a COSE keyAn EC2 key: kty 2, alg -7, curve P-256, and its x and y coordinates

The flags byte packs six yes-or-no answers into single bits, numbered 0 to 7 from the right. A bit set to 1 means yes:

The flags in the authenticator data, and which are set in Ava's 0x5d
BitFlagMeaningIn 0x5d
0UP, user presentSomeone interacted with the authenticator, such as a touchSet
2UV, user verifiedThe authenticator checked a PIN or biometricSet
3BE, backup eligibleThe credential's provider may copy it to other devicesSet
4BS, backup stateThe credential is currently backed upSet
6AT, attested credential dataThe AAGUID, credential ID and public key followSet
7ED, extension dataExtension results follow the credential dataNot set

Bits 1 and 5 are reserved. 0x5d is bits 0, 2, 3, 4 and 6: the credential was made with presence and verification, Ava's password manager syncs it to her other devices and has already backed it up, and the credential data follows. A credential that stays on one device, such as a passkey on a security key, leaves BE and BS clear, and its flags byte reads 0x45. Synced passkeys, cross-device sign-in, and recovery explains what those two bits can and cannot tell a server.

The signCount starts at zero here; the next lesson explains what an authenticator does with it at sign-in. The credential ID names this credential from now on. In a sign-in, the browser reports which credential answered by its ID, and Lab Photos looks up the matching public key. The public key itself is written as a COSE key, a small map of numbered fields: the key type (kty 2 means an elliptic curve key), the algorithm number from pubKeyCredParams, the curve, and the two coordinates that make up a P-256 public key.

The attestation object

For a registration, the authenticator data travels inside an attestation object. It is encoded in CBOR, a binary format with the same building blocks as JSON (maps, lists, text and numbers) plus raw bytes, which keeps it small enough for a security key to produce. The COSE key above is CBOR too. Written in CBOR's text notation, where h'...' marks raw bytes in hexadecimal, the attestation object is a map with three entries:

text
{
  "fmt":      "none",
  "attStmt":  {},
  "authData": h'6ddf25aa25cae088...'   (the bytes in the table above)
}

fmt names the format of the attestation statement, and attStmt holds the statement itself: a signature over the authenticator data by a key that belongs to the authenticator's maker, with the certificates needed to check it. Lab Photos asked for none, so the format is none and the statement is empty. The browser returns two base64url values to the page, clientDataJSON and attestationObject, along with the credential ID and the transports the authenticator supports.

Notice what is missing. Nothing in the response contains Ava's fingerprint, her phone's PIN or the private key. The UV flag is the only trace of the fingerprint check, and Lab Photos relies on that bit because the authenticator vouches for it, not because the server saw anything.

Store only after verification

Lab Photos' server now checks the response against what it saved before the browser was involved. Section 7.1 of the WebAuthn specification lists the steps. A maintained WebAuthn library performs them, and it helps to know what they are:

  1. Decode clientDataJSON. type is webauthn.create, challenge equals the saved challenge of this account's pending registration, and origin is one Lab Photos expects, here https://auth.photos.example. The deadline has not passed and the challenge has not been used.
  2. Decode the attestation object. rpIdHash equals SHA-256 of photos.example.
  3. UP is set. UV is set, because Lab Photos required verification. BS is not set without BE.
  4. The public key's algorithm is one of those offered in pubKeyCredParams.
  5. The attestation statement is valid for its format and acceptable under Lab Photos' policy. With none there is nothing to check, and nothing is learned about the model.
  6. The credential ID is at most 1023 bytes and is not already registered to any account. If it is, the ceremony fails.

Only then does Lab Photos store a record: the credential ID, the public key, the signCount, the transports, the BE and BS flags, a label Ava can recognize and the link to her account. The challenge is marked as used in the same step, a single change that either happens completely or not at all, so a response submitted twice, even at the same moment, cannot add the credential twice.

Each check answers a different attack. The challenge and its deadline stop an old response from being replayed. The origin and the rpIdHash stop a response made for another site. The account saved with the challenge stops an attempt started in Ava's session from being finished in someone else's: if Cora signs in on the same browser before the response arrives, the challenge still belongs to Ava's account, and the server refuses to store a passkey for Cora with it. The duplicate check catches a credential ID that is already registered, which would leave two accounts claiming one key. And nothing is stored on any path that fails.

Registration gives Ava a way to authenticate. It does not prove who she is in the legal sense, and it grants her no new permission.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

Lab Photos is choosing the value for user.id in its creation options for Ava. Which value fits the specification? 1 of 3

Choose one answer.

Ava's registration arrives with the flags byte 0x5d in its authenticator data. What does that tell Lab Photos? 2 of 3

Choose one answer.

A lookalike page at https://photos-login.example copies Lab Photos' creation options word for word, including rp.id photos.example. What happens when Ava tries to add a passkey there? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity