Commit d282bc5
feat: Ensure passkeys cannot have duplicate pubkeys (#3626)
<!-- Make sure you talk to us before submitting changes. See
CONTRIBUTING.md. -->
# Motivation
This PR enforces that public keys are unique for all (newly added)
passkeys.
The enforcement happens by maintaining a new stable index
`passkey_public_key -> anchor_number` (for consistency w.r.t. the
previously added `recovery_key_principal -> anchor_number` index). While
registering a new passkey, this PR adds a precondition that enforces
that it's not already present in that index, and then the index is
extended with the public key of a passkey that is successfully
registered.
For existing passkeys, the index will be populated for all passkeys of
all anchors in an arbitrary order. This means there might already be
duplicate passkey public keys in II, and those will be kept, but new
duplicates will not be allowed. This is reasonable, as existing
duplicates are out of scope of the current threat model.
# Changes
* Added new stable index `lookup_anchor_with_passkey_pubkey_hash_memory`
to track passkey public keys
* Added validation checks in all device registration flows to prevent
(new) duplicate passkey public keys
* Introduced new error variants across API layers to handle duplicate
public key scenarios
# Tests
Added tests to cover all passkey-based device creation flows:
1.
`should_enforce_unique_passkey_pubkeys_and_free_them_on_change_and_remove`
2. `should_enforce_unique_passkey_pubkeys_in_registration_mode_flows`
3. `should_enforce_unique_passkey_pubkeys_in_legacy_flows`
---------
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: sea-snake <104725312+sea-snake@users.noreply.github.com>
Co-authored-by: sea-snake <sea-snake@outlook.com>1 parent 6477b90 commit d282bc5
File tree
29 files changed
+1209
-197
lines changed- src
- frontend
- src/lib
- generated
- legacy/flows/addDevice/welcomeView
- locales
- tests/e2e-playwright/routes
- internet_identity_interface/src/internet_identity
- types
- internet_identity
- src
- anchor_management
- registration
- migrations
- storage/storable
- tests/integration
- activity_stats
- anchor_management
- config
- v2_api
- identity_register
29 files changed
+1209
-197
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| |||
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
| 181 | + | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| |||
190 | 192 | | |
191 | 193 | | |
192 | 194 | | |
| 195 | + | |
193 | 196 | | |
194 | 197 | | |
195 | 198 | | |
196 | 199 | | |
197 | 200 | | |
198 | 201 | | |
| 202 | + | |
199 | 203 | | |
200 | 204 | | |
201 | 205 | | |
| |||
0 commit comments