Skip to content

fix(credmgmt): Yubikey error when NextCred is not handled statefully#264

Merged
AlfioEmanueleFresta merged 3 commits into
linux-credentials:masterfrom
Nisker:fix/cred_mgmt
Jun 10, 2026
Merged

fix(credmgmt): Yubikey error when NextCred is not handled statefully#264
AlfioEmanueleFresta merged 3 commits into
linux-credentials:masterfrom
Nisker:fix/cred_mgmt

Conversation

@Nisker

@Nisker Nisker commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

I have a Token2 and a Yubikey "Security Key C NFC".
The Yubikey is more strict than the Token2 and causes errors.

cargo run --example cred_management_hid with option 2: "(2) Enumerate credentials"
causes Error: Ctap(NotAllowed) on the Yubikey after the PIN have been input.
I think this is due to enumerateCredentialsGetNextCredential and enumerateRPsGetNextRP being statefull in the fido v2.1 spec.

@AlfioEmanueleFresta AlfioEmanueleFresta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and the clear diagnosis @Nisker, you read the spec exactly right.

  • CTAP 2.1 §6.8.3 and §6.8.4 send the GetNext subcommands with only the subCommand parameter.
  • The stateful commands section lets authenticators fail a continuation with CTAP2_ERR_NOT_ALLOWED unless it directly follows Begin or another GetNext.
  • Our old loop broke this in two ways. It attached a pinUvAuthParam, and it sent a getInfo between Begin and GetNext.
  • YubiKeys enforce the strict reading, the Token2 is lenient.
  • libfido2, Chromium and python-fido2 all send GetNext bare.

Reproduced here on a YubiKey with two passkeys under one RP. On master:

DEBUG user_verification:ctap2_get_info: CTAP2 GetInfo successful
TRACE ctap2_credential_management: request=Ctap2CredentialManagementRequest {
  subcommand: Some(EnumerateCredentialsGetNextCredential), subcommand_params: None,
  protocol: Some(Two), uv_auth_param: Some([155, 189, 175, ..]) }
DEBUG ctap2_credential_management: Received CBOR response status=NotAllowed
Error: Ctap(NotAllowed)

With this PR, same device and credentials:

TRACE ctap2_credential_management: request=Ctap2CredentialManagementRequest {
  subcommand: Some(EnumerateCredentialsGetNextCredential), subcommand_params: None,
  protocol: None, uv_auth_param: None }
DEBUG ctap2_credential_management: Received CBOR response status=Ok
DEBUG ctap2_credential_management: CTAP2 CredentialManagement successful

I pushed two commits on top of your branch:

  • Regression tests pinning the wire format. They fail on master.
  • A fix for authenticators that only advertise credentialMgmtPreview. Begin resolves the 0x41 preview command from getInfo, but GetNext no longer went through that path, so it would have gone out as 0x0A. Begin now records the command set it resolved and GetNext reuses it.

Nice catch, thanks again!

@AlfioEmanueleFresta AlfioEmanueleFresta merged commit 5294ac7 into linux-credentials:master Jun 10, 2026
4 checks passed
@AlfioEmanueleFresta

Copy link
Copy Markdown
Member

This is now released in libwebauthn 0.7.1 if you want to test, thanks again @Nisker!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants