Skip to content

Commit 723ca8e

Browse files
update documentation following docs review
1 parent 18dd0f6 commit 723ca8e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

swift/ql/src/queries/Security/CWE-916/InsufficientHashIterations.qhelp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
"qhelp.dtd">
44
<qhelp>
55
<overview>
6-
<p>Using hash functions with less than 1,000 iterations is not secure. That scheme is vulnerable to password cracking attacks due to having an insufficient level of computational effort.</p>
6+
<p>Storing cryptographic hashes of passwords is standard security practice, but it is equally important to select the right hashing scheme. If an attacker obtains the hashed passwords of an application, the password hashing scheme should still prevent the attacker from easily obtaining the original cleartext passwords.</p>
7+
<p>A good password hashing scheme requires a computation that cannot be done efficiently. Hashing schemes with low number of iterations are efficiently computable, and are therefore not suitable for password hashing.</p>
78
</overview>
89

910
<recommendation>
10-
<p>Use sufficient number of iterations (that is, greater than or equal 120000) for generating password-based keys.</p>
11+
<p>Use the OWASP recommendation for sufficient number of iterations (currently, that is greater than or equal to 120,000) for password hashing schemes.</p>
1112
</recommendation>
1213

1314
<example>
14-
<p>The following example shows a few cases of instantiating a password-based key. In the 'BAD' cases, the key is initialized with insufficient iterations, making it susceptible to password cracking attacks. In the 'GOOD' cases, the key is initialized with at least 120000 iterations, which protects the encrypted data against recovery.</p>
15+
<p>The following example shows a few cases where a password hashing scheme is instantiated. In the 'BAD' cases, the scheme is initialized with insufficient iterations, making it susceptible to password cracking attacks. In the 'GOOD' cases, the scheme is initialized with at least 120,000 iterations, which protects the hashed data against recovery.</p>
1516
<sample src="InsufficientHashIterations.swift" />
1617
</example>
1718

swift/ql/src/queries/Security/CWE-916/InsufficientHashIterations.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
func encrypt() {
33
// ...
44

5-
// BAD: Using insufficient (i.e., < 120,000) hash iterations keys for encryption
5+
// BAD: Using insufficient (that is, < 120,000) hash iterations keys for encryption
66
_ = try PKCS5.PBKDF1(password: getRandomArray(), salt: getRandomArray(), iterations: 90000, keyLength: 0)
77
_ = try PKCS5.PBKDF2(password: getRandomArray(), salt: getRandomArray(), iterations: 90000, keyLength: 0)
88

9-
// GOOD: Using sufficient (i.e., >= 120,000) hash iterations keys for encryption
9+
// GOOD: Using sufficient (that is, >= 120,000) hash iterations keys for encryption
1010
_ = try PKCS5.PBKDF1(password: getRandomArray(), salt: getRandomArray(), iterations: 120120, keyLength: 0)
1111
_ = try PKCS5.PBKDF2(password: getRandomArray(), salt: getRandomArray(), iterations: 120120, keyLength: 0)
1212

0 commit comments

Comments
 (0)