-
Notifications
You must be signed in to change notification settings - Fork 1
fix: keychain access persistence #326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a security issue where sensitive keychain data (mnemonics, passphrases, PINs) persisted after app uninstall on iOS. The solution implements a Documents directory marker file to reliably detect app reinstallation and automatically wipes orphaned keychain data.
Changes:
- Implemented installation marker mechanism using Documents directory for reliable reinstall detection
- Added automatic detection and cleanup of orphaned native and React Native keychain data
- Enhanced keychain security attributes to prevent iCloud sync and restrict to device-only access
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Bitkit/Utilities/InstallationMarker.swift | New utility for managing installation marker file in Documents directory |
| Bitkit/Utilities/Keychain.swift | Updated security attributes to use device-only access and disable synchronization |
| Bitkit/Services/MigrationsService.swift | Added orphaned RN keychain detection and comprehensive cleanup methods |
| Bitkit/AppScene.swift | Integrated orphaned keychain handling at app startup |
| Bitkit/Utilities/AppReset.swift | Added marker deletion during app reset |
| BitkitTests/InstallationMarkerTests.swift | Comprehensive tests for installation marker functionality |
| BitkitTests/OrphanedKeychainTests.swift | Tests for orphaned keychain detection and cleanup |
| BitkitTests/RNMigrationCleanupTests.swift | Tests for RN migration cleanup functionality |
| BitkitTests/KeychainTests.swift | Enhanced tests to verify security attributes and device-only access |
Fix #293
Description
This PR prevents sensitive keychain data (mnemonics, passphrases, PINs) from being recovered after app uninstall by:
This only affects the upgrade path. Normal usage after installation and migration from RN works correctly.
Why Documents Marker?
The Keychain data is stored in App Group storage, which persists after uninstall on iOS. The Documents directory is reliably deleted on uninstall, so the marker file serves as the reliable detection mechanism.
Testing Scenarios
Screenshot / Video
unninstall-master-install-rn-migrate.mp4
install-over-master.mp4
reset-and-restore.mp4
delete-and-restore.mp4
recover-from.RN.mp4