ios - 使用 KeychainTouchID(相对更多)存储的项目在越狱设备上是否安全?

标签 ios security keychain touch-id

我对 iOS 钥匙串(keychain)的理解是,它在越狱设备上是不安全的。

我想知道是否有人使用 kSecAccessControlTouchIDAny 将值存储在钥匙串(keychain)中,因为它在 this example from Apple 中使用。 , 如果有额外级别的保护,即使是在越狱设备上?

将文本存储到钥匙串(keychain)中的示例的相关摘录:

- (void)addTouchIDItemAsync {
CFErrorRef error = NULL;

// Should be the secret invalidated when passcode is removed? If not then use kSecAttrAccessibleWhenUnlocked
SecAccessControlRef sacObject = SecAccessControlCreateWithFlags(kCFAllocatorDefault,
                                            kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly,
                                            kSecAccessControlTouchIDAny, &error);
if (sacObject == NULL || error != NULL) {
    NSString *errorString = [NSString stringWithFormat:@"SecItemAdd can't create sacObject: %@", error];

    self.textView.text = [self.textView.text stringByAppendingString:errorString];

    return;
}

/*
    We want the operation to fail if there is an item which needs authentication so we will use
    `kSecUseNoAuthenticationUI`.
*/
NSData *secretPasswordTextData = [@"SECRET_PASSWORD_TEXT" dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *attributes = @{
    (__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
    (__bridge id)kSecAttrService: @"SampleService",
    (__bridge id)kSecValueData: secretPasswordTextData,
    (__bridge id)kSecUseNoAuthenticationUI: @YES,
    (__bridge id)kSecAttrAccessControl: (__bridge_transfer id)sacObject
};

dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    OSStatus status =  SecItemAdd((__bridge CFDictionaryRef)attributes, nil);

    NSString *message = [NSString stringWithFormat:@"SecItemAdd status: %@", [self keychainErrorToString:status]];

    [self printMessage:message inTextView:self.textView];
});

最佳答案

这取决于您如何定义安全。请记住,在越狱设备上,任何 API 都可能受到中间人攻击。所以后端存储机制可能无关紧要。越狱设备上的攻击者可以简单地拦截您对 Keychain API 的调用并读取您传递给它的任何参数。

关于ios - 使用 KeychainTouchID(相对更多)存储的项目在越狱设备上是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35162592/

相关文章:

ios - 使用 FBWebDialogs (Facebook SDK 3.5) 成功发布后的 nil resultURL

ios - 更改 UIScrollVIew Content Inset 触发 scrollViewDidScroll

android - 有没有办法检查应用程序签名是否已调试或已发布?

xcode - 本地iOS开发证书

ios - 如何使用 Locksmith 保存和加载多个凭据?

ios - 如何在不调用生物识别的情况下检查现有的钥匙串(keychain)项目

ios - 如何从 UICollectionView 过渡到 UIViewController,如 Pinterest/Evernote

ios - 网络扩展授权,如何启用?

WCF安全绑定(bind)问题

javascript - 通过 <script> 标签加载到网页中的 JavaScript 文件的源可以被该页面中的其他 JavaScript 读取吗?