Repository navigation
fix(vaultstore): catch Keystore-key-deleted race during PIN unlock - #580
Conversation
If the Keystore key is deleted between forExisting()'s existence check and the subsequent unwrap() call inside unlockWithPin, the resulting KeyStoreException escaped uncaught instead of mapping to UnlockOutcome.KeystoreKeyLost — the same recovery-key fallback path forExisting()'s own KeystoreKeyLostException catch already routes to. Widened the catch to cover this race, without counting it toward the failed-attempt throttle (same as the existing early-return path, since the user didn't supply a wrong credential). Closes #566.
8a79da7 to
991a94a
Compare
The pull_request "ready_for_review" event didn't fire a fresh Actions run within several minutes of gh pr ready — jvm-tests.yml's unit-test job is gated to skip on drafts, so no CI run has actually exercised it yet on this PR. Empty commit to produce a synchronize event instead.
📱 iOS Build Status: PASSED⏭️ iOS Simulator Build & Unit Tests - skipped iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
QA verification — PR #580 vs issue #566Issue type: bug report (no explicit checklist) → checklist is "repro no longer reproduces, and a regression test proves it."
Note, not a blocker: the exact JVM exception type a real Android Keystore throws for this specific race (key deleted between Verdict rationale: fix matches the issue, regression test is proven real (fails pre-fix, passes post-fix), full suite green, conventions followed, no regressions found. QA verdict: PASS |
Principal review — verdict:
|
Summary
If the Keystore key is deleted between
forExisting()'s existence check and the subsequentunwrap()call insideunlockWithPin, the resultingKeyStoreExceptionescaped uncaught instead of mapping toUnlockOutcome.KeystoreKeyLost(the path that correctly routes the user to recovery-key unlock). Widened thecatchblock inVaultStore.unlockWithPinto also coverjava.security.KeyStoreException, returningKeystoreKeyLostwithout incrementing the failed-attempt throttle (same as the existing early-return path — the user didn't supply a wrong credential here).A correct, tested fix for this exact bug already existed in the now-stalled batch PR #537 (L3 of issue #530's split); this PR reimplements that same pattern directly against current
dev, since #537 diverged (addedmutationMutex/openReadersin the meantime) and is itself stuck onstatus:needs-info.Testing
HardwareKeyWrapFactorywhoseforExisting()succeeds (key still exists) but whose returnedHardwareKeyWrap.unwrap()throwsKeyStoreException, simulating the deletion race.newStore()'s test helper parameter type fromFakeHardwareKeyWrapFactoryto theHardwareKeyWrapFactoryinterface so the anonymous test double can be passed in.catchblock, then restored it — perAGENTS.md's "prove a new test can fail" rule../gradlew :core:vaultstore:testDebugUnitTestpasses locally (23/23 tests inVaultStoreTest).Risk
Touches
core/vaultstore/**, onagent-policy.yml'ssensitive_pathslist — this will be force-classifiedrisk:highregardless of size. That's correct here: this changes behavior in the Keystore-key-loss path of the vault unlock flow, though the change itself is narrowly scoped (widen one catch clause + a regression test).Closes #566.