Skip to content

Decrements UV retries before matching a fingerprint - #843

Merged
kaczmarczyck merged 3 commits into
google:developfrom
kakkar87d:uv-retries-before-match
Nov 23, 2026
Merged

kaczmarczyck merged 3 commits into
google:developfrom
kakkar87d:uv-retries-before-match

Conversation

@kakkar87d

Copy link
Copy Markdown
Contributor

check_fingerprint_loop writes 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, and uvRetries stays where it was, so fingerprint attempts are no longer limited by maxUvRetries. performBuiltInUv in CTAP 2.3 decrements uvRetries before running UV (step 4) to block this kind of hardware attack, and verify_pin_hash_enc already 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_loss panics 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_timeout covers giving the retry back.

  • Local tests pass (running run_desktop_tests.sh; every Rust step, skipping cargo audit, which I don't have installed, and the Python ruff checks, since no dependencies or Python files changed)
  • Tested against boards
    • Nordic nRF52840 DK
    • Nordic nRF52840 Dongle
    • Makerdiary nRF52840 MDK USB Dongle
  • Appropriate changes to README are included in PR

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
kaczmarczyck previously approved these changes Nov 19, 2026

@kaczmarczyck kaczmarczyck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Comment thread libraries/opensk/src/ctap/storage.rs Resolved
Comment thread libraries/opensk/src/env/test/mod.rs Resolved
kaczmarczyck
kaczmarczyck previously approved these changes Nov 23, 2026
@kaczmarczyck
kaczmarczyck merged commit abbd0ae into google:develop Nov 23, 2026
13 checks passed
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