medium · M9 · MASVS-STORAGE-2 · PTKD-IOS-KEYCHAIN-ACCESSIBLE
Keychain item accessible while locked
A Keychain item uses kSecAttrAccessibleAlways (or …AlwaysThisDeviceOnly), so it is readable even when the device is locked, including from a backup or a lost/stolen locked device.
How it is exploited
A Keychain item is stored with kSecAttrAccessibleAlways, so it stays readable even while the device is locked. An attacker with a lost or stolen locked device, or an unencrypted backup, extracts the secret without ever unlocking the phone.
Why it matters
Tokens and credentials meant to be protected by the lock screen are recoverable from a locked or backed-up device.
How to fix it
- Use kSecAttrAccessibleWhenUnlockedThisDeviceOnly for secrets that only need foreground access.
- Use kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly only when a background task genuinely needs the item; kSecAttrAccessibleAlways is deprecated.
Does your app have this?
PTKD checks your build or your source project for PTKD-IOS-KEYCHAIN-ACCESSIBLE and every other check in this knowledge base.
Scan your appReferences
Related checks (M9)
- Android file or preferences created world-readable or world-writable
- Public Supabase bucket can be listed by anyone
- Public Supabase storage bucket (heuristic)
- Sensitive data written to external storage
- Sensitive data written to the log
- Secret written to device storage
- Tokens or passwords stored in plain app preferences
- Tokens or passwords written to the device log