You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Constant salts should not be used for password hashing. Data hashed using constant salts are vulnerable to dictionary attacks, enabling attackers to recover the original input.</p>
7
+
</overview>
8
+
9
+
<recommendation>
10
+
<p>Use randomly generated salts to securely hash input data.</p>
11
+
</recommendation>
12
+
13
+
<example>
14
+
<p>The following example shows a few cases of hashing input data. In the 'BAD' cases, the salt is constant, making the generated hashes vulnerable to dictionary attacks. In the 'GOOD' cases, the salt is randomly generated, which protects the hashed data against recovery.</p>
15
+
<samplesrc="ConstantSalt.swift" />
16
+
</example>
17
+
18
+
<references>
19
+
<li><ahref="https://www.okta.com/blog/2019/03/what-are-salted-passwords-and-password-hashing/">What are Salted Passwords and Password Hashing?</a></li>
* @description Using constant salts for password hashing is not secure because potential attackers can precompute the hash value via dictionary attacks.
4
+
* @kind path-problem
5
+
* @problem.severity error
6
+
* @security-severity 7.5
7
+
* @precision high
8
+
* @id swift/constant-salt
9
+
* @tags security
10
+
* external/cwe/cwe-760
11
+
*/
12
+
13
+
import swift
14
+
import codeql.swift.dataflow.DataFlow
15
+
import codeql.swift.dataflow.TaintTracking
16
+
import codeql.swift.dataflow.FlowSteps
17
+
import DataFlow::PathGraph
18
+
19
+
/**
20
+
* A constant salt is created through either a byte array or string literals.
| test.swift:51:49:51:49 | constantSalt | test.swift:43:35:43:130 | [...] : | test.swift:51:49:51:49 | constantSalt | The value '[...]' is used as a constant salt, which is insecure for hashing passwords. |
15
+
| test.swift:56:59:56:59 | constantSalt | test.swift:43:35:43:130 | [...] : | test.swift:56:59:56:59 | constantSalt | The value '[...]' is used as a constant salt, which is insecure for hashing passwords. |
16
+
| test.swift:62:59:62:59 | constantSalt | test.swift:43:35:43:130 | [...] : | test.swift:62:59:62:59 | constantSalt | The value '[...]' is used as a constant salt, which is insecure for hashing passwords. |
17
+
| test.swift:67:53:67:53 | constantSalt | test.swift:43:35:43:130 | [...] : | test.swift:67:53:67:53 | constantSalt | The value '[...]' is used as a constant salt, which is insecure for hashing passwords. |
0 commit comments