Skip to content

Removes enrollments from the sensor before persistent storage - #845

Open
kakkar87d wants to merge 1 commit into
google:developfrom
kakkar87d:remove-enrollment-sensor-first
Open

kakkar87d wants to merge 1 commit into
google:developfrom
kakkar87d:remove-enrollment-sensor-first

Conversation

@kakkar87d

Copy link
Copy Markdown
Contributor

remove_enrollment deletes the template's record from persistent storage before asking the sensor to delete the template. When the sensor call fails, removeEnrollment returns an error but the record is already gone, so the finger stays enrolled on the sensor without OpenSK tracking it. perform_built_in_uv identifies against every sensor template, so that finger keeps passing built-in UV whenever another fingerprint is stored: it isn't listed by enumerateEnrollments, retrying removeEnrollment returns CTAP2_ERR_INVALID_OPTION, and authenticatorReset doesn't remove it because reset only deletes the templates in persistent storage.

On the FPC2534 board, delete_template fails with InvalidState while another matcher operation is running, for example an enrollment started with enrollBegin and not finished or cancelled, or the identify that stays active after a built-in UV prompt times out (check_fingerprint_complete doesn't abort it). The template is now removed from the sensor first, and the record only after that succeeds, which is the order reset() already uses. Unknown template IDs still return CTAP2_ERR_INVALID_OPTION without touching the sensor.

The test sensor now refuses to delete during an enrollment, like the FPC2534 driver. test_remove_enrollment_sensor_busy tries to remove a template while an enrollment is running, cancels the enrollment, removes the template again and checks that built-in UV fails. Without this change the second removal returns CTAP2_ERR_INVALID_OPTION and the template keeps passing built-in UV.

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

removeEnrollment deleted the template's persistent record before asking
the sensor to delete the template. If the sensor call failed, the
template stayed on the sensor untracked: it kept passing built-in UV,
was no longer listed or removable, and survived reset.

Delete the template from the sensor first and drop the record only
after that succeeds, like reset() already does.
@kaczmarczyck

Copy link
Copy Markdown
Collaborator

We discussed a redesigned in #844 . The code suggested here might get touched by that too. So I suspect that #844 , #845 and #846 together will merge.

@kaczmarczyck kaczmarczyck self-assigned this Nov 27, 2026
@kakkar87d

Copy link
Copy Markdown
Contributor Author

Makes sense, this one mostly goes away with the redesign in #844: check_fingerprint only matches enrolled templates there, so an untracked template can't pass built-in UV and the ordering in removeEnrollment stops mattering for the bypass. The only leftover I can see is that a failed delete_template leaves the template holding a sensor slot until init reconciles it on the next boot, which seems fine to me. Happy to close this in favour of #844 whenever you like.

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