Skip to content

A keychain zone without its class key is an error, not a panic - #10

Open
gregakespret wants to merge 2 commits into
findmy-export-supportfrom
fix/missing-zone-key-no-panic
Open

gregakespret wants to merge 2 commits into
findmy-export-supportfrom
fix/missing-zone-key-no-panic

Conversation

@gregakespret

Copy link
Copy Markdown
Owner

When a keychain zone has no class key, insert_keychain now returns PushError::ZoneKeyMissing(zone) instead of panicking with expect("Insert class key not found"). A zone ends up keyless when we skip its TLK share because the share failed its signature check (or was never sent). KeychainClientState::get_class_key is the lookup that returns the error.

PCSPrivateKey::get_service_key checks the service zone's classC key before it goes down the mint path. If the key is missing, it stops before get_master_key can upload a new master key for a service-key save that is bound to fail. If the zone does hold its key, behaviour is unchanged.

Why ≥80%: seven prod exports (sessions a16401a1, 0864073b, 2b7c9efb, 993ad8d2, eb2172b0, 8683d33e, 7185a364, Oct 10–11) all show the same sequence:

  1. "Skipping TLK share for Manatee: it failed its signature check".
  2. One to two seconds later, the panic at keychain.rs:1349 of bcc7da2.

FIND_MY_SERVICE.zone is Manatee, so the save that panicked is the one now guarded. class_key_tests covers both cases: a zone without its key is an error, and other zones' keys don't stand in for it. A zone-blind lookup fails that test. All 12 lib tests pass.

Not verified:

  • insert_keychain and get_service_key themselves aren't exercised; that needs a live CloudKit session and an affected account.
  • Out of scope, existing upstream behaviour: if the current-key pointer exists but its item can't be decrypted while the zone key is present, this code still mints a new key.
  • Gates at base: rustfmt is not clean (my hunks are), and clippy fails on src/imessage/messages.rs:1138/1144 (file not touched here). CI only runs cargo build --release.

Consumer: gregakespret/export-findmy, branch fix/missing-zone-key-no-panic. It maps the error to trust_circle_signature.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HW3tPgNjtZokBFXjYn8Qkn

gregakespret and others added 2 commits October 12, 2026 21:29
A TLK share that fails its signature check is skipped, which leaves its
zone with no class key. Saving the Find My service key into Manatee then
hit expect("Insert class key not found") in insert_keychain and took the
whole export task down. Return PushError::ZoneKeyMissing instead.

get_service_key checks for the same key before minting, so a save that
cannot succeed doesn't first make get_master_key upload a new master key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HW3tPgNjtZokBFXjYn8Qkn
rustfmt on the lines c9c30ab added; the rest of keychain.rs is untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HW3tPgNjtZokBFXjYn8Qkn
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.

1 participant