-
Notifications
You must be signed in to change notification settings - Fork 13
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
Security issue: Keychain Item Accessibility Constants missing #2
Comments
+1 to this. |
Yes, I'd like to be able to set kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly Anyone care to show where the easiest place to put this would be? |
From line 90 in ACSimpleKeychain.m - (BOOL)storeUsername:(NSString *)username password:(NSString *)password identifier:(NSString *)identifier info:(NSDictionary *)info forService:(NSString *)service
{
if ([self deleteCredentialsForUsername:username service:service] &&
[self deleteCredentialsForIdentifier:identifier service:service])
{
NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
(__bridge id)(kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly), (__bridge id)kSecAttrAccessible,
(__bridge id)kSecClassGenericPassword, (__bridge id)kSecClass,
[username dataUsingEncoding:NSUTF8StringEncoding], (__bridge id)kSecAttrAccount,
[identifier dataUsingEncoding:NSUTF8StringEncoding], (__bridge id)kSecAttrGeneric,
[service dataUsingEncoding:NSUTF8StringEncoding], (__bridge id)kSecAttrService, nil];
[dictionary setValue:[password dataUsingEncoding:NSUTF8StringEncoding] forKey:(__bridge id)kSecValueData];
NSMutableData *miscData = [NSMutableData data];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:miscData];
[archiver encodeObject:info forKey:ACKeychainInfo];
[archiver finishEncoding];
[dictionary setValue:miscData forKey:(__bridge id)kSecAttrComment];
OSStatus status = SecItemAdd((__bridge CFDictionaryRef)dictionary, NULL);
return (status == errSecSuccess);
}
return NO;
} Hope that helps. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
you should add the kSecAttrAccessibleWhenUnlocked value for the kSecAttrAccessible key. If you don't do that the keychain information can be hacked easily.
More information:
http://stackoverflow.com/questions/3558252/ios-keychain-security
https://developer.apple.com/library/ios/#documentation/Security/Reference/keychainservices/Reference/reference.html#//apple_ref/doc/constant_group/Keychain_Item_Accessibility_Constants
Thank you =)
The text was updated successfully, but these errors were encountered: