WebAuthn user handles: safely distinguish account IDs from credential IDs
A WebAuthn user handle is an opaque byte identifier that the relying party (RP) assigns to an account. With discoverable credentials, an authenticator can return it during a username-less sign-in so the server can find the account. Do not put an email address, phone number, or real name in it; use a stable, account-specific opaque value. The authenticator chooses each credential ID, while the RP chooses a user handle for the account.
WebAuthn user handles: safely distinguish account IDs from credential IDs
A WebAuthn user handle is an opaque byte identifier that the relying party (RP) assigns to an account. With discoverable credentials, an authenticator can return it during a username-less sign-in so the server can find the account. Do not put an email address, phone number, or real name in it; use a stable, account-specific opaque value. The authenticator chooses each credential ID, while the RP chooses a user handle for the account.
Under W3C WebAuthn Level 3, a user handle must be non-empty and no longer than 64 bytes. It is not meant to be shown to users. Do not confuse it with displayName or a login name.
What it is used for
At registration, the RP supplies the handle as user.id and stores each credential ID and public key with that account. In a username-less sign-in using a discoverable credential, the authenticator may return the handle as response.userHandle. The server must check that the response’s credential ID and user handle refer to the same account record. A matching handle alone does not authenticate the login: also verify the signature, challenge, origin, RP ID, and any required user-verification policy.
The same account’s user handle should normally be consistent across its registered credentials. If two accounts share a constant value, they can collide; some authenticators may also replace an existing discoverable credential when another is registered with the same RP ID and handle.
Implementation checklist
Generate an unpredictable opaque account identifier; do not encode personal information in it.
Give each account a distinct value. A username or email hash is not automatically a suitable opaque identifier: it can be guessable, change when an email changes, and enable correlation across services.
Enforce the non-empty and 64-byte maximum on the server.
Store `userHandle`, credential ID, username, and display name in separate fields with separate purposes.
On sign-in, confirm that the credential’s account and user handle agree. Avoid exposing whether an account exists before completing the full assertion checks.
Define how credentials and handles are revoked or migrated when an account is deleted, merged, or renamed.
References
W3C, [Web Authentication Level 3: User Handle](https://www.w3.org/TR/webauthn-3/#user-handle)
W3C, [Web Authentication Level 3: User Account Parameters](https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialuserentity-id)