fido2: fix hmac-secret detection with comma-separated libfido2 output - #592
Open
dinhphu28 wants to merge 1 commit into
Open
fido2: fix hmac-secret detection with comma-separated libfido2 output#592dinhphu28 wants to merge 1 commit into
dinhphu28 wants to merge 1 commit into
Conversation
_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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Environment: Tomb 2.13.0, libfido2 1.16.0, YubiKey 5 (FIDO_2_1), Linux.