iOS autodelete Keychain items after uninstall?

Will iOS clear an application's Keychain after the app is uninstalled? I seem to recall that an app's keychain items would be deleted by iOS some X days/hours/minutes after an app is deleted, however I can't find any reference to this behavior.


Edit:


So based on the thread below, it seems that the keychain survives an app uninstallation as a side effect of implementation. If so, it would seem that auto-deleting keychain items after app removal wouldn't be documented.


Re: iOS Keychain values survive to app uninstall


Out of curiousity, does anyone have insight into the observed behavior?

It seems that the keychain is [not] deleted when an app is deleted.

That’s expected behaviour (except in some beta releases of 10.3). See my post upthread for the gory details.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Still the case with iOS 17.5 as of June 2024. The keychain is definitely preserved even after app uninstall/reinstall. Quinn's suggestion about implementing some kind of entanglement (or even stembermichal's suggestion of a Bool flag in UserDefaults) appears necessary. Basically you have to implement your own test to determine if the keychain item is a holdover from a previous install.

I have a bigger concern that an app can store confidential data in the keychain that will never ever get deleted. Ever. There isn't any way to completely delete a keychain tied to an account.
If you reset your iphone and set it up with the same apple account, Apple downloads the stored icloud keychain to the phone before you get a chance to tell it not to. If you disable keychain sync at that point, the phone doe NOT prompt you to delete the existing keychain data despite documentation online saying that it does. If you log out of icloud on the phone, you get the option of removing the local copy. But the moment you sign in again, it comes back.

Deleting all the passwords in Safari or the password app does not delete all keychain data

If an app is designed to use a keychain access group, deleting that app will not delete the keychain data, yet that data or app is not listed anywhere in the Passwords app or anything else purporting to show keychain data.

That leaves trying to delete the keychain for an account on another device. MacOS provides only the Password app to view keychain data and the ability to enable or disable syncing. Disabling it does nothing to the copy stored on iCloud.

account.apple.com provides no access to keychain management other than indirectly e.g. changing your password, app-specific passwords, etc.

So if there's no way to view and / or delete / wipe the keychain data stored on icloud, and there's no way to prevent that data from being downloaded automatically to any device you sign in to using that account, and removing the keychain data on any given device does not modify the copy stored on the cloud,

How do I ensure that any rogue apps that maliciously stored data in the keychain can not access that same data in the future, either once the app is re-installed or via a different app configured with the same keychain access group?

How can there be any real security of confidential data if someone can write an app that does this, and then provides another party with the keychain access group keys?

It makes no difference if Apple claims that their phone is secure with such an obvious and gaping back door available. Enabling Advanced Data Protection doesnt list keychain data or the keychain in the list of types of data that are securely encrypted. And while the keychain data is encrypted, all it takes is for the user to install App A at some point, which stores unknown data in the keychain, then the user deletes App A and later on installs App B. And App B immediately gains access to that confidential data.

I don't want to get into some debate about why an app would do this, or caveat emptor; the point is that it's possible and would be an obvious method for malicious actors to use.

All because Apple doesn't provide a method for a user (NOT an app dev) to clear out their keychain.

iOS autodelete Keychain items after uninstall?
 
 
Q