Skip to content

fido2: fix hmac-secret detection with comma-separated libfido2 output - #592

Open
dinhphu28 wants to merge 1 commit into
dyne:masterfrom
dinhphu28:fix-fido2-hmac-secret-parsing
Open

fido2: fix hmac-secret detection with comma-separated libfido2 output#592
dinhphu28 wants to merge 1 commit into
dyne:masterfrom
dinhphu28:fix-fido2-hmac-secret-parsing

Conversation

@dinhphu28

Copy link
Copy Markdown

Problem

tomb forge --fido2 fails on compatible authenticators with:

[E] FIDO2 authenticator does not advertise hmac-secret. Please enable
hmac-secret on the key or use a compatible device.
even when the device clearly supports it:

$ fido2-token -I /dev/hidraw3
...
extension strings: credProtect, hmac-secret, largeBlobKey, credBlob, minPinLength

Root cause

_fido2_require_extension() parses that line by splitting on spaces only. Modern libfido2 (>= 1.15) prints the extension list comma-separated, so each word keeps a trailing comma (hmac-secret,) and never matches the target extension name. Only the last entry in the list
(no trailing comma) can ever match, so the check almost always fails.

Fix

Strip a trailing comma from each word before comparing. Works for both the comma-separated (new) and space-separated (old) formats, so no version detection is needed:

for word in ${(s: :)line}; do
word=${word%,} # libfido2 comma-separates extensions
[[ "$word" == "$ext" ]] && return 0
done

Testing

  • Before: tomb forge --fido2 -k test.key --fido2-device /dev/hidraw3 aborts with the hmac-secret error.
  • After: the extension is detected and forging proceeds.

Environment: Tomb 2.13.0, libfido2 1.16.0, YubiKey 5 (FIDO_2_1), Linux.

_fido2_require_extension() splits the `extension strings:` line from
`fido2-token -I` on whitespace only. Current libfido2 (>= 1.15) prints
that list comma-separated, e.g.:

    extension strings: credProtect, hmac-secret, largeBlobKey, credBlob, minPinLength

so every word except the last retains a trailing comma. The comparison
`hmac-secret,` == `hmac-secret` never matches, and `tomb forge --fido2`
aborts with the misleading:

    [E] FIDO2 authenticator does not advertise hmac-secret.

even on fully compatible devices (e.g. YubiKey 5) that do support it.

Strip the trailing comma from each word before comparing. This handles
both the comma-separated and older space-separated output formats.

Fixes FIDO2 key forging on libfido2 >= 1.15.

Signed-off-by: Dinh Phu Nguyen <dinhphu.nguyen.20@gmail.com>
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.

1 participant