RP ID and origin validation: why passkeys bind to the wrong site
In one line: How rpIdHash is computed, the protocol, host and port rules for origins, and the subdomain and localhost exceptions, with real mismatch cases.
Half of all "the passkey registers but sign-in fails" reports come down to an RP ID and origin mismatch. They look interchangeable but play different roles.
rpIdHash is the hash of the RP ID
rpIdHash = SHA-256(RP ID), over the RP ID string, not the origin. A credential registered with RP ID example.com hashes example.com even when the origin is https://login.example.com.
SHA-256("example.com")
= 3a6eb02f8ba0140d9f8e0c3d3e712f6d… (32 bytes)
If the decoder keeps reporting a mismatch, put the exact RP ID from the attestation into panel ②. Very often a www. prefix or a subdomain was used instead.
The three parts of an origin
| Part | Example | What to check |
|---|---|---|
| Scheme | https: | http is allowed only for localhost |
| Host | login.example.com | Equal to the RP ID or a subdomain of it |
| Port | 8443 | A non-default port changes the origin |
Allowed combinations
| RP ID | Origin | Result |
|---|---|---|
| example.com | https://example.com | Allowed |
| example.com | https://login.example.com | Allowed (subdomain) |
| login.example.com | https://example.com | Not allowed (cannot widen to the parent) |
| example.com | https://example.com:8443 | Not allowed (non-default port origin) |
| localhost | http://localhost:3000 | Allowed as a development exception |
| example.com | http://example.com | Not allowed (HTTPS required) |
The origin the server knows and the origin the browser recorded
Server applications usually sit behind a reverse proxy or CDN. The "our origin" the server knows may be an internal address such as http://10.0.2.5:8080, while the browser records the public domain the user sees in the address bar. Even when the proxy forwards X-Forwarded-Host and X-Forwarded-Proto, a comparison goes wrong unless the framework is configured to trust them. It is safer to compare clientData against an allow list written in configuration than against request headers.
If a service answers on both https://example.com and https://www.example.com, allow both origins but pin a single RP ID such as example.com, so the same passkey works whichever address the user visits.
Mismatches you will actually hit
- www or not — setting the RP ID to
www.example.commeans the same passkey cannot be used onexample.comlater. If the whole service should share credentials, use the parent domain. - Changing ports — a new development port changes the origin. localhost is exempt from the port rule; a real domain is not.
- iframes and crossOrigin — a ceremony inside an embedded iframe on another site can set
crossOriginto true in clientData, and many servers reject that. - Redirects — if the sign-in page redirects to another host, the origin changes even when the RP ID does not, and the server's origin allow list may not contain the new host.
A checking sequence
- Compare rpIdHash in the attestation with SHA-256 of the RP ID.
- Compare clientData.origin with the origin the server expects, as exact strings.
- Confirm the RP ID equals the origin host or is a parent domain of it.
- Confirm the scheme is https and that no unexpected port is present.
- Confirm UV is set if your policy requires it.
Decoding happens right in the browser. The payload you paste is not stored.
Open the PasskeyLab decoderFrequently asked questions
Can the RP ID be changed later?
Existing credentials are bound to the original RP ID and cannot move. You have to register again under the new RP ID; the old credentials remain valid but unused.
Do I need a separate passkey for each subdomain?
If the RP ID is the parent domain, every subdomain can use the same credential. If you want isolation per site, use the subdomain as the RP ID.
Can a passkey made on localhost be used on the production domain?
No. localhost and the real domain are different RP IDs, so credentials are not shared.
Sources
Read next
- The WebAuthn registration and authentication ceremoniesWhat the browser, server and authenticator each build and verify during create and get, field by field, and where implementations usually go wrong.
- The authenticatorData byte layout and flag bitsOffsets for the 37-byte header, AAGUID, credential ID, COSE key and extensions, with a worked hex example and the meaning of every flag.
- Reading CBOR and COSE public keys: ES256, RS256, Ed25519How the attestationObject CBOR map and the COSE key map (kty, alg, crv, x, y, n, e) are laid out, with byte-level examples and reconstruction steps.