Hardcoded salt 會削弱系統安全性,一旦出現安全問題將無法輕易修正。
采用硬編碼處理 salt 絕非一個好方法。這不僅是因為所有項目開發人員都可以使用 hardcoded salt 來查看該 salt,而且還會使解決這一問題變得極其困難。一旦將該代碼投入生產,則無法輕易更改該 salt。如果攻擊者知道該 salt 的值,他們就可以計算出該應用程序的彩虹表以及更輕松地反轉散列值。
例 1:下列代碼使用了 hardcoded salt:
...
Encryptor instance = ESAPI.encryptor();
String hash1 = instance.hash(input, "HereComesTheSalt...");
...
javap -c 命令訪問已經過反匯編的代碼,而在這些代碼中恰恰包含著用戶使用過的 salt 值。
[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) APP3150.1 CAT II
[5] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3150.1 CAT II
[6] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 326
[7] Standards Mapping - Web Application Security Consortium 24 + 2 - (WASC 24 + 2) Information Leakage
[8] Standards Mapping - FIPS200 - (FISMA) MP
[9] Standards Mapping - SANS Top 25 2011 - (SANS Top 25 2011) Porous Defenses - CWE ID 759
[10] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 - (PCI 1.2) Requirement 6.3.1.3, Requirement 6.5.8
[11] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 - (PCI 2.0) Requirement 6.5.3
[12] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 - (PCI 1.1) Requirement 6.5.8