界: Encapsulation

カプセル化とは、強い境界線を引くことです。Web ブラウザの場合は、自分のモバイル コードが他のモバイル コードに悪用されないようにすることを意味します。サーバー上では、検証されたデータと検証されていないデータ、あるユーザーのデータと別のユーザーのデータ、またはユーザーが見ることを許可されたデータと許可されていないデータの区別などを意味する場合があります。

Biometric Authentication: Insufficient Touch ID Protection

Abstract
アプリケーションはタッチ ID を使用してキーチェーンにアイテムを格納しますが、有効なフィンガープリントをキーチェーンのアイテムの格納時に使用可能であったフィンガープリントに制限することはできません。
Explanation
キーチェーン サービスを使用して、タッチ ID ベースの認証を実装できます。それには、キーチェーンにアイテムを格納して、後からアイテムを取得するにはフィンガープリントを使用することをユーザーに要求するアクセス制御を設定します。次のポリシーを使用して、フィンガープリントを使用してユーザーを認証する方法を定義できます。

- kSecAccessControlUserPresence: タッチ ID またはパスコードでのアクセスへの制約。タッチ ID が使用可能である、または登録されている必要はありません。フィンガープリントが追加または削除された場合でも、引き続きタッチ ID でアイテムにアクセスできます。
- kSecAccessControlTouchIDAny: 登録されている任意のフィンガープリントのタッチ ID でのアクセスへの制約。フィンガープリントが追加または削除された場合、アイテムは無効化されません。
- kSecAccessControlTouchIDCurrentSet: 現在登録されているフィンガープリントのタッチ ID でのアクセスへの制約。フィンガープリントが追加または削除された場合、アイテムは無効化されます。

タッチ ID を使用する場合、kSecAccessControlTouchIDCurrentSet 属性を使用して、フィンガープリントが今後追加または削除されるのを防ぐ必要があります。

例 1: 次のコードは、今後登録されるフィンガープリントでキーチェーンのアイテムをロック解除できる kSecAccessControlTouchIDAny 制約を使用しています。


