iphone keychain items persist after application uninstall?
Asked Answered
P

2

40

I am playing with idandersen's scifihifi-iphone code for keychain and came across the following behavior - I set the password using, say

[SFHFKeychainUtils storeUsername:@"User" andPassword:@"123"
                  forServiceName:@"TestService" updateExisting:YES error:&error];

Then delete test application from device and install it again - the previously set password appears to remain in keychain...
Is it the expected behavior? And is there a way to make sure that password I set will be deleted with the application?

Pinfeather answered 8/9, 2010 at 20:10 Comment(0)
P
34

Yes, this is the expected and correct behavior.

Some keychain items may be shared with other apps you control (that share the same keychain item access group).

You should just leave the info alone when your app is removed. You have no callback or method of removing the keychain items on deletion of your app.

Puppis answered 9/9, 2010 at 21:1 Comment(5)
So the fact that I don't want info stay in the keychain after app uninstall might imply that keychain is simply wrong place to store it, right?Pinfeather
@Mihai Damian items can be shared between apps, but are not by default; you have to set access groups.Chi
Its like how UIPasteboard is implemented.Private yet sharedFanlight
"In iOS, each application always has access to its own keychain items; the user is never asked to unlock the keychain. Whereas in OS X any application can access any keychain item provided the user gives permission, in iOS an application can access only its own keychain items." Please correct your answer, it is misleading! source: developer.apple.com/library/ios/#documentation/security/…Unfurl
@Unfurl Despite what the passage you quoted says, you can share a keychain between two applications you write, if you specify the same keychain group id in the keychain-access-groups in the entitlements file. See Apple's documentation for SecItemAdd() for more details. Apple's GenericKeychain sample code demonstrates how to do this.Studbook
C
4

Edit: They finally reverted the behavior described in my answers, so until everybody move away from that range of versions, this should not happen anymore.

Unfortunately, this is not the case anymore. It has been changed since iOS 10.3.

This is an intentional change in iOS 10.3 to protect user privacy. Information that can identify a user should not be left on the device after the app that created it has been removed.

It has never been a part of the API contract that keychain items created by an app would survive when the app is removed. This has always been an implementation detail.

See the reference here.

Climactic answered 23/1, 2018 at 15:50 Comment(5)
Actually, this has been reverted and the information is not valid any more as far as I know.Gean
@Gean Indeed, unless some people are still on those versions of iOS. :) I added a note. thanks for the update.Climactic
I think it was only in 10.3 Beta 2 till Beta 5. Therefore normal people shouldn't actually see that behavior at allGean
@Gean My client has 1.5 Millions of mobile users and we had reports of several of them having the issue, so it definitively went live at some point. I agree it wasn't the vast majority though.Climactic
A lot of people in IT install beta versions even if its very unwise. My crashlogs are already polluted by iOS 12 crashes caused by beta bugs. The best course of action is to ignore problems on betas.Gean

© 2022 - 2024 — McMap. All rights reserved.