調用不會驗證 SSL 服務器證書的主機名,或者允許 HTTPS 協議協商使用自簽名證書。
在開發過程中,開發人員使用測試或自簽名的 SSL 證書構建應用程序。這樣開發人員無需正式請求和驗證 SSL 證書即可測試 HTTPS 功能。然而,大多數情況下會保留使用自簽名證書的代碼,這會導致基于 HTTPS 的 Man-In-The-Middle (MITM) 攻擊。
例 1:以下代碼允許所有 HTTPS 連接的任意 HTTPS 證書:
implementation NSURLRequest (IgnoreSSL)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
return YES;
}
@end
[1] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A10 Insecure Configuration Management
[2] Standards Mapping - OWASP Top 10 2010 - (OWASP 2010) A6 Security Misconfiguration
[3] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP3305 CAT I
[4] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3305 CAT I
[5] Standards Mapping - FIPS200 - (FISMA) CM
[6] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 296
[7] CWE-296:Improper Following of Chain of Trust for Certificate Validation Mitre.org
[8] Standards Mapping - Web Application Security Consortium 24 + 2 - (WASC 24 + 2) Insufficient Authentication
[9] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 - (PCI 1.1) Requirement 6.5.10