...
SecAccessControlRef sacRef = SecAccessControlCreateWithFlags(kCFAllocatorDefault,
kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly,
kSecAccessControlTouchIDCurrentSet,
nil);
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id) kSecClass];
[dict setObject:account forKey:(__bridge id)kSecAttrAccount];
[dict setObject:service forKey:(__bridge id) kSecAttrService];
[dict setObject:token forKey:(__bridge id)kSecValueData];
...
[dict setObject:sacRef forKey:(__bridge id)kSecAttrAccessControl];
[dict setObject:@"Please authenticate using the Touch ID sensor." forKey:(__bridge id)kSecUseOperationPrompt];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
OSStatus status = SecItemAdd((__bridge CFDictionaryRef)dict, nil);
});
...
References
[1] David Thiel iOS Application Security: The Definitive Guide for Hackers and Developers No Starch Press
[2] Integrating Touch ID Into Your iOS Applications Cigital
[3] Don't Touch Me That Way nVisium
[4] SecAccessControlCreateFlags Apple
[5] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[6] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 4.0
[7] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 3
[8] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[9] Standards Mapping - Common Weakness Enumeration CWE ID 287
[10] Standards Mapping - Common Weakness Enumeration Top 25 2019 [13] CWE ID 287
[11] Standards Mapping - Common Weakness Enumeration Top 25 2020 [14] CWE ID 287
[12] Standards Mapping - Common Weakness Enumeration Top 25 2021 [14] CWE ID 287
[13] Standards Mapping - Common Weakness Enumeration Top 25 2022 [14] CWE ID 287
[14] Standards Mapping - Common Weakness Enumeration Top 25 2023 [13] CWE ID 287
[15] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001958
[16] Standards Mapping - FIPS200 CM, SC
[17] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[18] Standards Mapping - NIST Special Publication 800-53 Revision 4 IA-3 Device Identification and Authentication (P1)
[19] Standards Mapping - NIST Special Publication 800-53 Revision 5 IA-3 Device Identification and Authentication
[20] Standards Mapping - OWASP Top 10 2004 A10 Insecure Configuration Management
[21] Standards Mapping - OWASP Top 10 2007 A9 Insecure Communications
[22] Standards Mapping - OWASP Top 10 2010 A9 Insufficient Transport Layer Protection
[23] Standards Mapping - OWASP Top 10 2021 A07 Identification and Authentication Failures
[24] Standards Mapping - OWASP Application Security Verification Standard 4.0 2.7.1 Out of Band Verifier Requirements (L1 L2 L3), 2.7.2 Out of Band Verifier Requirements (L1 L2 L3), 2.7.3 Out of Band Verifier Requirements (L1 L2 L3), 2.8.4 Single or Multi Factor One Time Verifier Requirements (L2 L3), 2.8.5 Single or Multi Factor One Time Verifier Requirements (L2 L3), 3.7.1 Defenses Against Session Management Exploits (L1 L2 L3), 9.2.3 Server Communications Security Requirements (L2 L3)
[25] Standards Mapping - OWASP Mobile 2014 M5 Poor Authorization and Authentication
[26] Standards Mapping - OWASP Mobile 2024 M3 Insecure Authentication/Authorization
[27] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-AUTH-1, MASVS-AUTH-2
[28] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 4.1, Requirement 6.5.10
[29] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 4.1, Requirement 6.3.1.4, Requirement 6.5.9
[30] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 4.1, Requirement 6.5.4
[31] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 4.1, Requirement 6.5.4
[32] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 4.1, Requirement 6.5.4
[33] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 4.1, Requirement 6.5.4
[34] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 4.1, Requirement 6.5.4
[35] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 4.2.1, Requirement 6.2.4
[36] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 5.3 - Authentication and Access Control
[37] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 5.3 - Authentication and Access Control
[38] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 5.3 - Authentication and Access Control, Control Objective C.2.1.2 - Web Software Access Controls
[39] Standards Mapping - SANS Top 25 2010 Porous Defenses - CWE ID 311
[40] Standards Mapping - SANS Top 25 2011 Porous Defenses - CWE ID 311
[41] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001650 CAT II
[49] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001650 CAT II
[50] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001650 CAT II
[51] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001650 CAT II
[52] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001650 CAT II
[53] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001650 CAT II
[54] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001650 CAT II
[55] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001650 CAT II
[56] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001650 CAT II
[57] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001650 CAT II
[58] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001650 CAT II
[59] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001650 CAT II
[60] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001650 CAT II
[61] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001650 CAT II
[62] Standards Mapping - Web Application Security Consortium Version 2.00 Insufficient Authentication (WASC-01)
[63] Standards Mapping - Web Application Security Consortium 24 + 2 Insufficient Authentication
desc.dataflow.objc.biometric_authentication_insufficient_touch_id_protection
Abstract
アプリケーションはタッチ ID を使用してキーチェーンにアイテムを格納しますが、有効なフィンガープリントをキーチェーンのアイテムの格納時に使用可能であったフィンガープリントに制限することはできません。
Explanation
キーチェーン サービスを使用して、タッチ ID ベースの認証を実装できます。それには、キーチェーンにアイテムを格納して、後からアイテムを取得するにはフィンガープリントを使用することをユーザーに要求するアクセス制御を設定します。次のポリシーを使用して、フィンガープリントを使用してユーザーを認証する方法を定義できます。

- kSecAccessControlUserPresence: タッチ ID またはパスコードでのアクセスへの制約。タッチ ID が使用可能である、または登録されている必要はありません。フィンガープリントが追加または削除された場合でも、引き続きタッチ ID でアイテムにアクセスできます。
- kSecAccessControlTouchIDAny: 登録されている任意のフィンガープリントのタッチ ID でのアクセスへの制約。フィンガープリントが追加または削除された場合、アイテムは無効化されません。
- kSecAccessControlTouchIDCurrentSet: 現在登録されているフィンガープリントのタッチ ID でのアクセスへの制約。フィンガープリントが追加または削除された場合、アイテムは無効化されます。

タッチ ID を使用する場合、kSecAccessControlTouchIDCurrentSet 属性を使用して、フィンガープリントが今後追加または削除されるのを防ぐ必要があります。

例 1: 次のコードは、今後登録されるフィンガープリントでキーチェーンのアイテムをロック解除できる kSecAccessControlTouchIDAny 制約を使用しています。


...
let flags = SecAccessControlCreateWithFlags(kCFAllocatorDefault,
kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly,
.TouchIDAny,
nil)

var query = [String : AnyObject]()
query[kSecClass as String] = kSecClassGenericPassword
query[kSecAttrService as String] = service as AnyObject?
query[kSecAttrAccount as String] = account as AnyObject?
query[kSecValueData as String] = secret as AnyObject?
...
query[kSecAttrAccessControl as String] = sacRef
query[kSecUseOperationPrompt as String] = "Please authenticate using the Touch ID sensor."

