[5.x]: Passkeys registered with webauthn-lib v4 still fail with an uncaught InvalidUserHandleException (HTTP 500) after the #19530 fix
I maintainer di solito rispondono entro 1 giorno
@i-just ci sta già lavorando.
Dal 21/10/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- php
- Ambito
- authentication, backend
Direzione di ricerca
Start by reading CredentialRepository::findOneByCredentialId(), Auth::verifyPasskey(), and User::authenticateWithPasskey(), then trace the two comparisons in CheckUserHandle::process() from webauthn-lib 5.3.8. Reproduce the v4 record case described in the issue and compare it with the v5 control. Done means v4 passkeys authenticate successfully or fail with a normal authentication response rather than HTTP 500, while v5 passkeys continue to work.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happened?
Follow-up to #19530. Craft 5.11.1 replaced the checkOldUserHandle retry with a check in CredentialRepository::findOneByCredentialId(): when the stored userHandle is a raw user UID (a v4-era record), it is base64url-encoded again before validation. That fixes the first comparison in Webauthn\CeremonyStep\CheckUserHandle, but not the second one, so v4-era passkeys still cannot log in.
In CheckUserHandle::process() (webauthn-lib 5.3.8):
- Line 39:
hash_equals($credentialUserHandle, $userHandle). The stored handle (nowbase64url(uid)) vs$userEntity->id(base64url(uid)). Passes. - Line 41:
hash_equals($credentialUserHandle, $responseUserHandle). The stored handle (base64url(uid)) vs the user handle the authenticator returns. For a passkey registered under v4, the authenticator holds the raw UID asuser.id(that is what v4-era Craft sent at registration), so it returns the raw UID. Fails.
Auth::verifyPasskey() rethrows InvalidUserHandleException, and User::authenticateWithPasskey() only catches yii\base\InvalidArgumentException, so the request ends in an HTTP 500 instead of a normal "invalid credentials" response.
The two comparisons need different values for a v4-era record, so no change to the stored data can make both pass. The fix has to be in code.
Steps to reproduce
- Create a
webauthnrow in the v4 format. ItscredentialJSON hasuserHandle= base64 of the raw user UID, which is what records written under webauthn-lib v4 look like. - Put the matching credential on an authenticator with
user.id= the raw UID. We used a Chrome DevTools Protocol virtual authenticator (WebAuthn.addCredential). - Log in with that passkey (
auth/passkey-request-options, thenusers/login-with-passkey).
Result: HTTP 500, Webauthn\Exception\InvalidUserHandleException: Invalid user handle, thrown at CheckUserHandle.php(41).
Control: the same steps with a v5-format record (stored handle = base64url(uid), and the authenticator user.id = base64url(uid)) return HTTP 200.
Possible fix
For a v4-era record, do not re-encode the stored handle. Instead, pass the raw UID as the expected handle to the validator, so that both comparisons use the raw UID:
CredentialRepository::findOneByCredentialId(): keep$credentialRecord->userHandleas the raw UID.Auth::verifyPasskey(): if$credentialRecord->userHandle === $user->uid, pass$user->uidinstead of$userEntity->idas the$userHandleargument ofcheck().
Separately, User::authenticateWithPasskey() could treat InvalidUserHandleException as an authentication failure, so that a mismatch produces a normal login error instead of a 500.
Craft CMS version
5.11.1 (production). We also checked that CredentialRepository.php on the 5.x branch is unchanged as of 5.11.5.1.
PHP version
8.4
Operating system and version
Linux
Database type and version
MySQL 8.0
Image driver and version
No response
Installed plugins and versions
Not relevant (core passkey login).
Workaround we used
We deleted the v4-era webauthn rows and asked the affected users to register their passkeys again. After the rows are deleted, an old passkey still on a device gets a normal 400 "authentication failed" response instead of a 500.
- Lingua principale
- PHP
- Stelle
- 3.6k
- Fork
- 708
- Merge medio
- 10h 57m
- PR unite (30g)
- 275
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di craftcms/cms
-
bug repo:cms
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
craftcms/cms#20051 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[6.x]: Colored chips: link blue has low contrast on tinted backgroundsForse già presa @brandonkelly l’ha presa 7 giorni fa. Apertabug repo:cms
craftcms/cms#19984 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
bug repo:cms
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
craftcms/cms#19980 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[6.x]: Text in some input fields is clipped at the bottom on WindowsForse già presa @brianjhanson l’ha presa 13 giorni fa. Apertabug repo:cms
craftcms/cms#19928 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
bug repo:cms
Difficoltà 4/5 3-5 giorni Idoneità per principianti 15/100
craftcms/cms#19916 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di craftcms/cms
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
PHP SDK drops the API path prefix when a custom base URL has no trailing slashForse già presa @Winoren l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
langgenius/dify#44568 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
1. to develop bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Copilot displays warning when both claude and copilot harnesses installed in same repoApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
awslabs/aidlc-workflows#2921 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug Status: Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
php/php-src#24552 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno