Null password 會損害安全性。
最好不要為密碼變量指定 null password,因為這會使攻擊者繞過密碼驗證,或是表明資源受 empty password 保護。
例 1: 以下代碼可將密碼變量初始化為 null,并嘗試在存儲的值中讀取密碼,且將其與用戶提供的值進行比較。
...
NSString *stored_password = NULL;
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password))
// Access protected resources
...
}
...
readPassword() 因數據庫錯誤或其他問題而未能取得存儲的密碼,攻擊者只需向 user_password 提供一個 null 值,就能輕松繞過密碼檢查。
[1] Standards Mapping - OWASP Top 10 2010 - (OWASP 2010) A7 Insecure Cryptographic Storage
[2] Standards Mapping - OWASP Top 10 2007 - (OWASP 2007) A8 Insecure Cryptographic Storage
[3] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A8 Insecure Storage
[4] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP3210.1 CAT II, APP3340 CAT I, APP3350 CAT I
[5] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3210.1 CAT II, APP3340 CAT I, APP3350 CAT I
[6] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 259
[7] Standards Mapping - FIPS200 - (FISMA) IA
[8] Standards Mapping - SANS Top 25 2009 - (SANS 2009) Porous Defenses - CWE ID 259
[9] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 - (PCI 1.2) Requirement 3.4, Requirement 6.3.1.3, Requirement 6.5.8, Requirement 8.4
[10] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 - (PCI 2.0) Requirement 3.4, Requirement 6.5.3, Requirement 8.4
[11] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 - (PCI 1.1) Requirement 3.4, Requirement 6.5.8, Requirement 8.4