Repository navigation
Decrements UV retries before matching a fingerprint - #843
Merged
Merged
Conversation
check_fingerprint_loop only wrote the UV retry counter after the sensor reported a mismatch. Cutting the power between the mismatch and that write leaves uvRetries unchanged, so fingerprint attempts are not limited by maxUvRetries. performBuiltInUv decrements uvRetries before running UV for this reason, like OpenSK already does for PIN retries. Take the retry before each attempt, and give it back when the loop times out without a finger on the sensor.
kaczmarczyck
previously approved these changes
Nov 19, 2026
kaczmarczyck
left a comment
Collaborator
There was a problem hiding this comment.
Makes sense!
For the record, I think I saw a similar theme in a bigger PR before, where some agent wanted to piggyback this change into another PR, but it vanished after I commented.
kaczmarczyck
previously approved these changes
Nov 23, 2026
kaczmarczyck
approved these changes
Nov 23, 2026
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.
check_fingerprint_loopwrites the UV retry counter only after the sensor reports a mismatch. Someone holding the key can cut the power between that result and the flash write, anduvRetriesstays where it was, so fingerprint attempts are no longer limited bymaxUvRetries. performBuiltInUv in CTAP 2.3 decrementsuvRetriesbefore running UV (step 4) to block this kind of hardware attack, andverify_pin_hash_encalready takes the PIN retry before checking the PIN. A retry is now taken before each sensor attempt and given back when the loop times out with no finger on the sensor, which the spec allows, so an unanswered prompt still doesn't cost a retry.test_perform_built_in_uv_power_losspanics inside the fake sensor to stand in for the power loss and checks that the attempt already used a retry. It fails without this change (8 retries left instead of 7).test_perform_built_in_uv_timeoutcovers giving the retry back.run_desktop_tests.sh; every Rust step, skippingcargo audit, which I don't have installed, and the Python ruff checks, since no dependencies or Python files changed)