Commit e573a9c
committed
fix: accept delegation chains issued by a non-mainnet auth provider
A chain from a local Internet Identity carries a canister signature whose
certificate only BLS-verifies against that replica's root key. Two things made
such an identity unusable:
`icp identity principal`, `account-id` and `delegation sign` pass no network
root key and have no flag to supply one, so the chain was always checked
against mainnet and always failed.
`DelegatedIdentity::new` stops at the first link it cannot verify, so the links
behind the canister signature went unchecked, at load time and at link time —
including in `create_identity`, which documents its session-key check as
running before anything is written.
Treat a resolved network root key as authoritative and consult nothing else: a
chain that fails against it belongs to another network. Where no root key could
be resolved, verify each link as far as it can be verified without one. For a
canister signature that is everything but the certificate's own BLS signature:
that the CBOR decodes, that the signing canister's certified data matches the
signature tree, and that the tree carries a signature over exactly this
delegation. ic-agent verifies canister signatures only as a whole, so those
checks are repeated here rather than skipped with the trust check.
Key the identity cache by the root key as well as the selection: the same
identity validates differently against different networks, so an entry cached
for one must not be handed to a load that resolved another. `canister create`
and `canister settings update` now take the caller principal from the agent
rather than loading the same identity a second time without a root key.
Also check expiry before `icp identity link web` writes a chain, as the import
and load paths already do.1 parent 763a55f commit e573a9c
7 files changed
Lines changed: 826 additions & 67 deletions
File tree
- crates
- icp-cli/src/commands/canister
- settings
- icp
- src/identity
Some 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 | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | 358 | | |
363 | 359 | | |
364 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
365 | 364 | | |
366 | 365 | | |
367 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
391 | 390 | | |
392 | 391 | | |
393 | 392 | | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | 393 | | |
400 | 394 | | |
401 | 395 | | |
402 | 396 | | |
403 | 397 | | |
404 | 398 | | |
405 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
406 | 403 | | |
407 | 404 | | |
408 | 405 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| |||
0 commit comments