SecItemAdd(query as CFDictionary, nil)
...
References
[1] David Thiel iOS Application Security: The Definitive Guide for Hackers and Developers No Starch Press
[2] Integrating Touch ID Into Your iOS Applications Cigital
[3] Don't Touch Me That Way nVisium
[4] SecAccessControlCreateFlags Apple
[5] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[6] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 4.0
[7] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 3
[8] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[9] Standards Mapping - Common Weakness Enumeration CWE ID 287
[10] Standards Mapping - Common Weakness Enumeration Top 25 2019 [13] CWE ID 287
[11] Standards Mapping - Common Weakness Enumeration Top 25 2020 [14] CWE ID 287
[12] Standards Mapping - Common Weakness Enumeration Top 25 2021 [14] CWE ID 287
[13] Standards Mapping - Common Weakness Enumeration Top 25 2022 [14] CWE ID 287
[14] Standards Mapping - Common Weakness Enumeration Top 25 2023 [13] CWE ID 287
[15] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001958
[16] Standards Mapping - FIPS200 CM, SC
[17] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[18] Standards Mapping - NIST Special Publication 800-53 Revision 4 IA-3 Device Identification and Authentication (P1)
[19] Standards Mapping - NIST Special Publication 800-53 Revision 5 IA-3 Device Identification and Authentication
[20] Standards Mapping - OWASP Top 10 2004 A10 Insecure Configuration Management
[21] Standards Mapping - OWASP Top 10 2007 A9 Insecure Communications
[22] Standards Mapping - OWASP Top 10 2010 A9 Insufficient Transport Layer Protection
[23] Standards Mapping - OWASP Top 10 2021 A07 Identification and Authentication Failures
[24] Standards Mapping - OWASP Application Security Verification Standard 4.0 2.7.1 Out of Band Verifier Requirements (L1 L2 L3), 2.7.2 Out of Band Verifier Requirements (L1 L2 L3), 2.7.3 Out of Band Verifier Requirements (L1 L2 L3), 2.8.4 Single or Multi Factor One Time Verifier Requirements (L2 L3), 2.8.5 Single or Multi Factor One Time Verifier Requirements (L2 L3), 3.7.1 Defenses Against Session Management Exploits (L1 L2 L3), 9.2.3 Server Communications Security Requirements (L2 L3)
[25] Standards Mapping - OWASP Mobile 2014 M5 Poor Authorization and Authentication
[26] Standards Mapping - OWASP Mobile 2024 M3 Insecure Authentication/Authorization
[27] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-AUTH-1, MASVS-AUTH-2
[28] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 4.1, Requirement 6.5.10
[29] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 4.1, Requirement 6.3.1.4, Requirement 6.5.9
[30] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 4.1, Requirement 6.5.4
[31] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 4.1, Requirement 6.5.4
[32] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 4.1, Requirement 6.5.4
[33] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 4.1, Requirement 6.5.4
[34] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 4.1, Requirement 6.5.4
[35] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 4.2.1, Requirement 6.2.4
[36] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 5.3 - Authentication and Access Control
[37] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 5.3 - Authentication and Access Control
[38] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 5.3 - Authentication and Access Control, Control Objective C.2.1.2 - Web Software Access Controls
[39] Standards Mapping - SANS Top 25 2010 Porous Defenses - CWE ID 311
[40] Standards Mapping - SANS Top 25 2011 Porous Defenses - CWE ID 311
[41] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3250.1 CAT I, APP3250.2 CAT I, APP3250.3 CAT II, APP3250.4 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001650 CAT II
[49] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001650 CAT II
[50] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001650 CAT II
[51] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001650 CAT II
[52] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001650 CAT II
[53] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001650 CAT II
[54] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001650 CAT II
[55] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001650 CAT II
[56] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001650 CAT II
[57] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001650 CAT II
[58] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001650 CAT II
[59] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001650 CAT II
[60] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001650 CAT II
[61] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001650 CAT II
[62] Standards Mapping - Web Application Security Consortium Version 2.00 Insufficient Authentication (WASC-01)
[63] Standards Mapping - Web Application Security Consortium 24 + 2 Insufficient Authentication
desc.dataflow.swift.biometric_authentication_insufficient_touch_id_protection