Web and networkingDive 03 of 12

A passkey, from the button to the chip

Ana signs in without sharing a secret. Follow her passkey from a phone to a laptop, through the browser’s origin checks, a real signature, the USB frames and the hardware boundary that protects the key.

Levels
9
Reading
36 min
Depth
Idea to Silicon
Published

Ana’s passkey belongs to an address

Same face.
Different site.
No usable proof.

The phone can recognise Ana on both pages. The browser only lets her shop passkey answer for the real shop.

https://shop.example

Sign in with Ana’s passkey

RP ID: shop.example · eligible

0f59463c606c5b0e5d3da81f36e3f7c175ac230c60e75c2144ce3b752247607c

The signed rpIdHash must equal these 32 bytes.

https://shop-example.co

No credential for this site

Asking for shop.example is rejected by the browser.

382dabfbbb89aa3d6388852b89393b6e3e169ab523833e7a99ed91a195e99774

Using its own RP ID yields these unrelated 32 bytes.

The shop accepts a proof scoped to shop.example. The lookalike cannot request that credential; using its own RP ID also changes the signed hash.

Level 01/09Idea

A proof you cannot type into a fake site

Ana buys something at shop.example on her phone. At checkout, the shop offers to create a passkey. She approves with her phone’s screen unlock. Later, she opens the shop on a laptop that has never seen her account. She clicks Sign in with passkey, scans a QR code with her phone, approves there, and the laptop signs her in. The next morning she visits the shop on her phone and signs in directly. She has never invented, typed or transmitted a password.

There are three different stories hiding in those few gestures. The shop must learn that the returning person controls the credential it registered. The browser must stop other websites from borrowing that credential. And the phone must decide whether the person asking to use it is authorised. A passkey joins these stories without giving the shop a reusable secret.

With a password, the proof and the secret are the same string. A fake shop can ask Ana to type that string and immediately replay it at the real shop. A breach of another site becomes a threat if she reused it. Password hashing helps a server survive a database leak, but it does not change what Ana hands over during a login. A one-time code adds another check, yet a live phishing proxy can often relay it before it expires.

Public-key authentication changes the proof. At registration, an The component that creates credentials, checks user consent and produces signatures. It may be a phone’s credential provider, a platform component or a roaming security key. creates a key pair for the shop. The private key can make signatures; the public key can check them. The shop keeps the public key and an opaque credential identifier beside Ana’s account. At login it asks for a signature tied to a new random challenge. Learning that public key, or recording yesterday’s signature, does not give an attacker a way to answer tomorrow’s challenge.

That alone would still allow a phishing proxy to relay challenges. WebAuthn adds the website’s identity. A compliant browser supplies the calling origin and enforces the credential’s The relying party identifier: normally a domain string such as shop.example. It scopes credential use and is hashed into authenticator data.. The authenticator signs data containing a hash of the RP ID and a hash of the browser’s client data. A fake site cannot simply label itself as the real shop and borrow its credentials. The hero shows two real hashes, but the browser’s permission check is what prevents the wrong site from asking in the first place.

Ana’s phone

Private credential key + RP ID + account handle. Local approval authorises a signing operation.

Browser

Enforces the calling origin and RP ID relationship. Supplies fresh ceremony context to the authenticator.

Shop server

Account → credential ID → public key. Stores a pending random challenge, then verifies and consumes it.

Crossing the boundary

Public key at registration. Signed assertion at login. Neither the biometric template nor the credential private key is sent to the shop.

Ana’s secret stays on the credential side of the boundary. The shop stores the public half and checks a new proof on each return.

A credential, a device and a provider are different things

A passkey is a discoverable FIDO credential used for passwordless sign-in. Discoverable means the authenticator can find the account’s credential from the RP ID, without the server first naming its credential ID. It can offer Ana’s shop account before she types a username. A passkey may be device-bound or backup eligible and synced by a credential provider. The public-key protocol does not require cloud synchronisation.

A security key is a physical authenticator, usually carried separately and connected by USB or NFC. It can hold discoverable passkeys; it can also hold older, non-discoverable credentials used as a second factor after a password. Passkey versus security key mixes up a credential with a container. Ana could register one passkey in her phone’s provider and a second, independent one on a security key for recovery.

The threat model matters. Passkeys resist credential reuse and ordinary remote phishing by a different origin. They do not repair malicious code running inside the real shop’s origin, a stolen session cookie, an already compromised device or a weak account-recovery path. Local user verification protects use of a credential, but the site still has to secure its sessions and sensitive account changes. The WebAuthn security considerations describe those boundaries.

The shop learns that Ana controls its credential. It never receives a secret that could be typed into another website.

Check yourselfThe shop’s credential database leaks. Which item lets an attacker produce Ana’s next valid assertion?

Level 02/09Interface

Ask for a credential, not a password

The shop’s button does not talk directly to a secure element. It asks the browser to run a WebAuthn ceremony. The web API and the authenticator protocol are separate layers: WebAuthn defines the JavaScript interface and the server’s verification contract; CTAP defines communication with an authenticator where that boundary is exposed. A platform authenticator may use operating-system interfaces internally instead of sending USB packets.

Registration starts on an authenticated shop account. The server generates an unpredictable challenge, associates it with Ana’s session and the registration action, and sends options. WebAuthn recommends challenges contain at least 16 bytes of entropy; 32 random bytes is a convenient choice. A challenge is public, but it must be fresh and difficult for an attacker to predict. The server should expire it and accept it only once. A hardcoded challenge turns an interactive proof into a replayable one.

The options identify the relying party and the user. rp.id isshop.example; rp.name is a friendly display name.user.id is a stable, opaque byte string, at most 64 bytes, chosen by the server. It is not a username field and should not contain an email address or other identifying information. user.name and user.displayName are the human-readable labels Ana may see in a credential picker. This dive uses the five bytes of Ana-1 as an easy-to-inspect handle; a production system can use a random account identifier.

pubKeyCredParams lists acceptable public-key algorithms in preference order. COSE algorithm −7 is ES256, ECDSA on P-256 with SHA-256. −8 denotes EdDSA; the Ed25519 key used by the lab’s COSE parser has curve label 6. −257 is RS256, RSA PKCS#1 v1.5 with SHA-256. An authenticator chooses an algorithm it supports from the offered list. Offering one algorithm does not guarantee every platform can create it. The server must understand whichever algorithm it agrees to store.

authenticatorSelection.residentKey: "required" asks for a discoverable credential. "preferred" allows fallback; "discouraged" asks to avoid one where possible. userVerification independently says whether local verification is required, preferred or discouraged. Requiring UV means registration or login must fail if the authenticator cannot perform it. A biometric, a device passcode or a security-key PIN may satisfy UV. A touch that merely confirms presence does not.

Creation options · JSON boundary

Input to parseCreationOptionsFromJSON()

{
  "challenge": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8",
  "rp": {
    "id": "shop.example",
    "name": "Ana’s shop"
  },
  "user": {
    "id": "QW5hLTE",
    "name": "ana",
    "displayName": "Ana"
  },
  "pubKeyCredParams": [
    {
      "type": "public-key",
      "alg": -7
    }
  ],
  "authenticatorSelection": {
    "residentKey": "required",
    "userVerification": "required"
  },
  "excludeCredentials": [],
  "hints": [
    "client-device"
  ],
  "attestation": "none"
}

Challenge bytes 00…1f are a visible teaching constant here. A server must generate a fresh, unpredictable challenge for each ceremony. Domain syntax is checked; public-suffix eligibility is the browser’s job.

Valid options. User handle decodes to the five bytes “Ana-1”. No credential API is called.

Build the JSON representation of creation options. Change the byte handle, algorithm or policy and inspect the resulting dictionary.

excludeCredentials lists credentials that must not be created again on an authenticator that already recognises one of those identifiers. This helps prevent duplicate enrolment. It is not an account-wide ban on adding another authenticator: a different device can create another credential for the same account. Store transport hints with credential records when supplied, but do not treat them as authenticated facts about where the private key lives.

Level 3’s hints field lets an RP express a user-experience preference such as "client-device", "security-key" or "hybrid". These are guidance to the client, rather than a security policy. They cannot substitute for UV requirements or server verification. The browser may have a better idea of which available route will work for Ana.

JavaScript dictionaries use binary values for the challenge, user handle and credential IDs. JSON does not have an ArrayBuffer type. The Level 3 JSON conversion API bridges the boundary: PublicKeyCredential.parseCreationOptionsFromJSON() decodes base64url fields into the binary-valued dictionary, and a returned credential’s toJSON() produces its JSON representation. Encode bytes with the URL-safe alphabet, without padding. Serialising an ArrayBuffer with plain JSON.stringify does not perform this conversion.

Production API boundary · shown, never executed by these labs
// Server JSON -> WebAuthn's binary-valued dictionary
const publicKey = PublicKeyCredential
  .parseCreationOptionsFromJSON(serverOptions);

// In a production application, after explicit user intent:
const credential = await navigator.credentials.create({ publicKey });
const responseJSON = credential.toJSON();
// Send responseJSON to the pending registration endpoint.

Login uses navigator.credentials.get(). The server supplies another fresh challenge and an RP ID. An empty or omitted allowCredentials lets the authenticator discover suitable accounts; a populated list restricts the eligible credentials. mediation: "conditional" allows a supporting browser to offer discoverable credentials alongside autofill rather than immediately opening a modal. The username field uses an autocomplete token list ending in webauthn, for example username webauthn. Feature-detect support, keep other sign-in routes available, and cancel an obsolete request when the page’s flow changes.

Cancellation, a timeout, unavailable authenticators and policy failures all reject promises. Restore the sign-in control and announce a useful outcome; do not leave Ana stuck behind a spinner. NotAllowedError deliberately covers several situations, so avoid telling her that it proves no credential exists. These labs never call the credential API: the only authenticator they operate is software in this page. See creation options and request options for the full dictionaries.

Conditional sign-in · production shape
// Feature-detect conditional mediation before using this flow.
// The server supplies a new, session-bound challenge.
const publicKey = PublicKeyCredential.parseRequestOptionsFromJSON({
  challenge: serverChallengeBase64url,
  rpId: "shop.example",
  userVerification: "required",
  allowCredentials: []
});
const controller = new AbortController();
try {
  const credential = await navigator.credentials.get({
    publicKey,
    mediation: "conditional",
    signal: controller.signal
  });
  // Verify credential.toJSON() on the server.
} catch (error) {
  // Announce cancellation/failure and restore the sign-in control.
} finally {
  // Release busy state. A new attempt needs a fresh challenge.
}

Discoverability chooses how an account is found. User verification chooses what local approval is required. They are separate decisions.

Level 03/09Runtime

What the server must actually believe

When Ana registers, the browser returns client data and an attestation object. When she logs in, it returns client data, authenticator data and a signature, plus identifiers that let the server find the account and key. The server must treat all of this as untrusted input. A well-formed signature proves control of a key over particular bytes; it does not decide whether those bytes describe the login the server intended.

clientDataJSON is UTF-8 JSON written by the client. Its type distinguishes webauthn.create from webauthn.get. Its challenge is the server’s challenge encoded as base64url. Its origin is the calling origin. Modern clients can also reportcrossOrigin and, for cross-origin use, topOrigin. An RP accepting embedded ceremonies must validate that context deliberately. Ana’s simple shop permits only its top-level origin.

The authenticator produces a second structure. Its first 32 bytes are SHA-256 of the RP ID. A flags byte reports presence, verification, backup eligibility, backup state and whether more structures follow. A four-byte counter follows. At registration, this normally continues with the newly created credential’s identifier and COSE public key. The byte microscope later opens every one of these fields.

Authenticator bytes

rpIdHash · flags · signCount · optional extension outputs

Browser bytes

SHA-256(clientDataJSON), preserving the original UTF-8 encoding

Signed message

authenticatorData || SHA-256(clientDataJSON)

Shop decision

Verify that signature with Ana’s registered key, then apply ceremony, origin, challenge, account and policy checks.

The assertion signs a concatenation, not the challenge alone. Every byte of authenticatorData and the hash of the original clientDataJSON contributes to the signature.

Registration establishes the record

The §7.1 registration algorithm starts by decoding and checking the client data: type, challenge and allowed origin, including cross-origin context where applicable. Check the RP ID hash, UP and the requested UV policy. Validate the backup flags. Parse the attested credential data and ensure the returned public-key algorithm was offered. Check extensions according to the extensions requested. Then verify the attestation statement for its format and decide whether that attestation meets the RP’s trust policy.

fmt: "none" has an empty statement and no attestation signature. The shop can accept that policy, as many consumer sites do. It gains a credential public key, not proof of a manufacturer or security chip. Packed self-attestation signs the registration message with the newly created credential key; it demonstrates possession, but no independent manufacturer identity. Certificate-backed packed attestation uses an attestation key and certificate chain, with additional profile and trust requirements. They are three different evidence levels.

Finish registration by checking that the credential ID is not already associated with a different account and saving it with Ana’s public key, user handle, initial counter and backup eligibility. Bind this action to the account Ana was authorised to modify. An unauthenticated add passkey endpoint can give an attacker a perfectly valid credential on somebody else’s account.

Authentication uses the stored record

The §7.2 authentication algorithm first identifies the credential and its account. With a discoverable flow, validate the returned user handle against the stored account association; with an identified user, make sure the credential belongs to that user. Repeat the type, challenge, origin, RP hash, presence, UV and extension checks. Backup eligibility must match the registration record, while backup state can change. Finally verify the assertion signature with the registered public key and evaluate the signature counter.

Server verification · captured bytes

Captured RP: dev.dontneeda.pw. Signature verification preserves the original clientDataJSON bytes. A byte flip can survive none registration because none has no signed attestation statement.

  1. Ready to verifyChecks and signature results will occupy this reserved panel.

Choose a response and tamper mode, then run verification locally.

Run the context and signature checks on captured responses. Tamper with different parts to see which checks detect the change.

The signature must use the original client bytes. Parsing JSON and serialising it again can change key order, whitespace or escaping. The JSON values might be identical while the hash is different. Likewise, ES256 signatures in WebAuthn use ASN.1 DER encoding of the ECDSA integers r and s; WebCrypto’s ECDSA interface uses the fixed-width concatenation. The verifier converts that format explicitly rather than stripping a guessed number of prefix bytes.

Counters are a signal, not a universal monotonic clock. When either stored or returned signCount is nonzero, a value that does not increase can indicate a clone, a malfunction or an ordering race. The RP chooses its response. A credential can keep both values at zero, and synced credentials commonly do. Two devices sharing a credential cannot generally maintain a single globally ordered counter without coordination. Do not reject every synced passkey merely because zero is not greater than zero.

Use the lab below to generate a real key and complete both ceremonies. The page plays three roles: browser, software authenticator and shop verifier. Registration creates a none attestation object; authentication signs fresh challenges with ES256 and checks the signatures with the saved public key. The user-approval and backup flags are modeled. The cryptographic operations and byte structures are real.

Ana’s shop.example credential · software authenticator

No key exists yet. Registration creates a real P-256 key pair, a discoverable credential record and a CBOR none attestation object. The private key stays in memory until this page closes.
  1. Ready to registerThe server-side checks will appear here.

Register first. No platform prompt, persistent storage or network request is used.

The software authenticator sets UP/UV/BE/BS to model Ana approving a synced passkey. Those flags are simulated; WebCrypto signatures and every serialized byte are real. A nonextractable CryptoKey is not a secure element.

Create a fresh credential for Ana, then sign in repeatedly. Each login has a new random challenge; replacing the key replaces the account’s in-memory credential record.
Check yourselfA valid assertion arrives with the right signature but yesterday’s challenge. Should the shop accept it?

Level 04/09Runtime

The address is part of the security boundary

Ana’s phishing protection depends on two addresses that look similar in code but mean different things. An origin includes a scheme, host and port: https://shop.example. An RP ID is a domain string: shop.example. The browser validates their relationship; the authenticator receives the RP ID, and the server validates both. Checking only one loses part of the boundary.

By default, an RP ID must equal the calling origin’s effective domain or be a registrable domain suffix of it. A page at checkout.shop.example can ask for shop.example. A page at shop-example.co cannot. A domain owner also cannot choose an arbitrary public suffix such as com or co.uk and gain every site’s credentials. Registrability is determined with public-suffix rules, rather than a naïve string endsWith check.

This policy allows a shop to place checkout and account management on different subdomains while sharing an RP ID. It also means that choosing a broad RP ID deserves care. If an untrusted tenant controls a subdomain under that RP ID, browser eligibility alone may let it ask for the shared credential. The server’s exact origin allowlist is the second gate. It must not accept every caller merely because the credential’s RP hash matches.

Suppose a malicious page asks for its own RP ID instead. The browser may allow that request, but Ana’s existing shop credential is not eligible for the lookalike. Even if an attacker obtains a credential for the lookalike, its public key is not the one stored for Ana’s shop account, and its authenticator data carries a different RP ID hash. A signature is bound to the scope in which it was made. The address is not a label the page can silently replace after the fact.

Which address may ask for shop.example?

https://shop.example

Browser: RP ID is the caller’s host. Eligible. Server: exact expected origin matches. Accept after all other checks.

Selected: Shop itself. https://shop.example.

Apply the browser’s RP ID gate and the server’s origin gate separately. A port change affects the origin even though it leaves the RP ID unchanged.

Related origins are an explicit delegation

A global business may have genuinely separate domains: shop.example and shop.example.co.uk. WebAuthn Level 3 includes related origin requests to address that deployment. The owner of the chosen RP ID hosts an HTTPS JSON document at /.well-known/webauthn, listing the other permitted origins. A supporting browser can consult that document when the ordinary domain relationship fails.

This is a deliberate expansion of the trust boundary, not an exemption a phishing site grants itself. The document is hosted under the RP ID’s control. The server still checks the returned origin against its own allowlist. A successful browser eligibility check does not force the server to accept the assertion. Clients supporting the feature must support at least five registrable origin labels and can impose limits to resist abuse. Browser deployment and product policy can vary even when the feature is in a Recommendation.

A related-origin policy served by the RP ID owner
// https://shop.example/.well-known/webauthn
// Content-Type: application/json
{
  "origins": [
    "https://shop.example.co.uk"
  ]
}

An iframe adds another boundary. Permissions Policy controls whether embedded content may invoke WebAuthn features. The client data identifies cross-origin circumstances so the RP can decide whether that top-level embedding context is acceptable. An application that supports embedded authentication must define those rules; comparing only origin while ignoring an unexpected cross-origin context is insufficient. The verifier here takes the simpler policy of rejecting cross-origin ceremonies.

HTTPS protects how the page and its JavaScript arrive; origin binding protects which site can use the credential. They solve related but distinct problems. If an attacker controls the actual shop origin, perhaps through an injected script, the browser sees a legitimate caller. Passkeys do not cause it to distinguish the shop’s intended JavaScript from malicious JavaScript that runs with the same origin’s authority. Content security, deployment security and session protection remain essential.

The applicable reference here is WebAuthn Level 3, W3C Recommendation of 25 August 2026. Naming the dated version matters: older explanations often describe related origins as a proposal or say that credentials can never be used across different registrable domains. The default remains the domain rule, with this explicit opt-in route layered on top.

The browser decides whether an origin may request an RP ID. The server decides whether that exact origin may authenticate an account.

Level 05/09System

The laptop borrows the phone’s authenticator

Ana has registered on her phone. Her laptop does not have a copy of that credential and is not signed into her phone’s credential provider. Nevertheless, it can use the phone as an authenticator. This is cross-device authentication through the A FIDO transport that combines a local proximity signal with a separate channel for messages between a client and a phone authenticator.. The credential stays with the phone; the laptop borrows access to its signing operation for this ceremony.

The browser’s use another device route displays a QR code. Its contents are not the shop’s account password, not the private credential key and not a login assertion. In CTAP 2.2 §11.5, the QR bootstraps a communication channel between the devices. The protocol historically grew from caBLE, cloud-assisted Bluetooth Low Energy, which is why cable still appears in tunnel paths and implementation discussions.

The QR is a FIDO:/ URI followed by digit-encoded bytes. The uppercase scheme helps QR encoding efficiency. The bytes are a CTAP2-canonical CBOR map. Integer key 0 carries a 33-byte compressed P-256 public key belonging to the laptop’s channel identity. Key 1 carries a fresh 16-byte shared QR secret. Key 2 describes the known assigned tunnel-domain count. Optional time and state-assisted capability fields, plus a flow hint such as ga for getAssertion, help the devices start the right conversation.

The numeric encoding is specific: split the CBOR into seven-byte chunks, interpret each chunk as a little-endian unsigned integer, and render it in 17 decimal digits with leading zeros. A final chunk of one through six bytes uses 3, 5, 8, 10, 13 or 15 digits respectively. It is neither base64url nor a decimal rendering of the whole CBOR object. This is one of the places where apparently minor wire-format shortcuts make otherwise plausible implementations incompatible.

Decode one complete QR payload

Give Ana’s laptop the four-field map below. Key 0 is a valid compressed P-256 point, key 1 is a 16-byte teaching secret, key 2 says the laptop knows two assigned tunnel domains, and key 5 is the ga flow hint. Optional time and state-assisted fields are omitted. The point is the standard curve’s generator, chosen so its coordinates are reproducible; a real channel uses freshly generated private key material.

The map encodes to 61 bytes. Its first byte, a4, says four map pairs. 00 58 21 introduces key 0’s 33-byte byte string;01 50 introduces key 1’s 16-byte secret. The tail02 02 05 62 67 61 carries the tunnel-domain count and the two UTF-8 characters ga. These are the actual bytes fed to the digit encoder, not JSON hidden behind a URL.

Worked QR contents · 61 CBOR bytes, 149 decimal digits

Fixed teaching values: the P-256 generator point is the laptop’s public channel key; the 16-byte QR secret is 00…0f. A real laptop generates fresh secret material. This is a URI payload, not a live sign-in QR.

{0: h'036b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296', 1: h'000102030405060708090a0b0c0d0e0f', 2: 2, 5: "ga"}

Encode the canonical CBOR bytes

a4 00 58 21 03 6b 17 d1 f2 e1 2c 42 47 f8 bc e6 e5 63 a4 40 f2 77 03 7d 81 2d eb 33 a0 f4 a1 39 45 d8 98 c2 96 01 50 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 02 02 05 62 67 61

Partition into 7-byte chunks · select one to reverse it

Chunk 1 · bytes 0–6

Read 06591585652834468 as decimal: 6591585652834468.

Repeated division by 256 returns the remainders in byte order:

a4 00 58 21 03 6b 17

The leading decimal zero preserves this chunk’s 17-digit width.

N = b0 + 256b1 + 2562b2 + …

Concatenate the digit chunks after FIDO:/

FIDO:/06591585652834468698841437706615856818801915880415614613804490752887430219882912779840056405080733049802542101049181187005795029762731620418346304770
Remove FIDO:/, split into eight 17-digit groups and one 13-digit group, recover the little-endian bytes, then decode the CBOR map.

Selected chunk 1. The last five-byte chunk uses 13 decimal digits, including its leading zero.

One canonical CBOR map becomes a FIDO:/ URI. Reverse each decimal chunk, then reassemble all 61 bytes to recover the typed map.

For the first chunk, bytes a4 00 58 21 03 6b 17 give the little-endian integer 6,591,585,652,834,468. Padding it to 17 digits yields06591585652834468. Decoding takes the decimal number modulo 256 to recover a4, divides by 256, and repeats to recover the remaining bytes in their original order. The final chunk has five bytes, 02 05 62 67 61; its 13-digit encoding is0418346304770. Its leading zero is required, too.

The scanner removes the six-character FIDO:/ prefix, reads eight full 17-digit chunks and a final 13-digit chunk, and recovers the CBOR bytes. Only then does it interpret integer keys 0, 1, 2 and 5. At this point it has channel bootstrap material, not Ana’s shop key.CTAP 2.2 §11.5.1 specifies this encoding and the next proximity and channel-authentication steps.

Ana scans the laptop’s sign-in QR

FIDO:/ + decimal digits

A CTAP2-canonical CBOR map carries the laptop’s compressed P-256 public key and a 16-byte shared secret, plus protocol metadata. This bootstraps a temporary channel; it is not Ana’s credential private key.

Selected: What the QR carries. FIDO:/ + decimal digits.

The QR, BLE signal and tunnel have different jobs. Select a boundary to follow the laptop-to-phone ceremony.

Why a photographed QR is not enough

The phone broadcasts a BLE advertisement whose service data is protected using material derived from the QR secret. The laptop scans for the required FIDO service UUID and attempts to decrypt matching advertisements. The specified service data is 20 bytes; the protocol uses the recovered advert information in later channel setup. This makes physical proximity part of authorising the connection. An attacker who displays a remote laptop’s QR on a phishing page still needs the protocol’s local radio encounter.

BLE proximity is not a mathematical measurement of distance and is not a defence against every attacker with radios near the victim. Its role is to make a simple remote QR relay insufficient. It should not be replaced by the user scanned the code, so they must be near the right laptop. The scanner sees pixels; the protocol needs independent evidence of the nearby device.

For the CTAP 2.2 flow described here, a tunnel service relays messages over WebSockets. The phone and laptop establish end-to-end encryption with the specified Noise-based handshake, using the channel public key and a pre-shared key derived from the QR secret and decrypted BLE advert. These keys belong to the temporary connection. They are distinct from Ana’s long-lived shop credential key. The relay transports encrypted traffic; it does not become an entity allowed to sign in as Ana.

The laptop then sends the authenticator request with the shop’s RP ID and the client-data hash. Ana’s phone displays the request through its trusted interface and obtains local approval. The phone finds the discoverable shop credential and signs the assertion. The browser returns that assertion to the shop exactly as it would for another transport. The server verifies the same WebAuthn fields and signature; it does not accept a QR scan as authentication.

A successful hybrid login does not imply that the laptop now stores the passkey. Some implementations can link devices for a later state-assisted connection, reducing repeated QR scanning. Linking information and provider UX vary, so do not assume a particular cloud account, vendor tunnel hostname or future prompt. CTAP 2.3 also exists by November 2026; this account intentionally follows the named CTAP 2.2 QR-initiated flow, rather than treating one transport revision as timeless.

Now Ana opens the shop on the phone itself. The same RP ID and account are eligible, but no cross-device channel is needed. The local credential provider handles the request. The server’s new challenge still changes the signed message; the stored public key still verifies it. That sameness is the useful abstraction: transport chooses how the browser reaches the authenticator, while WebAuthn defines the evidence the server receives.

Check yourselfAfter Ana signs into the laptop through the phone’s QR flow, where must the credential private key now be?

Level 06/09System

A second device changes the custody story

Cross-device authentication moved a request to the phone. Synchronisation moves credential material between authorised instances of a credential provider. These can look similar to Ana because both let her sign in on another device, but their trust and recovery stories differ. A laptop holding a synced copy can authenticate without contacting the phone. A laptop using hybrid transport depends on reaching that phone for the ceremony.

Providers such as iCloud Keychain, Google Password Manager and third-party credential managers can make passkeys available across a user’s devices. The RP stores the same credential public key and identifier when a provider synchronises that credential. A separately created passkey on another authenticator is a new registration with a new key pair and ID. It gives the account another sign-in route rather than copying the existing one.

Apple documents iCloud Keychain synchronisation; Google describes end-to-end encryption of its passkey backups. At a high level, the provider encrypts credential secrets before uploading them and authorises other devices to recover them. Key wrapping, device enrolment, recovery and account policies are provider-specific. End-to-end encrypted does not mean that recovery has no trust assumptions or that the website can inspect the provider’s recovery design from one assertion.

This creates an important qualification to the phrase the private key never leaves the device. A device-bound hardware key can enforce that property. A synced passkey must be able to make its signing secret available to another authorised provider instance. A secure chip may protect the local wrapping key, the device-unlock decision or access to the local credential store while the sync system transports encrypted credential material. Do not infer that every synced passkey is generated and permanently confined inside a non-exportable secure-element slot.

What can the server infer from backup flags?

BE 0 · BS 0

Not backup eligible. The credential is bound to one authenticator instance. Loss can mean loss of this sign-in method; enrol another credential. These bits alone do not prove a particular chip or certification.

Selected: Device-bound. BE 0 · BS 0.

Backup eligibility is a credential property; backup state is a report that can change. The impossible fourth combination must be rejected.

WebAuthn exposes two signed bits for this distinction. BE is backup eligibility. BS is current backup state. The RP records BE at registration and checks that it stays consistent on authentication. It may update stored BS after a valid assertion. BS cannot be set with BE clear. These fields help the RP reason about credentials, but they do not enumerate all copies, describe encryption algorithms or certify the recovery strength of a cloud account.

The counter story follows the same custody boundary. One physical authenticator can maintain a local counter. Copies on devices that can sign offline cannot trivially agree on one sequence. WebAuthn allows zero counters, so a synced passkey reporting zero is not automatically a broken implementation. The server should evaluate counters according to the spec and its risk policy, rather than demanding a strictly increasing global number from every credential.

Moving between providers

Synchronisation within one provider and migration to a different provider are separate engineering problems. An export containing raw credential secrets in an unprotected file would undo much of the care taken around normal key custody. The FIDO Credential Exchange Format (CXF) defines structures for exchanging credentials; the Credential Exchange Protocol (CXP) describes protected exchange between provider applications.

As checked for this November 2026 dive, the linked CXF 1.0 document is a Proposed Standard with 9 March 2026 errata. The FIDO download page links CXP as a Working Draft dated 3 October 2024. Those are different maturity levels. Publication of a format does not guarantee every pair of credential managers can already transfer every passkey. Device-bound keys and policy-restricted credentials may be ineligible for export.

Recovery is where these choices become visible. If Ana loses her phone, a synced passkey may be recoverable through her provider’s approved device or account recovery process. A device-bound credential on a lost security key cannot be reconstructed by the shop from its public key. The shop needs another previously enrolled authenticator or a recovery route. That route deserves protection comparable to normal sign-in: an easy email fallback can become the real account takeover boundary.

OperationWhat moves?Shop’s credential record
Hybrid sign-inRequest and signed responseExisting ID and public key
Provider syncProtected credential materialSame credential ID and key
Another registrationA new public key and IDAdditional credential record
Provider exchangeEligible credentials through an exchange mechanismTransferred credential can retain its ID and key

“Available on another device” can mean a remote signing operation, a synced credential or an independently registered key. The recovery consequences differ.

Level 07/09Machine

Open the envelope, byte by byte

The server’s policy is now clear. Open the bytes that carry it. The outer browser credential has a string id, binary rawId, a type of public-key, a response object and client extension results. In its JSON representation, binary fields become base64url strings. That encoding is just a transport representation: decode it before reading binary structures or hashing client data.

A registration’s attestationObject is CBOR, the Concise Binary Object Representation. Its map contains fmt, attStmt and authData. The first is a format name, the second a format-specific map, and the third a byte string containing authenticator data. A CBOR byte string is not text and is not another base64url layer. The registration response also returns clientDataJSON as a separate buffer.

A login response does not wrap these fields in an attestation object. It returns authenticatorData, clientDataJSON, signature and a nullable userHandle separately. Registration describes and optionally attests a new credential; authentication proves possession of the registered one. Confusing the shapes is a frequent source of decoders that appear to work on one fixture but fail on the next.

Byte microscope · real captured responses

Bytes 0–63 of 197 · zero-based offsets

Byte 0 · rpIdHash

Field [0, 32): SHA-256 of the RP ID, not the full origin.

3d
{
  "flags": 69,
  "signCount": 0,
  "credentialId": "01d297244721d5a5795a8edb8fba8b1ec9156383a835a8fdaaef133dd27b91202051e47158d9e05e570d206b7881ec5918a54672a669aaa5a8add5dbfe17b58b36"
}

Showing the Android/Firefox capture. Select a byte to inspect its field. Captures retain their original domain.

Inspect real registration and assertion captures, or paste your own bounded hex buffer. Each byte links to its containing field; the decoded view retains the captured origin.

The fixtures are preserved from SimpleWebAuthn’s registration tests and authentication tests, under the MIT licence, copyright Matthew Miller. They include an Android/Firefox none response, packed self-attestation, a Yubico certificate-backed packed response and a separate assertion. The source does not identify every physical model. Their RP is dev.dontneeda.pw; relabeling it as Ana’s shop would invalidate the signed data. The software ceremony supplies the separate, fully local shop.example example.

The fixed header is 37 bytes

WebAuthn §6.1 puts the 32-byterpIdHash at offsets 0–31, the flags at offset 32, and signCount at offsets 33–36. The counter is an unsigned 32-bit big-endian integer. The flags are UP at bit 0, UV at bit 2, BE at bit 3, BS at bit 4, AT at bit 6 and ED at bit 7. Bits 1 and 5 are reserved. They are not padding bytes inserted between fields.

AT means attested credential data follows. It begins at offset 37 with a 16-byte AAGUID, then a two-byte big-endian credential ID length, the credential ID itself and a variable-length COSE public-key map. The length counts only the credential ID. It does not count the AAGUID, its own two bytes or the public key. After the key, ED means a CBOR map of authenticator extension outputs follows. Without AT or ED, the buffer ends after the counter. Reject truncation and unconsumed trailing data.

The AAGUID identifies an authenticator model or class, not Ana personally. None attestation has an empty statement and no attestation signature. Its AAGUID may be zero or nonzero; without verified attestation, it provides no authenticated provenance. SeeWebAuthn Level 3 §5.1.3. A certificate-backed response can carry a meaningful model identifier, but the ID itself is not proof. A client could write arbitrary bytes there. Trust comes from verifying the attestation format, its signature and chain, and applying an appropriate metadata policy.

COSE labels are numbers, including negative numbers

The credential public key is a COSE_Key map. For ES256, label 1 has value 2 for EC2; label 3 has value −7 for the algorithm; label −1 has value 1 for P-256; and labels −2 and −3 contain the 32-byte x and y coordinates. Those negative labels are map keys, not byte offsets. An Ed25519 key uses OKP type 1, curve 6 and a 32-byte x value. An RSA key uses type 3 with modulus and exponent byte strings instead.

CBOR packs the major type into the top three bits of its first byte. The remaining five bits either carry a small argument or tell you how many following bytes hold it. Negative integer value n is encoded using argument −1 − n; −7 therefore has the single-byte encoding 26. A 32-byte byte string starts with 58 20. a5introduces a map with five pairs. The decoder reads those lengths and recursively advances a cursor; it does not search for familiar byte sequences.

CTAP2 canonical CBOR requires minimal integer and length encodings, definite lengths, no tags, no duplicate keys and a particular key order: major type first, then encoded length, then bytewise lexical order. That order matters: the two-byte positive integer key 24 sorts before the one-byte negative key −1. A generic length-first “canonical CBOR” helper can produce the wrong order. The lab’s strict mode checks the CTAP credential subset; it rejects floating-point values rather than guessing their meaning. The WebAuthn attestation object’s outer map is decoded with general map ordering, while embedded credential keys and CTAP messages use strict checks.

Level 08/09Machine

One request becomes USB reports

With a roaming USB security key, the browser’s request crosses an explicit wire boundary. The client constructs authenticatorMakeCredential, command byte 01, followed by a CBOR map. The mandatory integer parameters are 1 for clientDataHash, 2 for the RP entity, 3 for the user entity and 4 for the public-key credential parameters. Optional parameters include an exclude list, extensions, options and PIN/UV authentication fields. CTAP 2.2 §6.1 defines their types and processing.

The authenticator gets a 32-byte hash of client data, not a mandate to parse the browser’s origin JSON itself. The client enforces WebAuthn’s origin rules and sends the RP ID. The authenticator hashes that RP ID into its data and includes the supplied client-data hash in its signed message. This division explains both why a browser is part of the trusted computing base and why a direct CTAP program has different powers from an ordinary web page.

The same application command can ride different transports. USB HID carries reports. NFC uses its command and response framing. The BLE authenticator transport has its own message fragmentation; hybrid uses the channel already described. A transport does not change the meaning of ES256 or turn a credential into an account session. The web server normally receives WebAuthn responses from the browser, not the raw USB packets below.

CTAPHID_CBOR · makeCredential · 64-byte reports

