Repository navigation
Conversation
kaczmarczyck
left a comment
There was a problem hiding this comment.
I wonder where this problem should be solved.
The problem is that the assumed invariant between template ID storage and fingerprint template storage is broken. You are working on this in #846, but there might be more problems.
This PR wants to solve it in the library. It could also be a problem for the Env implementation. Or even the OS might need to help by either cleaning up fingerprints when installing OpenSK, or otherwise helping us enforce the invariant.
@ia0 Opinions?
|
I can see at least 3 options:
If the third option is possible, in my opinion it's the cleanest. The library is simpler and we can provide helpers (like we do for other APIs) to implement the environment using some keys in the storage. |
|
Option 3 looks possible with the API that is already there. One constraint on the isolation: I am happy to rework this as option 3: move listing and friendly names behind the |
|
I agree that the invariant is not clean. Option 3 should be powerful enough, and ideally we don't need to put too much CTAP logic into the helper. |
Built-in UV accepted any finger the sensor matched. The applet identifies against every template on the FPC2534 (Identify::new(None)) and dropped the template ID that IdentifyResult::Match returns, so the library could not tell an enrolled finger from a template OpenSK doesn't store. The sensor holds such a template when it finishes an enrollment that OpenSK never records: after enrollBegin, the finger is touched until the sensor completes the enrollment and cancelCurrentEnrollment is sent next (Enroll::abort only aborts a running enrollment, so a finished one stays on the sensor), or the device loses power before the template ID is stored. That finger passed built-in UV whenever at least one stored finger existed, was not listed by enumerateEnrollments, could not be deleted with removeEnrollment, and survived authenticatorReset. The root cause is the invariant between the template IDs in the store and the templates on the sensor, which the library maintained on its own. The environment now owns both, so there is no invariant left to break: - Fingerprint gains init, list_enrollments and set_friendly_name, and remove_enrollment deletes the enrollment as well as the template. Capturing the last sample enrolls the template, and the implementation deletes it from the sensor if it can't store the enrollment. check_fingerprint only matches enrolled templates. - api::fingerprint::helper implements that storage on top of Persist, the way the key store helper does, keeping the template IDs and friendly names in keys::TEMPLATE_INFOS. Persist loses the five fingerprint methods and the library no longer uses the store for this. - The Wasefire environment stores enrollments through the helper, compares the matched template from IdentifyResult::Match against them, and deletes templates that are not enrolled in init. - The test environment does the same with a store shared between TestEnv and TestFingerprint, so it mirrors a real environment. test_perform_built_in_uv_unenrolled_template leaves a template on the sensor without enrolling it and checks that built-in UV rejects it, test_init_removes_unenrolled_template checks that init deletes it, and test_enrollment_database_full now checks that a template the environment couldn't enroll is gone from the sensor.
b540d82 to
b188ca1
Compare
|
Reworked as option 3, so the environment owns the templates and their metadata. The helper in One constraint on the isolation: With the invariant gone, #846 isn't needed, so I'm happy to close it if you agree. |
Built-in UV accepts any finger the sensor matches. The applet identifies against every template on the FPC2534 (
Identify::new(None)) and drops the template ID thatIdentifyResult::Matchreturns, so the library can't tell an enrolled finger from a template OpenSK doesn't store. The sensor holds such a template when it finishes an enrollment that OpenSK never records: after enrollBegin, the finger is touched until the sensor completes the enrollment and cancelCurrentEnrollment is sent next (Enroll::abortonly aborts a running enrollment, so a finished one stays on the sensor), or the device loses power before the template ID is stored. That finger passes built-in UV whenever at least one stored finger exists. It isn't listed by enumerateEnrollments, removeEnrollment can't delete it, and it survives authenticatorReset.Reworked as the third option from #844: the environment owns both the templates and their metadata, so there is no one-to-one invariant left on the library side (this also covers #846 and #840).
Fingerprintgainsinit,list_enrollmentsandset_friendly_name, andremove_enrollmentdeletes the enrollment as well as the template. Capturing the last sample enrolls the template, and the implementation deletes it from the sensor if it can't store the enrollment.check_fingerprintonly matches enrolled templates.api::fingerprint::helperimplements that storage on top ofPersist, the way the key store helper does, keeping the template IDs and friendly names inkeys::TEMPLATE_INFOS.Persistloses its five fingerprint methods and the library no longer touches the store for this.IdentifyResult::Matchagainst them, and deletes templates that are not enrolled ininit. It can't restrict identification to a set of templates, sinceIdentify::newtakes a single optional template ID.TestEnvandTestFingerprint, so it mirrors a real environment and the helper is covered by the library tests.Since the trait changes, other
Envimplementations need to implement the three new methods and keep the metadata with the templates.test_perform_built_in_uv_unenrolled_templateleaves a template on the sensor without enrolling it and checks that built-in UV rejects it,test_init_removes_unenrolled_templatechecks thatinitdeletes it, andtest_enrollment_database_fullnow checks that a template the environment couldn't enroll is gone from the sensor.run_desktop_tests.shexceptcargo audit, which I don't have installed; no dependencies changed)