界: Security Features

软件安全不是安全软件。此处我们关注的主题包括身份验证、Access Control、机密性、加密和权限管理。

Authentication Bad Practice: Missing Check against Protection Space

Abstract
NSURLConnection 代理处理身份验证质询,而无需先验证应用程序是否知道如何处理特定保护空间的身份验证质询。
Explanation
NSURLProtectionSpace 对象代表需要身份验证的服务器或服务器上的某个区域(通常称为 Realm)。
当建立需要对保护空间进行身份验证的 URL 连接时,将在调用 NSURLConnectionDelegate.connection(_:canAuthenticateAgainstProtectionSpace:) 方法之后立即调用应执行身份验证的 NSURLConnectionDelegate.connection(_:didReceive:) 方法。这样,NSURLConnectionDelegate 便可在尝试对保护空间进行身份验证之前检查它。通过返回 true,代理指示它可以处理身份验证,在对 connection(_:didReceive:) 的后续调用中它也确实这样做了。如果您的代理未实施此方法且保护空间使用客户端证书身份验证或服务器信任身份验证,系统将会尝试使用用户的密钥链来验证哪些可能不是所需的行为。
References
[1] connection(_:canAuthenticateAgainstProtectionSpace:) API documentation Apple
[2] URLProtectionSpace API documentation Apple
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 3
[4] Standards Mapping - CIS Microsoft Azure Foundations Benchmark partial
[5] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5
[6] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[7] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[8] Standards Mapping - CIS Kubernetes Benchmark partial
[9] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[10] Standards Mapping - OWASP API 2023 API2 Broken Authentication
[11] Standards Mapping - OWASP Mobile 2024 M3 Insecure Authentication/Authorization
[12] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-AUTH-1
desc.structural.objc.authentication_bad_practice_missing_check_against_protection_space
Abstract
NSURLConnection 代理处理身份验证质询,而无需先验证应用程序是否知道如何处理特定保护空间的身份验证质询。
Explanation
NSURLProtectionSpace 对象代表需要身份验证的服务器或服务器上的某个区域(通常称为 Realm)。
当建立需要对保护空间进行身份验证的 URL 连接时,将在调用 NSURLConnectionDelegate.connection(_:canAuthenticateAgainstProtectionSpace:) 方法之后立即调用应执行身份验证的 NSURLConnectionDelegate.connection(_:didReceive:) 方法。这样,NSURLConnectionDelegate 便可在尝试对保护空间进行身份验证之前检查它。通过返回 true,代理指示它可以处理身份验证,在对 connection(_:didReceive:) 的后续调用中它也确实这样做了。如果您的代理未实施此方法且保护空间使用客户端证书身份验证或服务器信任身份验证,系统将会尝试使用用户的密钥链来验证哪些可能不是所需的行为。
References
[1] connection(_:canAuthenticateAgainstProtectionSpace:) API documentation Apple
[2] URLProtectionSpace API documentation Apple
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 3
[4] Standards Mapping - CIS Microsoft Azure Foundations Benchmark partial
[5] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5
[6] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[7] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[8] Standards Mapping - CIS Kubernetes Benchmark partial
[9] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[10] Standards Mapping - OWASP API 2023 API2 Broken Authentication
[11] Standards Mapping - OWASP Mobile 2024 M3 Insecure Authentication/Authorization
[12] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-AUTH-1
desc.structural.swift.authentication_bad_practice_missing_check_against_protection_space