7 header bytes · 57 request bytes · 0 padding bytes

01 02 03 04 90 00 8f 01 a5 01 58 20 bd fa 61 87
9d 36 e8 c4 7f 93 7d 87 94 bc 47 7d 5e 6a fc 44
5c 9f 1a d2 24 c0 6b f1 c7 12 a3 6b 02 a2 62 69
64 6c 73 68 6f 70 2e 65 78 61 6d 70 6c 65 64 6e
01a5015820bdfa61879d36e8c47f937d8794bc477d5e6afc445c9f1ad224c06bf1c712a36b02a26269646c73686f702e6578616d706c65646e616d656c416e61e28099732073686f7003a362696445416e612d31646e616d6563616e616b646973706c61794e616d6563416e610481a263616c672664747970656a7075626c69632d6b657907a262726bf5627576f5

143 request bytes in 3 reports. Header command 90 is CTAPHID_CBOR (10 with bit 7 set); payload byte 01 is authenticatorMakeCredential.

The clientDataHash hashes the sample registration JSON included below. No PIN/UV protocol token is included; this request asks an authenticator with built-in user verification to perform UV.

Build a real canonical makeCredential request and fragment it into 64-byte CTAPHID reports. The bands allocate exactly one sixty-fourth of their width to each byte.

Two command bytes at different layers

CTAPHID §11.2.4 distinguishes initialization packets from continuation packets. In a 64-byte report, the initialization packet starts with a four-byte channel ID, a command byte with its high bit set, a two-byte big-endian message length and up to 57 data bytes. A continuation packet repeats the four-byte channel ID, carries a one-byte sequence number starting at zero, and has room for 59 data bytes. Unused bytes are padded; the message length says which bytes are meaningful.

The outer command here is CTAPHID_CBOR, value 10 hexadecimal with bit 7 set, yielding 90 on the wire. The first byte inside its payload is 01, the CTAP authenticatorMakeCredential command. 90 is not an alternative encoding of 01. One selects a HID message type; the other selects the authenticator operation carried inside it.

For a payload of L bytes, the first report holds min(L, 57). Remaining bytes require ⌈max(0, L − 57) / 59⌉ continuation reports. With sequence numbers 0 through 127, a 64-byte report size allows at most 57 + 128 × 59 = 7,609 message bytes at this framing layer. The authenticator can have a smaller supported message limit. Do not confuse a transport’s maximum with a promise that a device accepts a request that large.

A client first allocates a channel using CTAPHID_INIT; it does not invent an arbitrary channel ID for a real operation. The builder uses an already allocated, illustrative ID, 01020304. It rejects zero and the broadcast channel. The broadcast value has a specific role in allocation, not permission to send ordinary makeCredential commands to every logical channel. The HID report identifier, where a host API uses one, is outside the packet bytes illustrated here.

A login uses authenticatorGetAssertion, command 02. Its parameter map begins with the RP ID under key 1 and the client-data hash under key 2, with optional allow list, extensions, options and PIN/UV fields. The response contains a credential descriptor, authenticator data and signature, and can contain user information for a discoverable flow. Multiple eligible credentials can require additional selection or retrieval. The browser translates that protocol result into the WebAuthn response object seen by the shop.

The request builder asks for built-in UV and a discoverable credential. A real client first learns authenticator capabilities and may need the ClientPIN/PIN-UV protocol, rather than assuming every security key can perform biometric verification. Touch-only presence and a PIN-protected operation have different meanings. The distinction persists from the JavaScript options down to the command map and back up through the signed flags.

Check yourselfA 64-byte CTAPHID continuation report has how much room for payload?

Level 09/09Silicon

The boundary around the private key

The final question is where a signing key lives when Ana approves the phone’s prompt. In secure hardware is a useful beginning, but it leaves several different architectures unresolved. WebAuthn standardises the observable behaviour of an authenticator. It does not require every credential provider to store every passkey in the same kind of chip or to run every signature inside one.

A device-bound hardware authenticator can generate a credential key inside a protected boundary and expose a signing operation instead of an export operation. A security key’s secure element may hold credential secrets directly or derive and wrap them under internal master secrets, depending on its design. An opaque credential ID can participate in that design. The server must treat it as opaque rather than assuming it encodes a serial number, a memory address or an encrypted private key.

A phone can use a Secure Enclave, a trusted execution environment or a dedicated secure element for parts of key management and local verification. Android distinguishes hardware-backed Keystore implementations, including StrongBox on devices that provide it; Android’s Keystore architecture describes the boundary. Windows platform credentials may use a TPM, whileWindows Hello’s architecture separates key protection and user gestures. Names such as StrongBox and TPM describe capabilities, not a universal statement about every installed credential provider.

Application processor

The browser and OS broker requests. They enforce origin rules, manage UI and route data; they do not need the credential secret to verify a response.

Verification boundary

A biometric matcher or PIN/passcode policy authorises use. The biometric template remains local; the RP receives a signed UV flag.

Protected key service

Generate, unwrap or use key material according to policy. A device-bound design can expose sign() without exposing export().

Cryptographic engine

ES256 computes an ECDSA signature using the secret scalar and fresh per-signature randomness. Hardware or software implements the arithmetic.

Return path

Only public data and the signature leave through the authenticator API. Synced credentials have a separate protected backup path.

Follow one authorised signing operation through its trust boundaries. Hardware can protect key custody, approval or wrapping; the exact placement depends on the credential provider.

Follow one signing request across the chip boundary

Suppose Ana also enrols a device-bound backup credential on a USB key whose firmware keeps its P-256 signing key in a secure element. Use that credential for one shop.example login with local verification complete and a counter advancing to 7. This is one concrete architecture for the backup key, rather than a claim about the provider storing her synced phone passkey.

The browser sends the RP ID and SHA-256(clientDataJSON)to the authenticator. Firmware looks up the credential and checks its RP binding, completes presence and verification policy, then constructsM = authenticatorData || clientDataHash. Here M is 69 bytes: the 32-byte RP ID hash, flags 05 for UP and UV, big-endian counter 00 00 00 07, and the 32-byte client-data hash. No attested credential data or extension map follows this assertion header.

In the prehashed signing interface modeled below, firmware computesH = SHA-256(M) and sends H, an opaque key reference and an ECDSA/P-256 operation selector across the protected boundary. The element uses its internal private key only after its access policy permits the operation. It returns signature integers r and s or an error. Firmware cannot obtain the private scalar by asking for a signature.

One device-bound backup key · Ana’s shop login · counter 7

Modeled architecture: authenticator firmware owns the WebAuthn record; a secure element holds the non-exportable P-256 signing key. The demo uses WebCrypto in this page. Real chip APIs, key references and approval boundaries vary by vendor.

Outside: prepare the signed message

The firmware has checked the RP ID and obtained UP + UV. It serializes 37 bytes of authenticator data, then appends the browser’s 32-byte clientDataHash.

M · 69 bytes
0f 59 46 3c 60 6c 5b 0e 5d 3d a8 1f 36 e3 f7 c1 75 ac 23 0c 60 e7 5c 21 44 ce 3b 75 22 47 60 7c 05 00 00 00 07 22 51 02 40 46 31 2c 6c 59 b5 f7 e5 04 1d 2b 23 e8 e6 67 f2 3b 97 96 12 22 aa 1e 81 3d 4d 58 e0

Cross into the secure element

Logical request: sign with opaque key reference “slot 7”, ECDSA/P-256, and this 32-byte SHA-256 digest of M.

85a4723e3aab416aea2a6de382a756f63e3b2b09e3b3fc3c7cc4840a638161e3

The slot label is illustrative. It is not Ana’s credential ID or a specified CTAP command packet.

Inside: use the private scalar

The protected signing engine resolves the key reference, enforces its access policy and uses private scalar d and a per-signature secret k to compute (r, s). Neither d nor k is part of the reply.

Cross back: return the signature

In this modeled interface the element returns two 32-byte integers. Firmware encodes them as DER and returns the signature with authenticatorData and the credential ID. The browser attaches its original clientDataJSON.

r · 32 bytes: awaiting signing
s · 32 bytes: awaiting signing
DER signature: awaiting signing

The 69-byte message and 32-byte digest are already shown. The button creates a fresh in-memory key to demonstrate the return values.

A concrete 69-byte assertion message becomes a 32-byte digest at the modeled secure-element boundary. Compute the actual r and s values and verify the resulting signature locally.

The element’s reply is not a WebAuthn response object. In this chosen interface it is a fixed-width pair of integers; firmware turns that pair into the DER ECDSA signature required by WebAuthn. Another chip might return DER directly or accept the message and perform SHA-256 internally. The command framing, key reference and location of policy checks depend on the vendor. Neither CTAP nor WebAuthn standardises this internal chip interface. The invariants are the signed message and the external response, not a universal secure-element packet layout.

A phone’s key service can add another broker. Android’sKeyMint architectureseparates the Keystore daemon, HAL service and protected implementation; authentication-bound operations can also require an authentication token. That illustrates how approval evidence can cross a boundary without sending a fingerprint template to the website. A provider may instead protect a wrapping key or use another custody design, especially for synced credentials. The USB-key trace above does not identify which of those designs Ana’s phone uses.

Verification authorises a key operation

Ana’s face is not an input to the ECDSA equation. Local biometric machinery checks a match and authorises an operation under device policy. A passcode or PIN can provide another local route. The authenticator reports UV in signed data; the website normally does not receive the biometric, its template or a match score. It also does not learn from UV alone whether Ana used her face, a fingerprint or a PIN.

Presence is weaker. Touching a security key can show that somebody is physically interacting with it. It need not identify which person. This is why UP and UV occupy separate flag bits, and why asking for userVerification: "required" has a real consequence. A server that needs UV must enforce the returned UV flag instead of treating any successful API return as equivalent approval.

For ES256, a private scalar d and public point Q =dG belong to P-256. A signature combines the message hash with a per-signature secret scalar. Reusing that scalar across different messages can expose the credential private key. A sound implementation uses a secure random or approved deterministic nonce procedure. No animation of a fingerprint can compensate for a broken signing implementation. This page delegates the cryptography to WebCrypto and performs the WebAuthn serialization itself.

P-256’s coordinates each occupy 32 bytes, yet that does not mean 256-bit resistance to every attack. The commonly cited generic security level is about 128 bits. RSA and elliptic-curve key sizes are not directly comparable by counting their serialized bytes. The options builder’s algorithm identifiers choose a signature scheme and key format, not an arbitrary strength slider.

The hardware claim needs evidence

A nonextractable WebCrypto key prevents ordinary script from exporting it through that API. It does not, by itself, establish a secure element, a biometric gate or resistance to a compromised browser. Likewise, a valid none-attestation registration does not tell the shop how the credential’s provider protects its secrets. If the shop needs hardware assurances, it must request and evaluate suitable attestation under an explicit policy. That carries compatibility and privacy consequences and requires maintained trust inputs.

Hardware also has a lifecycle. Firmware defects, side channels, physical attacks, certification changes and compromised attestation keys can alter a trust decision. FIDO metadata status reports exist partly because a one-time model check is insufficient. A relying party using that evidence must plan for updates and recovery, rather than permanently blessing a model name from its first successful login.

Ana’s next phone login closes the path we followed. A new server challenge reaches the browser. The browser binds it to the shop’s origin and RP ID. The provider finds her discoverable credential and obtains approval. A signing operation produces an assertion; the shop checks the exact context, bytes and signature, then creates a session. Whether that signing operation lived behind a remote phone channel, a local provider or a USB secure element changes the route and custody. The proof remains scoped to the shop and fresh for this login.

The chip protects a key operation. The browser protects its website scope. The server checks that the resulting proof answers this account’s pending ceremony.

End of Passkeys · 9 levels, Idea to Silicon

Where to next

Practical notes

  1. Note4 min read

    Set up passkeys: the minimum server checks

    Generate fresh challenges, bind them to the ceremony, and verify origin, RP ID, flags and signatures before creating a session or storing a credential.

  2. Note3 min read

    Validate an Ory Kratos username with an identity schema

    Constrain a username to 4–20 ASCII letters, digits or underscores. Put the rule in the identity schema and distinguish validation from identifier uniqueness.

Browse all 34 divesAll topics