From 10eb9076ac6b421d23727a6a9eefcb2fbf4f4e4a Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Wed, 2 Dec 2026 19:00:50 +0000 Subject: [PATCH 1/8] unified: Copy Swift weak password hashing query and tests unchanged Copy the original Swift WeakPasswordHashing query, query help, examples, and query tests byte-for-byte into unified/ to establish an unchanged baseline for the unified Swift port. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CWE-328/WeakPasswordHashing.qhelp | 95 +++++++ .../security/CWE-328/WeakPasswordHashing.ql | 26 ++ .../CWE-328/WeakPasswordHashingBad.swift | 8 + .../CWE-328/WeakPasswordHashingGood.swift | 11 + .../CWE-328/WeakPasswordHashing.expected | 104 +++++++ .../CWE-328/WeakPasswordHashing.qlref | 2 + .../security/CWE-328/testArgon2Swift.swift | 49 ++++ .../security/CWE-328/testCryptoKit.swift | 260 ++++++++++++++++++ .../security/CWE-328/testCryptoSwift.swift | 232 ++++++++++++++++ 9 files changed, 787 insertions(+) create mode 100644 unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.qhelp create mode 100644 unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql create mode 100644 unified/ql/src/queries/security/CWE-328/WeakPasswordHashingBad.swift create mode 100644 unified/ql/src/queries/security/CWE-328/WeakPasswordHashingGood.swift create mode 100644 unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected create mode 100644 unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.qlref create mode 100644 unified/ql/test/query-tests/security/CWE-328/testArgon2Swift.swift create mode 100644 unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift create mode 100644 unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift diff --git a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.qhelp b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.qhelp new file mode 100644 index 000000000000..0e26c11703b1 --- /dev/null +++ b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.qhelp @@ -0,0 +1,95 @@ + + + +

+ Hash functions that are not sufficiently computationally hard can leave data vulnerable. You should not use such functions for password hashing. +

+ +

+ A strong cryptographic hash function should be resistant to: +

+ + +

+ All of MD5, SHA-1, SHA-2 and SHA-3 are weak against offline brute forcing, since they are not sufficiently computationally hard. This includes SHA-224, SHA-256, SHA-384 and SHA-512, which are in the SHA-2 family. +

+ +

+ Password hashing algorithms should be slow and/or memory intensive to compute, to make brute force attacks more difficult. +

+ +
+ + +

+ For password storage, you should use a sufficiently computationally hard cryptographic hash function, such as one of the following: +

+ + + +
+ + +

+ The following examples show two versions of the same function. In both cases, a password is hashed using a cryptographic hashing algorithm. + + In the first case, the SHA-512 hashing algorithm is used. It is vulnerable to offline brute force attacks: +

+ +

+ + Here is the same function using Argon2, which is suitable for password hashing: +

+ + +
+ +
  • + OWASP: + Password Storage + Cheat Sheet + +
  • +
  • + GitHub: CryptoSwift README - Password-Based Key Derivation Function +
  • +
  • + libsodium: libsodium bindings for other languages +
  • +
  • + GitHub: Argon2Swift +
  • +
    + +
    diff --git a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql new file mode 100644 index 000000000000..62a9cb652477 --- /dev/null +++ b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql @@ -0,0 +1,26 @@ +/** + * @name Use of an inappropriate cryptographic hashing algorithm on passwords + * @description Using inappropriate cryptographic hashing algorithms with passwords can compromise security. + * @kind path-problem + * @problem.severity warning + * @security-severity 7.5 + * @precision high + * @id swift/weak-password-hashing + * @tags security + * external/cwe/cwe-327 + * external/cwe/cwe-328 + * external/cwe/cwe-916 + */ + +import swift +import codeql.swift.security.WeakPasswordHashingQuery +import WeakPasswordHashingFlow::PathGraph + +from + WeakPasswordHashingFlow::PathNode source, WeakPasswordHashingFlow::PathNode sink, string algorithm +where + WeakPasswordHashingFlow::flowPath(source, sink) and + algorithm = sink.getNode().(WeakPasswordHashingSink).getAlgorithm() +select sink.getNode(), source, sink, + "Insecure hashing algorithm (" + algorithm + ") depends on $@.", source.getNode(), + "password (" + source.getNode().asExpr() + ")" diff --git a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashingBad.swift b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashingBad.swift new file mode 100644 index 000000000000..572fe9fa3605 --- /dev/null +++ b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashingBad.swift @@ -0,0 +1,8 @@ +let passwordData = Data(passwordString.utf8) +let passwordHash = Crypto.SHA512.hash(data: passwordData) // BAD: SHA-512 is not suitable for password hashing. + +// ... + +if Crypto.SHA512.hash(data: Data(passwordString.utf8)) == passwordHash { + // ... +} diff --git a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashingGood.swift b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashingGood.swift new file mode 100644 index 000000000000..ed2c8758674c --- /dev/null +++ b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashingGood.swift @@ -0,0 +1,11 @@ +import Argon2Swift + +let salt = Salt.newSalt() +let result = try! Argon2Swift.hashPasswordString(password: passwordString, salt: salt) // GOOD: Argon2 is suitable for password hashing. +let passwordHash = result.encodedString() + +// ... + +if try! Argon2Swift.verifyHashString(password: passwordString, hash: passwordHash) { + // ... +} diff --git a/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected new file mode 100644 index 000000000000..2b0eed8d0c2b --- /dev/null +++ b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected @@ -0,0 +1,104 @@ +#select +| testCryptoKit.swift:84:47:84:47 | passwd | testCryptoKit.swift:84:47:84:47 | passwd | testCryptoKit.swift:84:47:84:47 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:84:47:84:47 | passwd | password (passwd) | +| testCryptoKit.swift:85:52:85:52 | passwd | testCryptoKit.swift:85:52:85:52 | passwd | testCryptoKit.swift:85:52:85:52 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:85:52:85:52 | passwd | password (passwd) | +| testCryptoKit.swift:91:36:91:36 | passwd | testCryptoKit.swift:91:36:91:36 | passwd | testCryptoKit.swift:91:36:91:36 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:91:36:91:36 | passwd | password (passwd) | +| testCryptoKit.swift:92:45:92:45 | passwd | testCryptoKit.swift:92:45:92:45 | passwd | testCryptoKit.swift:92:45:92:45 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:92:45:92:45 | passwd | password (passwd) | +| testCryptoKit.swift:98:44:98:44 | passwd | testCryptoKit.swift:98:44:98:44 | passwd | testCryptoKit.swift:98:44:98:44 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:98:44:98:44 | passwd | password (passwd) | +| testCryptoKit.swift:99:53:99:53 | passwd | testCryptoKit.swift:99:53:99:53 | passwd | testCryptoKit.swift:99:53:99:53 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:99:53:99:53 | passwd | password (passwd) | +| testCryptoKit.swift:105:37:105:37 | passwd | testCryptoKit.swift:105:37:105:37 | passwd | testCryptoKit.swift:105:37:105:37 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:105:37:105:37 | passwd | password (passwd) | +| testCryptoKit.swift:106:46:106:46 | passwd | testCryptoKit.swift:106:46:106:46 | passwd | testCryptoKit.swift:106:46:106:46 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:106:46:106:46 | passwd | password (passwd) | +| testCryptoKit.swift:112:37:112:37 | passwd | testCryptoKit.swift:112:37:112:37 | passwd | testCryptoKit.swift:112:37:112:37 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:112:37:112:37 | passwd | password (passwd) | +| testCryptoKit.swift:113:46:113:46 | passwd | testCryptoKit.swift:113:46:113:46 | passwd | testCryptoKit.swift:113:46:113:46 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:113:46:113:46 | passwd | password (passwd) | +| testCryptoKit.swift:119:37:119:37 | passwd | testCryptoKit.swift:119:37:119:37 | passwd | testCryptoKit.swift:119:37:119:37 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:119:37:119:37 | passwd | password (passwd) | +| testCryptoKit.swift:120:46:120:46 | passwd | testCryptoKit.swift:120:46:120:46 | passwd | testCryptoKit.swift:120:46:120:46 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:120:46:120:46 | passwd | password (passwd) | +| testCryptoKit.swift:129:23:129:23 | passwd | testCryptoKit.swift:129:23:129:23 | passwd | testCryptoKit.swift:129:23:129:23 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:129:23:129:23 | passwd | password (passwd) | +| testCryptoKit.swift:138:23:138:23 | passwd | testCryptoKit.swift:138:23:138:23 | passwd | testCryptoKit.swift:138:23:138:23 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:138:23:138:23 | passwd | password (passwd) | +| testCryptoKit.swift:147:23:147:23 | passwd | testCryptoKit.swift:147:23:147:23 | passwd | testCryptoKit.swift:147:23:147:23 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:147:23:147:23 | passwd | password (passwd) | +| testCryptoKit.swift:156:23:156:23 | passwd | testCryptoKit.swift:156:23:156:23 | passwd | testCryptoKit.swift:156:23:156:23 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:156:23:156:23 | passwd | password (passwd) | +| testCryptoKit.swift:165:23:165:23 | passwd | testCryptoKit.swift:165:23:165:23 | passwd | testCryptoKit.swift:165:23:165:23 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:165:23:165:23 | passwd | password (passwd) | +| testCryptoKit.swift:174:32:174:32 | passwd | testCryptoKit.swift:174:32:174:32 | passwd | testCryptoKit.swift:174:32:174:32 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:174:32:174:32 | passwd | password (passwd) | +| testCryptoKit.swift:183:32:183:32 | passwd | testCryptoKit.swift:183:32:183:32 | passwd | testCryptoKit.swift:183:32:183:32 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:183:32:183:32 | passwd | password (passwd) | +| testCryptoKit.swift:192:32:192:32 | passwd | testCryptoKit.swift:192:32:192:32 | passwd | testCryptoKit.swift:192:32:192:32 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:192:32:192:32 | passwd | password (passwd) | +| testCryptoKit.swift:201:32:201:32 | passwd | testCryptoKit.swift:201:32:201:32 | passwd | testCryptoKit.swift:201:32:201:32 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:201:32:201:32 | passwd | password (passwd) | +| testCryptoKit.swift:210:32:210:32 | passwd | testCryptoKit.swift:210:32:210:32 | passwd | testCryptoKit.swift:210:32:210:32 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:210:32:210:32 | passwd | password (passwd) | +| testCryptoKit.swift:220:49:220:49 | passwordData | testCryptoKit.swift:220:49:220:49 | passwordData | testCryptoKit.swift:220:49:220:49 | passwordData | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:220:49:220:49 | passwordData | password (passwordData) | +| testCryptoKit.swift:224:33:224:57 | call to Data.init(_:) | testCryptoKit.swift:224:38:224:38 | passwordString | testCryptoKit.swift:224:33:224:57 | call to Data.init(_:) | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:224:38:224:38 | passwordString | password (passwordString) | +| testCryptoSwift.swift:154:30:154:30 | passwdArray | testCryptoSwift.swift:154:30:154:30 | passwdArray | testCryptoSwift.swift:154:30:154:30 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:154:30:154:30 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:157:31:157:31 | passwdArray | testCryptoSwift.swift:157:31:157:31 | passwdArray | testCryptoSwift.swift:157:31:157:31 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:157:31:157:31 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:160:47:160:47 | passwdArray | testCryptoSwift.swift:160:47:160:47 | passwdArray | testCryptoSwift.swift:160:47:160:47 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:160:47:160:47 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:163:47:163:47 | passwdArray | testCryptoSwift.swift:163:47:163:47 | passwdArray | testCryptoSwift.swift:163:47:163:47 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:163:47:163:47 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:167:20:167:20 | passwdArray | testCryptoSwift.swift:167:20:167:20 | passwdArray | testCryptoSwift.swift:167:20:167:20 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:167:20:167:20 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:170:21:170:21 | passwdArray | testCryptoSwift.swift:170:21:170:21 | passwdArray | testCryptoSwift.swift:170:21:170:21 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:170:21:170:21 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:173:23:173:23 | passwdArray | testCryptoSwift.swift:173:23:173:23 | passwdArray | testCryptoSwift.swift:173:23:173:23 | passwdArray | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:173:23:173:23 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:176:21:176:21 | passwdArray | testCryptoSwift.swift:176:21:176:21 | passwdArray | testCryptoSwift.swift:176:21:176:21 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:176:21:176:21 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:179:21:179:21 | passwdArray | testCryptoSwift.swift:179:21:179:21 | passwdArray | testCryptoSwift.swift:179:21:179:21 | passwdArray | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:179:21:179:21 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:183:9:183:9 | passwdArray | testCryptoSwift.swift:183:9:183:9 | passwdArray | testCryptoSwift.swift:183:9:183:9 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:183:9:183:9 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:186:9:186:9 | passwdArray | testCryptoSwift.swift:186:9:186:9 | passwdArray | testCryptoSwift.swift:186:9:186:9 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:186:9:186:9 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:189:9:189:9 | passwdArray | testCryptoSwift.swift:189:9:189:9 | passwdArray | testCryptoSwift.swift:189:9:189:9 | passwdArray | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:189:9:189:9 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:192:9:192:9 | passwdArray | testCryptoSwift.swift:192:9:192:9 | passwdArray | testCryptoSwift.swift:192:9:192:9 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:192:9:192:9 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:195:9:195:9 | passwdArray | testCryptoSwift.swift:195:9:195:9 | passwdArray | testCryptoSwift.swift:195:9:195:9 | passwdArray | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:195:9:195:9 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:201:9:201:9 | passwdData | testCryptoSwift.swift:201:9:201:9 | passwdData | testCryptoSwift.swift:201:9:201:9 | passwdData | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:201:9:201:9 | passwdData | password (passwdData) | +| testCryptoSwift.swift:204:9:204:9 | passwdData | testCryptoSwift.swift:204:9:204:9 | passwdData | testCryptoSwift.swift:204:9:204:9 | passwdData | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:204:9:204:9 | passwdData | password (passwdData) | +| testCryptoSwift.swift:207:9:207:9 | passwdData | testCryptoSwift.swift:207:9:207:9 | passwdData | testCryptoSwift.swift:207:9:207:9 | passwdData | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:207:9:207:9 | passwdData | password (passwdData) | +| testCryptoSwift.swift:210:9:210:9 | passwdData | testCryptoSwift.swift:210:9:210:9 | passwdData | testCryptoSwift.swift:210:9:210:9 | passwdData | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:210:9:210:9 | passwdData | password (passwdData) | +| testCryptoSwift.swift:213:9:213:9 | passwdData | testCryptoSwift.swift:213:9:213:9 | passwdData | testCryptoSwift.swift:213:9:213:9 | passwdData | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:213:9:213:9 | passwdData | password (passwdData) | +| testCryptoSwift.swift:219:9:219:9 | passwd | testCryptoSwift.swift:219:9:219:9 | passwd | testCryptoSwift.swift:219:9:219:9 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:219:9:219:9 | passwd | password (passwd) | +| testCryptoSwift.swift:222:9:222:9 | passwd | testCryptoSwift.swift:222:9:222:9 | passwd | testCryptoSwift.swift:222:9:222:9 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:222:9:222:9 | passwd | password (passwd) | +| testCryptoSwift.swift:225:9:225:9 | passwd | testCryptoSwift.swift:225:9:225:9 | passwd | testCryptoSwift.swift:225:9:225:9 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:225:9:225:9 | passwd | password (passwd) | +| testCryptoSwift.swift:228:9:228:9 | passwd | testCryptoSwift.swift:228:9:228:9 | passwd | testCryptoSwift.swift:228:9:228:9 | passwd | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:228:9:228:9 | passwd | password (passwd) | +| testCryptoSwift.swift:231:9:231:9 | passwd | testCryptoSwift.swift:231:9:231:9 | passwd | testCryptoSwift.swift:231:9:231:9 | passwd | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:231:9:231:9 | passwd | password (passwd) | +edges +| testCryptoKit.swift:224:38:224:38 | passwordString | testCryptoKit.swift:224:38:224:53 | .utf8 | provenance | | +| testCryptoKit.swift:224:38:224:53 | .utf8 | testCryptoKit.swift:224:33:224:57 | call to Data.init(_:) | provenance | | +nodes +| testCryptoKit.swift:84:47:84:47 | passwd | semmle.label | passwd | +| testCryptoKit.swift:85:52:85:52 | passwd | semmle.label | passwd | +| testCryptoKit.swift:91:36:91:36 | passwd | semmle.label | passwd | +| testCryptoKit.swift:92:45:92:45 | passwd | semmle.label | passwd | +| testCryptoKit.swift:98:44:98:44 | passwd | semmle.label | passwd | +| testCryptoKit.swift:99:53:99:53 | passwd | semmle.label | passwd | +| testCryptoKit.swift:105:37:105:37 | passwd | semmle.label | passwd | +| testCryptoKit.swift:106:46:106:46 | passwd | semmle.label | passwd | +| testCryptoKit.swift:112:37:112:37 | passwd | semmle.label | passwd | +| testCryptoKit.swift:113:46:113:46 | passwd | semmle.label | passwd | +| testCryptoKit.swift:119:37:119:37 | passwd | semmle.label | passwd | +| testCryptoKit.swift:120:46:120:46 | passwd | semmle.label | passwd | +| testCryptoKit.swift:129:23:129:23 | passwd | semmle.label | passwd | +| testCryptoKit.swift:138:23:138:23 | passwd | semmle.label | passwd | +| testCryptoKit.swift:147:23:147:23 | passwd | semmle.label | passwd | +| testCryptoKit.swift:156:23:156:23 | passwd | semmle.label | passwd | +| testCryptoKit.swift:165:23:165:23 | passwd | semmle.label | passwd | +| testCryptoKit.swift:174:32:174:32 | passwd | semmle.label | passwd | +| testCryptoKit.swift:183:32:183:32 | passwd | semmle.label | passwd | +| testCryptoKit.swift:192:32:192:32 | passwd | semmle.label | passwd | +| testCryptoKit.swift:201:32:201:32 | passwd | semmle.label | passwd | +| testCryptoKit.swift:210:32:210:32 | passwd | semmle.label | passwd | +| testCryptoKit.swift:220:49:220:49 | passwordData | semmle.label | passwordData | +| testCryptoKit.swift:224:33:224:57 | call to Data.init(_:) | semmle.label | call to Data.init(_:) | +| testCryptoKit.swift:224:38:224:38 | passwordString | semmle.label | passwordString | +| testCryptoKit.swift:224:38:224:53 | .utf8 | semmle.label | .utf8 | +| testCryptoSwift.swift:154:30:154:30 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:157:31:157:31 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:160:47:160:47 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:163:47:163:47 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:167:20:167:20 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:170:21:170:21 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:173:23:173:23 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:176:21:176:21 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:179:21:179:21 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:183:9:183:9 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:186:9:186:9 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:189:9:189:9 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:192:9:192:9 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:195:9:195:9 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:201:9:201:9 | passwdData | semmle.label | passwdData | +| testCryptoSwift.swift:204:9:204:9 | passwdData | semmle.label | passwdData | +| testCryptoSwift.swift:207:9:207:9 | passwdData | semmle.label | passwdData | +| testCryptoSwift.swift:210:9:210:9 | passwdData | semmle.label | passwdData | +| testCryptoSwift.swift:213:9:213:9 | passwdData | semmle.label | passwdData | +| testCryptoSwift.swift:219:9:219:9 | passwd | semmle.label | passwd | +| testCryptoSwift.swift:222:9:222:9 | passwd | semmle.label | passwd | +| testCryptoSwift.swift:225:9:225:9 | passwd | semmle.label | passwd | +| testCryptoSwift.swift:228:9:228:9 | passwd | semmle.label | passwd | +| testCryptoSwift.swift:231:9:231:9 | passwd | semmle.label | passwd | +subpaths diff --git a/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.qlref b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.qlref new file mode 100644 index 000000000000..24744b4a4250 --- /dev/null +++ b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.qlref @@ -0,0 +1,2 @@ +query: queries/Security/CWE-328/WeakPasswordHashing.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/unified/ql/test/query-tests/security/CWE-328/testArgon2Swift.swift b/unified/ql/test/query-tests/security/CWE-328/testArgon2Swift.swift new file mode 100644 index 000000000000..e88fb5eb2c73 --- /dev/null +++ b/unified/ql/test/query-tests/security/CWE-328/testArgon2Swift.swift @@ -0,0 +1,49 @@ + +// --- stubs --- + +class Data +{ + init(_ elements: S) {} +} + +class Salt { + init(bytes: Data) { } + + static func newSalt(length: Int = 16) -> Salt { + return Salt(bytes: Data(0)) + } +} + +class Argon2SwiftResult { + init(hashBytes: [Int8], encodedBytes: [Int8]) { } + + func encodedString() -> String { + return "" + } +} + +class Argon2Swift { + // slightly simplified (type and version changed to Int) + static func hashPasswordString(password: String, salt: Salt, iterations: Int = 32, memory: Int = 256, parallelism: Int = 2, length: Int = 32, type: Int = 1, version: Int = 13) throws -> Argon2SwiftResult { + return Argon2SwiftResult(hashBytes: [], encodedBytes: []) + } + + static func verifyHashString(password: String, hash: String, type: Int = 1) throws -> Bool { + return false + } +} + +// --- tests --- + +func testGoodExample(passwordString: String) { + // this is the "good" example from the .qhelp + let salt = Salt.newSalt() + let result = try! Argon2Swift.hashPasswordString(password: passwordString, salt: salt) // GOOD (suitable password hash) + let passwordHash = result.encodedString() + + // ... + + if try! Argon2Swift.verifyHashString(password: passwordString, hash: passwordHash) { + // ... + } +} diff --git a/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift b/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift new file mode 100644 index 000000000000..d2faf8812248 --- /dev/null +++ b/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift @@ -0,0 +1,260 @@ +//codeql-extractor-options: -module-name Crypto + +// --- stubs --- + +class Data +{ + init(_ elements: S) {} +} + +public protocol HashFunction { + associatedtype Digest + + init() + mutating func update(bufferPointer: UnsafeRawBufferPointer) + func finalize() -> Digest +} + +extension HashFunction { + @inlinable + public static func hash(bufferPointer: UnsafeRawBufferPointer) -> Digest { + var hasher = Self() + hasher.update(bufferPointer: bufferPointer) + return hasher.finalize() + } + + @inlinable + public static func hash(data: D) -> Self.Digest { + var hasher = Self() + hasher.update(data: data) + return hasher.finalize() + } + + @inlinable + public mutating func update(data: D) { + // ... + } +} + +public struct SHA256: HashFunction { + public typealias Digest = [UInt8] + + public init() {} + public mutating func update(bufferPointer: UnsafeRawBufferPointer) {} + public func finalize() -> Digest { return [] } +} + +public struct SHA384: HashFunction { + public typealias Digest = [UInt8] + + public init() {} + public mutating func update(bufferPointer: UnsafeRawBufferPointer) {} + public func finalize() -> Digest { return [] } +} + +public struct SHA512: HashFunction { + public typealias Digest = [UInt8] + + public init() {} + public mutating func update(bufferPointer: UnsafeRawBufferPointer) {} + public func finalize() -> Digest { return [] } +} + +enum Insecure { + public struct MD5: HashFunction { + public typealias Digest = [UInt8] + + public init() {} + public mutating func update(bufferPointer: UnsafeRawBufferPointer) {} + public func finalize() -> Digest { return [] } + } + + public struct SHA1: HashFunction { + public typealias Digest = [UInt8] + + public init() {} + public mutating func update(bufferPointer: UnsafeRawBufferPointer) {} + public func finalize() -> Digest { return [] } + } +} + +// --- tests --- + +func testHashMethods(passwd : UnsafeRawBufferPointer, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { + var hash = Crypto.Insecure.MD5.hash(data: passwd) // $ Alert[swift/weak-password-hashing] + hash = Crypto.Insecure.MD5.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] + hash = Crypto.Insecure.MD5.hash(data: cert) // $ Alert[swift/weak-sensitive-data-hashing] + hash = Crypto.Insecure.MD5.hash(data: encrypted_passwd) // GOOD (not sensitive) + hash = Crypto.Insecure.MD5.hash(data: account_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash = Crypto.Insecure.MD5.hash(data: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] + + hash = Insecure.MD5.hash(data: passwd) // $ Alert[swift/weak-password-hashing] + hash = Insecure.MD5.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] + hash = Insecure.MD5.hash(data: cert) // $ Alert[swift/weak-sensitive-data-hashing] + hash = Insecure.MD5.hash(data: encrypted_passwd) // GOOD (not sensitive) + hash = Insecure.MD5.hash(data: account_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash = Insecure.MD5.hash(data: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] + + hash = Crypto.Insecure.SHA1.hash(data: passwd) // $ Alert[swift/weak-password-hashing] + hash = Crypto.Insecure.SHA1.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] + hash = Crypto.Insecure.SHA1.hash(data: cert) // $ Alert[swift/weak-sensitive-data-hashing] + hash = Crypto.Insecure.SHA1.hash(data: encrypted_passwd) // GOOD (not sensitive) + hash = Crypto.Insecure.SHA1.hash(data: account_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash = Crypto.Insecure.SHA1.hash(data: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] + + hash = Crypto.SHA256.hash(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash = Crypto.SHA256.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash = Crypto.SHA256.hash(data: cert) // GOOD, computationally expensive hash not required + hash = Crypto.SHA256.hash(data: encrypted_passwd) // GOOD, not sensitive + hash = Crypto.SHA256.hash(data: account_no) // GOOD, computationally expensive hash not required + hash = Crypto.SHA256.hash(data: credit_card_no) // GOOD, computationally expensive hash not required + + hash = Crypto.SHA384.hash(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash = Crypto.SHA384.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash = Crypto.SHA384.hash(data: cert) // GOOD, computationally expensive hash not required + hash = Crypto.SHA384.hash(data: encrypted_passwd) // GOOD, not sensitive + hash = Crypto.SHA384.hash(data: account_no) // GOOD, computationally expensive hash not required + hash = Crypto.SHA384.hash(data: credit_card_no) // GOOD, computationally expensive hash not required + + hash = Crypto.SHA512.hash(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash = Crypto.SHA512.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash = Crypto.SHA512.hash(data: cert) // GOOD, computationally expensive hash not required + hash = Crypto.SHA512.hash(data: encrypted_passwd) // GOOD, not sensitive + hash = Crypto.SHA512.hash(data: account_no) // GOOD, computationally expensive hash not required + hash = Crypto.SHA512.hash(data: credit_card_no) // GOOD, computationally expensive hash not required +} + +func testMD5UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { + var hash = Crypto.Insecure.MD5() + hash.update(data: passwd) // $ Alert[swift/weak-password-hashing] + hash.update(data: cert) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(data: encrypted_passwd) // GOOD (not sensitive) + hash.update(data: account_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(data: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] +} + +func testSHA1UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { + var hash = Crypto.Insecure.SHA1() + hash.update(data: passwd) // $ Alert[swift/weak-password-hashing] + hash.update(data: cert) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(data: encrypted_passwd) // GOOD (not sensitive) + hash.update(data: account_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(data: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] +} + +func testSHA256UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { + var hash = Crypto.SHA256() + hash.update(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash.update(data: cert) // GOOD + hash.update(data: encrypted_passwd) // GOOD (not sensitive) + hash.update(data: account_no) // GOOD + hash.update(data: credit_card_no) // GOOD +} + +func testSHA384UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { + var hash = Crypto.SHA384() + hash.update(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash.update(data: cert) // GOOD + hash.update(data: encrypted_passwd) // GOOD (not sensitive) + hash.update(data: account_no) // GOOD + hash.update(data: credit_card_no) // GOOD +} + +func testSHA512UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { + var hash = Crypto.SHA512() + hash.update(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash.update(data: cert) // GOOD + hash.update(data: encrypted_passwd) // GOOD (not sensitive) + hash.update(data: account_no) // GOOD + hash.update(data: credit_card_no) // GOOD +} + +func testMD5UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) { + var hash = Crypto.Insecure.MD5() + hash.update(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] + hash.update(bufferPointer: cert) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) + hash.update(bufferPointer: account_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(bufferPointer: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] +} + +func testSHA1UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) { + var hash = Crypto.Insecure.SHA1() + hash.update(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] + hash.update(bufferPointer: cert) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) + hash.update(bufferPointer: account_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(bufferPointer: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] +} + +func testSHA256UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) { + var hash = Crypto.SHA256() + hash.update(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash.update(bufferPointer: cert) // GOOD + hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) + hash.update(bufferPointer: account_no) // GOOD + hash.update(bufferPointer: credit_card_no) // GOOD +} + +func testSHA384UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) { + var hash = Crypto.SHA384() + hash.update(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash.update(bufferPointer: cert) // GOOD + hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) + hash.update(bufferPointer: account_no) // GOOD + hash.update(bufferPointer: credit_card_no) // GOOD +} + +func testSHA512UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) { + var hash = Crypto.SHA512() + hash.update(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + hash.update(bufferPointer: cert) // GOOD + hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) + hash.update(bufferPointer: account_no) // GOOD + hash.update(bufferPointer: credit_card_no) // GOOD +} + +func testBadExample(passwordString: String) { + // this is the "bad" example from the .qhelp + let passwordData = Data(passwordString.utf8) + let passwordHash = Crypto.SHA512.hash(data: passwordData) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + + // ... + + if Crypto.SHA512.hash(data: Data(passwordString.utf8)) == passwordHash { // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + // ... + } +} + +func testWithFlowAndMetatypes(cardNumber: String) { + let value1 = Data(cardNumber.utf8); // $ Source[swift/weak-sensitive-data-hashing] + let _digest1 = Insecure.MD5.hash(data: value1); // $ Alert[swift/weak-sensitive-data-hashing] + + let value2 = Data(cardNumber.utf8); // $ Source[swift/weak-sensitive-data-hashing] + let hasher2 = Insecure.MD5.self; // metatype + let _digest2 = hasher2.hash(data: value2); // $ Alert[swift/weak-sensitive-data-hashing] + + let value3 = Data(cardNumber.utf8); // $ Source[swift/weak-sensitive-data-hashing] + let _digest3 = (Insecure.MD5.self).hash(data: value3); // $ Alert[swift/weak-sensitive-data-hashing] + + let value4 = Data(cardNumber.utf8); // $ Source[swift/weak-sensitive-data-hashing] + testReceiver1(value: value4); + + let value5 = Data(cardNumber.utf8); // $ Source[swift/weak-sensitive-data-hashing] + testReceiver2(hasher: Insecure.MD5.self, value: value5); + + let value6 = Data(cardNumber.utf8); + testReceiver3(hasher: Insecure.MD5.self, value: value6); +} + +func testReceiver1(value: Data) { + let _digest = Insecure.MD5.hash(data: value); // $ Alert[swift/weak-sensitive-data-hashing] +} + +func testReceiver2(hasher: Insecure.MD5.Type, value: Data) { + let _digest = hasher.hash(data: value); // $ Alert[swift/weak-sensitive-data-hashing] +} + +func testReceiver3(hasher: H.Type, value: Data) { + let _digest = hasher.hash(data: value); // $ MISSING: Alert[swift/weak-sensitive-data-hashing] // BAD [NOT DETECTED] +} diff --git a/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift b/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift new file mode 100644 index 000000000000..a6f4584230e7 --- /dev/null +++ b/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift @@ -0,0 +1,232 @@ + +// --- stubs --- + +class Data +{ + init(_ elements: S) {} +} + +protocol DigestType { + func calculate(for bytes: Array) -> Array +} + +class MD5 : DigestType { + public func calculate(for bytes: Array) -> Array { + return Array() + } +} + +class SHA1 : DigestType { + public func calculate(for bytes: Array) -> Array { + return Array() + } +} + +class SHA2 : DigestType { + public enum Variant { + case sha512 + } + + public init(variant: SHA2.Variant) {} + + public func calculate(for bytes: Array) -> Array { + return Array() + } +} + +class SHA3 : DigestType { + public enum Variant { + case sha512 + } + + public init(variant: SHA3.Variant) {} + + public func calculate(for bytes: Array) -> Array { + return Array() + } +} + +struct Digest { + static func md5(_ bytes: Array) -> Array { + return MD5().calculate(for: bytes) + } + + static func sha1(_ bytes: Array) -> Array { + return SHA1().calculate(for: bytes) + } + + static func sha512(_ bytes: Array) -> Array { + return self.sha2(bytes, variant: .sha512) + } + + static func sha2(_ bytes: Array, variant: SHA2.Variant) -> Array { + return SHA2(variant: variant).calculate(for: bytes) + } + + static func sha3(_ bytes: Array, variant: SHA3.Variant) -> Array { + return SHA3(variant: variant).calculate(for: bytes) + } +} + +extension Array where Element == UInt8 { + func toHexString() -> String { + return "" + } + + func md5() -> [Element] { + return Digest.md5(self) + } + + func sha1() -> [Element] { + return Digest.sha1(self) + } + + func sha512() -> [Element] { + return Digest.sha512(self) + } + + func sha2(_ variant: SHA2.Variant) -> [Element] { + return Digest.sha2(self, variant: variant) + } + + func sha3(_ variant: SHA3.Variant) -> [Element] { + return Digest.sha3(self, variant: variant) + } +} + +extension Data { + var bytes: Array { + return Array() + } + + func md5() -> Data { + return Data(Digest.md5(bytes)) + } + + func sha1() -> Data { + return Data(Digest.sha1(bytes)) + } + + func sha512() -> Data { + return Data(Digest.sha512(bytes)) + } + + func sha2(_ variant: SHA2.Variant) -> Data { + return Data(Digest.sha2(bytes, variant: variant)) + } + + func sha3(_ variant: SHA3.Variant) -> Data { + return Data(Digest.sha3(bytes, variant: variant)) + } +} + +extension String { + var bytes: Array { + return Array() + } + + func md5() -> String { + return self.bytes.md5().toHexString() + } + + func sha1() -> String { + return self.bytes.sha1().toHexString() + } + + func sha512() -> String { + return self.bytes.sha512().toHexString() + } + + func sha2(_ variant: SHA2.Variant) -> String { + return self.bytes.sha2(variant).toHexString() + } + + func sha3(_ variant: SHA3.Variant) -> String { + return self.bytes.sha3(variant).toHexString() + } +} + +// --- tests --- + +func testArrays(harmlessArray: Array, phoneNumberArray: Array, passwdArray: Array) { + _ = MD5().calculate(for: harmlessArray) // GOOD (not sensitive) + _ = MD5().calculate(for: phoneNumberArray) // $ Alert[swift/weak-sensitive-data-hashing] + _ = MD5().calculate(for: passwdArray) // $ Alert[swift/weak-password-hashing] + _ = SHA1().calculate(for: harmlessArray) // GOOD (not sensitive) + _ = SHA1().calculate(for: phoneNumberArray) // $ Alert[swift/weak-sensitive-data-hashing] + _ = SHA1().calculate(for: passwdArray) // $ Alert[swift/weak-password-hashing] + _ = SHA2(variant: .sha512).calculate(for: harmlessArray) // GOOD + _ = SHA2(variant: .sha512).calculate(for: phoneNumberArray) // GOOD + _ = SHA2(variant: .sha512).calculate(for: passwdArray) // $ Alert[swift/weak-password-hashing] + _ = SHA3(variant: .sha512).calculate(for: harmlessArray) // GOOD + _ = SHA3(variant: .sha512).calculate(for: phoneNumberArray) // GOOD + _ = SHA3(variant: .sha512).calculate(for: passwdArray) // $ Alert[swift/weak-password-hashing] + + _ = Digest.md5(harmlessArray) // GOOD (not sensitive) + _ = Digest.md5(phoneNumberArray) // $ Alert[swift/weak-sensitive-data-hashing] + _ = Digest.md5(passwdArray) // $ Alert[swift/weak-password-hashing] + _ = Digest.sha1(harmlessArray) // GOOD (not sensitive) + _ = Digest.sha1(phoneNumberArray) // $ Alert[swift/weak-sensitive-data-hashing] + _ = Digest.sha1(passwdArray) // $ Alert[swift/weak-password-hashing] + _ = Digest.sha512(harmlessArray) // GOOD (not sensitive) + _ = Digest.sha512(phoneNumberArray) // GOOD + _ = Digest.sha512(passwdArray) // $ Alert[swift/weak-password-hashing] + _ = Digest.sha2(harmlessArray, variant: .sha512) // GOOD (not sensitive) + _ = Digest.sha2(phoneNumberArray, variant: .sha512) // GOOD + _ = Digest.sha2(passwdArray, variant: .sha512) // $ Alert[swift/weak-password-hashing] + _ = Digest.sha3(harmlessArray, variant: .sha512) // GOOD (not sensitive) + _ = Digest.sha3(phoneNumberArray, variant: .sha512) // GOOD + _ = Digest.sha3(passwdArray, variant: .sha512) // $ Alert[swift/weak-password-hashing] + + _ = harmlessArray.md5() // GOOD (not sensitive) + _ = phoneNumberArray.md5() // $ Alert[swift/weak-sensitive-data-hashing] + _ = passwdArray.md5() // $ Alert[swift/weak-password-hashing] + _ = harmlessArray.sha1() // GOOD (not sensitive) + _ = phoneNumberArray.sha1() // $ Alert[swift/weak-sensitive-data-hashing] + _ = passwdArray.sha1() // $ Alert[swift/weak-password-hashing] + _ = harmlessArray.sha512() // GOOD + _ = phoneNumberArray.sha512() // GOOD + _ = passwdArray.sha512() // $ Alert[swift/weak-password-hashing] + _ = harmlessArray.sha2(.sha512) // GOOD + _ = phoneNumberArray.sha2(.sha512) // GOOD + _ = passwdArray.sha2(.sha512) // $ Alert[swift/weak-password-hashing] + _ = harmlessArray.sha3(.sha512) // GOOD + _ = phoneNumberArray.sha3(.sha512) // GOOD + _ = passwdArray.sha3(.sha512) // $ Alert[swift/weak-password-hashing] +} + +func testData(harmlessData: Data, medicalData: Data, passwdData: Data) { + _ = harmlessData.md5() // GOOD (not sensitive) + _ = medicalData.md5() // $ Alert[swift/weak-sensitive-data-hashing] + _ = passwdData.md5() // $ Alert[swift/weak-password-hashing] + _ = harmlessData.sha1() // GOOD (not sensitive) + _ = medicalData.sha1() // $ Alert[swift/weak-sensitive-data-hashing] + _ = passwdData.sha1() // $ Alert[swift/weak-password-hashing] + _ = harmlessData.sha512() // GOOD + _ = medicalData.sha512() // GOOD + _ = passwdData.sha512() // $ Alert[swift/weak-password-hashing] + _ = harmlessData.sha2(.sha512) // GOOD + _ = medicalData.sha2(.sha512) // GOOD + _ = passwdData.sha2(.sha512) // $ Alert[swift/weak-password-hashing] + _ = harmlessData.sha3(.sha512) // GOOD + _ = medicalData.sha3(.sha512) // GOOD + _ = passwdData.sha3(.sha512) // $ Alert[swift/weak-password-hashing] +} + +func testStrings(creditCardNumber: String, passwd: String) { + _ = "harmless".md5() // GOOD (not sensitive) + _ = creditCardNumber.md5() // $ Alert[swift/weak-sensitive-data-hashing] + _ = passwd.md5() // $ Alert[swift/weak-password-hashing] + _ = "harmless".sha1() // GOOD (not sensitive) + _ = creditCardNumber.sha1() // $ Alert[swift/weak-sensitive-data-hashing] + _ = passwd.sha1() // $ Alert[swift/weak-password-hashing] + _ = "harmless".sha512() // GOOD + _ = creditCardNumber.sha512() // GOOD + _ = passwd.sha512() // $ Alert[swift/weak-password-hashing] + _ = "harmless".sha2(.sha512) // GOOD + _ = creditCardNumber.sha2(.sha512) // GOOD + _ = passwd.sha2(.sha512) // $ Alert[swift/weak-password-hashing] + _ = "harmless".sha3(.sha512) // GOOD + _ = creditCardNumber.sha3(.sha512) // GOOD + _ = passwd.sha3(.sha512) // $ Alert[swift/weak-password-hashing] +} From cbf265f12faf248aa0df5e9fc58438297e19b61d Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Wed, 2 Dec 2026 19:00:53 +0000 Subject: [PATCH 2/8] unified: Collect original Swift weak password hashing configuration and models Inline the data flow configuration and query-specific models unchanged from WeakPasswordHashingQuery.qll, WeakPasswordHashingExtensions.qll, and WeakSensitiveDataHashingExtensions.qll, marking their provenance before adapting to unified Swift APIs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../security/CWE-328/WeakPasswordHashing.ql | 311 +++++++++++++++++- 1 file changed, 310 insertions(+), 1 deletion(-) diff --git a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql index 62a9cb652477..455b4562d414 100644 --- a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql +++ b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql @@ -13,9 +13,318 @@ */ import swift -import codeql.swift.security.WeakPasswordHashingQuery +import codeql.swift.security.SensitiveExprs +import codeql.swift.dataflow.DataFlow +import codeql.swift.dataflow.TaintTracking +import codeql.swift.dataflow.ExternalFlow import WeakPasswordHashingFlow::PathGraph +// Copied from swift/ql/lib/codeql/swift/security/WeakPasswordHashingQuery.qll. +/** + * Provides a taint tracking configuration to find use of inappropriate + * cryptographic hashing algorithms on passwords. + */ + +/** + * A taint tracking configuration from password expressions to inappropriate + * hashing sinks. + */ +module WeakPasswordHashingConfig implements DataFlow::ConfigSig { + predicate isSource(DataFlow::Node node) { + exists(SensitiveExpr se | + node.asExpr() = se and + se.getSensitiveType() instanceof SensitivePassword + ) + } + + predicate isSink(DataFlow::Node node) { node instanceof WeakPasswordHashingSink } + + predicate isBarrier(DataFlow::Node node) { node instanceof WeakPasswordHashingBarrier } + + predicate isBarrierIn(DataFlow::Node node) { + // make sources barriers so that we only report the closest instance + isSource(node) + } + + predicate isBarrierOut(DataFlow::Node node) { + // make sinks barriers so that we only report the closest instance + isSink(node) + } + + predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { + any(WeakPasswordHashingAdditionalFlowStep s).step(nodeFrom, nodeTo) + } + + predicate observeDiffInformedIncrementalMode() { any() } +} + +module WeakPasswordHashingFlow = TaintTracking::Global; + +// Copied from swift/ql/lib/codeql/swift/security/WeakPasswordHashingExtensions.qll. +/** + * Provides classes and predicates for reasoning about use of inappropriate + * cryptographic hashing algorithms on passwords. + */ + +/** + * A dataflow sink for weak password hashing vulnerabilities. That is, + * a `DataFlow::Node` that is passed into a weak password hashing function. + */ +abstract class WeakPasswordHashingSink extends DataFlow::Node { + /** + * Gets the name of the hashing algorithm, for display. + */ + abstract string getAlgorithm(); +} + +/** + * A barrier for weak password hashing vulnerabilities. + */ +abstract class WeakPasswordHashingBarrier extends DataFlow::Node { } + +/** + * A unit class for adding additional flow steps. + */ +class WeakPasswordHashingAdditionalFlowStep extends Unit { + /** + * Holds if the step from `node1` to `node2` should be considered a flow + * step for paths related to weak password hashing vulnerabilities. + */ + abstract predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo); +} + +/** + * A sink inherited from weak sensitive data hashing. Password hashing has + * stronger requirements than sensitive data hashing, since (in addition to + * its particular qualities) a password *is* sensitive data. Thus, any sink + * for the weak sensitive data hashing query is a sink for weak password + * hashing as well. + */ +private class InheritedWeakPasswordHashingSink extends WeakPasswordHashingSink instanceof WeakSensitiveDataHashingSink +{ + override string getAlgorithm() { result = this.(WeakSensitiveDataHashingSink).getAlgorithm() } +} + +private class WeakSensitiveDataHashingSinks extends SinkModelCsv { + override predicate row(string row) { + row = + [ + // CryptoKit + // (SHA-256, SHA-384 and SHA-512 are all variants of the SHA-2 algorithm) + ";SHA256;true;hash(data:);;;Argument[0];weak-password-hash-input-SHA256", + ";SHA256;true;hash(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA256", + ";SHA256;true;update(data:);;;Argument[0];weak-password-hash-input-SHA256", + ";SHA256;true;update(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA256", + ";SHA384;true;hash(data:);;;Argument[0];weak-password-hash-input-SHA384", + ";SHA384;true;hash(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA384", + ";SHA384;true;update(data:);;;Argument[0];weak-password-hash-input-SHA384", + ";SHA384;true;update(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA384", + ";SHA512;true;hash(data:);;;Argument[0];weak-password-hash-input-SHA512", + ";SHA512;true;hash(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA512", + ";SHA512;true;update(data:);;;Argument[0];weak-password-hash-input-SHA512", + ";SHA512;true;update(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA512", + // CryptoSwift + ";SHA2;true;calculate(for:);;;Argument[0];weak-password-hash-input-SHA2", + ";SHA2;true;callAsFunction(_:);;;Argument[0];weak-password-hash-input-SHA2", + ";SHA2;true;process64(block:currentHash:);;;Argument[0];weak-password-hash-input-SHA2", + ";SHA2;true;process32(block:currentHash:);;;Argument[0];weak-password-hash-input-SHA2", + ";SHA2;true;update(withBytes:isLast:);;;Argument[0];weak-password-hash-input-SHA2", + ";SHA3;true;calculate(for:);;;Argument[0];weak-password-hash-input-SHA2", + ";SHA3;true;callAsFunction(_:);;;Argument[0];weak-password-hash-input-SHA2", + ";SHA3;true;process(block:currentHash:);;;Argument[0];weak-password-hash-input-SHA2", + ";SHA3;true;update(withBytes:isLast:);;;Argument[0];weak-password-hash-input-SHA2", + ";Digest;true;sha2(_:variant:);;;Argument[0];weak-password-hash-input-SHA2", + ";Digest;true;sha3(_:variant:);;;Argument[0];weak-password-hash-input-SHA3", + ";Digest;true;sha224(_:);;;Argument[0];weak-password-hash-input-SHA224", + ";Digest;true;sha256(_:);;;Argument[0];weak-password-hash-input-SHA256", + ";Digest;true;sha384(_:);;;Argument[0];weak-password-hash-input-SHA384", + ";Digest;true;sha512(_:);;;Argument[0];weak-password-hash-input-SHA512", + ";Array;true;sha2(_:);;;Argument[-1];weak-password-hash-input-SHA2", + ";Array;true;sha3(_:);;;Argument[-1];weak-password-hash-input-SHA3", + ";Array;true;sha224();;;Argument[-1];weak-password-hash-input-SHA224", + ";Array;true;sha256();;;Argument[-1];weak-password-hash-input-SHA256", + ";Array;true;sha384();;;Argument[-1];weak-password-hash-input-SHA384", + ";Array;true;sha512();;;Argument[-1];weak-password-hash-input-SHA512", + ";Data;true;sha2(_:);;;Argument[-1];weak-password-hash-input-SHA2", + ";Data;true;sha3(_:);;;Argument[-1];weak-password-hash-input-SHA3", + ";Data;true;sha224();;;Argument[-1];weak-password-hash-input-SHA224", + ";Data;true;sha256();;;Argument[-1];weak-password-hash-input-SHA256", + ";Data;true;sha384();;;Argument[-1];weak-password-hash-input-SHA384", + ";Data;true;sha512();;;Argument[-1];weak-password-hash-input-SHA512", + ";String;true;sha2(_:);;;Argument[-1];weak-password-hash-input-SHA2", + ";String;true;sha3(_:);;;Argument[-1];weak-password-hash-input-SHA3", + ";String;true;sha224();;;Argument[-1];weak-password-hash-input-SHA224", + ";String;true;sha256();;;Argument[-1];weak-password-hash-input-SHA256", + ";String;true;sha384();;;Argument[-1];weak-password-hash-input-SHA384", + ";String;true;sha512();;;Argument[-1];weak-password-hash-input-SHA512", + ] + } +} + +/** + * A sink defined in a CSV model. + */ +private class DefaultWeakPasswordHashingSink extends WeakPasswordHashingSink { + string algorithm; + + DefaultWeakPasswordHashingSink() { sinkNode(this, "weak-password-hash-input-" + algorithm) } + + override string getAlgorithm() { result = algorithm } +} + +/** + * A sink for weak password hashing through a call with a metatype qualifier. + */ +private class WeakPasswordHashingMetatypeSink extends WeakPasswordHashingSink { + string algorithm; + + WeakPasswordHashingMetatypeSink() { + exists(CallExpr ce, Type t | + // call target + ce.getStaticTarget().getName() = + ["hash(data:)", "hash(bufferPointer:)", "update(data:)", "update(bufferPointer:)"] and + // argument + ce.getAnArgument().getExpr() = this.asExpr() and + // qualifier + t = ce.getQualifier().getType() and + algorithm = ["SHA256", "SHA384", "SHA512"] and + ( + t.getFullName() = algorithm + or + exists(TypeDecl td | + td.getInterfaceType() = t and + td.getFullName() = algorithm + ) + ) + ) + } + + override string getAlgorithm() { result = algorithm } +} + +/** + * A barrier for weak password hashing, when it occurs inside of + * certain cryptographic algorithms as part of their design. + */ +class WeakPasswordHashingImplementationBarrier extends WeakPasswordHashingBarrier { + WeakPasswordHashingImplementationBarrier() { + this.asParameter() + .getDeclaringFunction() + .(Function) + .getDeclaringDecl*() + .(NominalTypeDecl) + .getName() = ["HMAC", "PBKDF1", "PBKDF2"] + } +} + +// Copied from swift/ql/lib/codeql/swift/security/WeakSensitiveDataHashingExtensions.qll. +/** + * Provides classes and predicates for reasoning about use of broken or weak + * cryptographic hashing algorithms on sensitive data. + */ + +/** + * A dataflow sink for weak sensitive data hashing vulnerabilities. That is, + * a `DataFlow::Node` that is passed into a weak hashing function. + */ +abstract class WeakSensitiveDataHashingSink extends DataFlow::Node { + /** + * Gets the name of the hashing algorithm, for display. + */ + abstract string getAlgorithm(); +} + +/** + * A barrier for weak sensitive data hashing vulnerabilities. + */ +abstract class WeakSensitiveDataHashingBarrier extends DataFlow::Node { } + +/** + * A unit class for adding additional flow steps. + */ +class WeakSensitiveDataHashingAdditionalFlowStep extends Unit { + /** + * Holds if the step from `node1` to `node2` should be considered a flow + * step for paths related to weak sensitive data hashing vulnerabilities. + */ + abstract predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo); +} + +private class WeakSensitiveDataHashingSinks extends SinkModelCsv { + override predicate row(string row) { + row = + [ + // CryptoKit + ";Insecure.MD5;true;hash(data:);;;Argument[0];weak-hash-input-MD5", + ";Insecure.MD5;true;hash(bufferPointer:);;;Argument[0];weak-hash-input-MD5", + ";Insecure.MD5;true;update(data:);;;Argument[0];weak-hash-input-MD5", + ";Insecure.MD5;true;update(bufferPointer:);;;Argument[0];weak-hash-input-MD5", + ";Insecure.SHA1;true;hash(data:);;;Argument[0];weak-hash-input-SHA1", + ";Insecure.SHA1;true;hash(bufferPointer:);;;Argument[0];weak-hash-input-SHA1", + ";Insecure.SHA1;true;update(data:);;;Argument[0];weak-hash-input-SHA1", + ";Insecure.SHA1;true;update(bufferPointer:);;;Argument[0];weak-hash-input-SHA1", + // CryptoSwift + ";MD5;true;calculate(for:);;;Argument[0];weak-hash-input-MD5", + ";MD5;true;callAsFunction(_:);;;Argument[0];weak-hash-input-MD5", + ";MD5;true;process(block:currentHash:);;;Argument[0];weak-hash-input-MD5", + ";MD5;true;update(withBytes:isLast:);;;Argument[0];weak-hash-input-MD5", + ";SHA1;true;calculate(for:);;;Argument[0];weak-hash-input-SHA1", + ";SHA1;true;callAsFunction(_:);;;Argument[0];weak-hash-input-SHA1", + ";SHA1;true;process(block:currentHash:);;;Argument[0];weak-hash-input-SHA1", + ";SHA1;true;update(withBytes:isLast:);;;Argument[0];weak-hash-input-SHA1", + ";Digest;true;md5(_:);;;Argument[0];weak-hash-input-MD5", + ";Digest;true;sha1(_:);;;Argument[0];weak-hash-input-SHA1", + ";Array;true;md5();;;Argument[-1];weak-hash-input-MD5", + ";Array;true;sha1();;;Argument[-1];weak-hash-input-SHA1", + ";Data;true;md5();;;Argument[-1];weak-hash-input-MD5", + ";Data;true;sha1();;;Argument[-1];weak-hash-input-SHA1", + ";String;true;md5();;;Argument[-1];weak-hash-input-MD5", + ";String;true;sha1();;;Argument[-1];weak-hash-input-SHA1", + ] + } +} + +/** + * A sink defined in a CSV model. + */ +private class DefaultWeakSensitiveDataHashingSink extends WeakSensitiveDataHashingSink { + string algorithm; + + DefaultWeakSensitiveDataHashingSink() { sinkNode(this, "weak-hash-input-" + algorithm) } + + override string getAlgorithm() { result = algorithm } +} + +/** + * A sink for weak sensitive data hashing through a call with a metatype qualifier. + */ +private class WeakSensitiveDataHashingMetatypeSink extends WeakSensitiveDataHashingSink { + string algorithm; + + WeakSensitiveDataHashingMetatypeSink() { + exists(CallExpr ce, Type t | + // call target + ce.getStaticTarget().getName() = + ["hash(data:)", "hash(bufferPointer:)", "update(data:)", "update(bufferPointer:)"] and + // argument + ce.getAnArgument().getExpr() = this.asExpr() and + // qualifier + t = ce.getQualifier().getType() and + algorithm = ["MD5", "SHA1"] and + ( + t.getFullName() = "Insecure." + algorithm + or + exists(TypeDecl td | + td.getInterfaceType() = t and + td.getFullName() = "Insecure." + algorithm + ) + ) + ) + } + + override string getAlgorithm() { result = algorithm } +} + from WeakPasswordHashingFlow::PathNode source, WeakPasswordHashingFlow::PathNode sink, string algorithm where From 5fa9a024b6ed244cda8d24291ce5aa495bd5782d Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Wed, 2 Dec 2026 19:02:31 +0000 Subject: [PATCH 3/8] unified: Port weak password hashing query to unified Swift Adapt WeakPasswordHashing.ql to unified Swift using SensitiveData password sources, existing models-as-data sinks from legacy-swift.model.json, and an implementation barrier covering HMAC/PBKDF1/PBKDF2 declarations and extensions. Update the query ID, .qlref, and inline test expectations. All 48 original positive cases are detected with 0 testFailures. Because LegacyMaD currently ignores receiver types for method calls, overloaded sink names (hash, update, calculate) match multiple algorithm models per call site (152 #select rows total). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../security/CWE-328/WeakPasswordHashing.ql | 319 ++--------------- .../CWE-328/WeakPasswordHashing.expected | 334 ++++++++++++------ .../CWE-328/WeakPasswordHashing.qlref | 5 +- .../security/CWE-328/testArgon2Swift.swift | 2 +- .../security/CWE-328/testCryptoKit.swift | 210 +++++------ .../security/CWE-328/testCryptoSwift.swift | 69 ++-- 6 files changed, 409 insertions(+), 530 deletions(-) diff --git a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql index 455b4562d414..ac0d3bb66915 100644 --- a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql +++ b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql @@ -5,25 +5,27 @@ * @problem.severity warning * @security-severity 7.5 * @precision high - * @id swift/weak-password-hashing + * @id unified/swift/weak-password-hashing * @tags security * external/cwe/cwe-327 * external/cwe/cwe-328 * external/cwe/cwe-916 */ -import swift -import codeql.swift.security.SensitiveExprs -import codeql.swift.dataflow.DataFlow -import codeql.swift.dataflow.TaintTracking -import codeql.swift.dataflow.ExternalFlow -import WeakPasswordHashingFlow::PathGraph +import unified +import codeql.unified.security.SensitiveData -// Copied from swift/ql/lib/codeql/swift/security/WeakPasswordHashingQuery.qll. /** - * Provides a taint tracking configuration to find use of inappropriate - * cryptographic hashing algorithms on passwords. + * Holds if `node` is a sink for weak password hashing using `algorithm`. */ +private predicate isWeakPasswordHashingSink(DataFlow::Node node, string algorithm) { + exists(string kind | Models::isSink(node, kind) | + // match the following sinks: + // - `weak-hash-input-` (sinks that apply to both this query and `unified/swift/weak-sensitive-data-hashing`) + // - `weak-password-hash-input-` (sinks that apply to just this query) + algorithm = kind.regexpCapture("weak-(?:password-)?hash-input-(.+)", 1) + ) +} /** * A taint tracking configuration from password expressions to inappropriate @@ -31,15 +33,25 @@ import WeakPasswordHashingFlow::PathGraph */ module WeakPasswordHashingConfig implements DataFlow::ConfigSig { predicate isSource(DataFlow::Node node) { - exists(SensitiveExpr se | - node.asExpr() = se and - se.getSensitiveType() instanceof SensitivePassword - ) + node.(SensitiveData).getClassification() = SensitiveDataClassification::password() } - predicate isSink(DataFlow::Node node) { node instanceof WeakPasswordHashingSink } + predicate isSink(DataFlow::Node node) { isWeakPasswordHashingSink(node, _) } - predicate isBarrier(DataFlow::Node node) { node instanceof WeakPasswordHashingBarrier } + predicate isBarrier(DataFlow::Node node) { + // A barrier for weak password hashing, when it occurs inside of + // certain cryptographic algorithms as part of their design. + exists(Parameter param, ClassLikeDeclaration cls, string name | + node.asExpr() = param.getPattern() and + param.getParent().getParent+() = cls and + ( + name = cls.resolve().getName() + or + name = cls.getExtensionTarget().(Identifier).getValue() + ) and + name = ["HMAC", "PBKDF1", "PBKDF2"] + ) + } predicate isBarrierIn(DataFlow::Node node) { // make sources barriers so that we only report the closest instance @@ -50,286 +62,17 @@ module WeakPasswordHashingConfig implements DataFlow::ConfigSig { // make sinks barriers so that we only report the closest instance isSink(node) } - - predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { - any(WeakPasswordHashingAdditionalFlowStep s).step(nodeFrom, nodeTo) - } - - predicate observeDiffInformedIncrementalMode() { any() } } module WeakPasswordHashingFlow = TaintTracking::Global; -// Copied from swift/ql/lib/codeql/swift/security/WeakPasswordHashingExtensions.qll. -/** - * Provides classes and predicates for reasoning about use of inappropriate - * cryptographic hashing algorithms on passwords. - */ - -/** - * A dataflow sink for weak password hashing vulnerabilities. That is, - * a `DataFlow::Node` that is passed into a weak password hashing function. - */ -abstract class WeakPasswordHashingSink extends DataFlow::Node { - /** - * Gets the name of the hashing algorithm, for display. - */ - abstract string getAlgorithm(); -} - -/** - * A barrier for weak password hashing vulnerabilities. - */ -abstract class WeakPasswordHashingBarrier extends DataFlow::Node { } - -/** - * A unit class for adding additional flow steps. - */ -class WeakPasswordHashingAdditionalFlowStep extends Unit { - /** - * Holds if the step from `node1` to `node2` should be considered a flow - * step for paths related to weak password hashing vulnerabilities. - */ - abstract predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo); -} - -/** - * A sink inherited from weak sensitive data hashing. Password hashing has - * stronger requirements than sensitive data hashing, since (in addition to - * its particular qualities) a password *is* sensitive data. Thus, any sink - * for the weak sensitive data hashing query is a sink for weak password - * hashing as well. - */ -private class InheritedWeakPasswordHashingSink extends WeakPasswordHashingSink instanceof WeakSensitiveDataHashingSink -{ - override string getAlgorithm() { result = this.(WeakSensitiveDataHashingSink).getAlgorithm() } -} - -private class WeakSensitiveDataHashingSinks extends SinkModelCsv { - override predicate row(string row) { - row = - [ - // CryptoKit - // (SHA-256, SHA-384 and SHA-512 are all variants of the SHA-2 algorithm) - ";SHA256;true;hash(data:);;;Argument[0];weak-password-hash-input-SHA256", - ";SHA256;true;hash(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA256", - ";SHA256;true;update(data:);;;Argument[0];weak-password-hash-input-SHA256", - ";SHA256;true;update(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA256", - ";SHA384;true;hash(data:);;;Argument[0];weak-password-hash-input-SHA384", - ";SHA384;true;hash(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA384", - ";SHA384;true;update(data:);;;Argument[0];weak-password-hash-input-SHA384", - ";SHA384;true;update(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA384", - ";SHA512;true;hash(data:);;;Argument[0];weak-password-hash-input-SHA512", - ";SHA512;true;hash(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA512", - ";SHA512;true;update(data:);;;Argument[0];weak-password-hash-input-SHA512", - ";SHA512;true;update(bufferPointer:);;;Argument[0];weak-password-hash-input-SHA512", - // CryptoSwift - ";SHA2;true;calculate(for:);;;Argument[0];weak-password-hash-input-SHA2", - ";SHA2;true;callAsFunction(_:);;;Argument[0];weak-password-hash-input-SHA2", - ";SHA2;true;process64(block:currentHash:);;;Argument[0];weak-password-hash-input-SHA2", - ";SHA2;true;process32(block:currentHash:);;;Argument[0];weak-password-hash-input-SHA2", - ";SHA2;true;update(withBytes:isLast:);;;Argument[0];weak-password-hash-input-SHA2", - ";SHA3;true;calculate(for:);;;Argument[0];weak-password-hash-input-SHA2", - ";SHA3;true;callAsFunction(_:);;;Argument[0];weak-password-hash-input-SHA2", - ";SHA3;true;process(block:currentHash:);;;Argument[0];weak-password-hash-input-SHA2", - ";SHA3;true;update(withBytes:isLast:);;;Argument[0];weak-password-hash-input-SHA2", - ";Digest;true;sha2(_:variant:);;;Argument[0];weak-password-hash-input-SHA2", - ";Digest;true;sha3(_:variant:);;;Argument[0];weak-password-hash-input-SHA3", - ";Digest;true;sha224(_:);;;Argument[0];weak-password-hash-input-SHA224", - ";Digest;true;sha256(_:);;;Argument[0];weak-password-hash-input-SHA256", - ";Digest;true;sha384(_:);;;Argument[0];weak-password-hash-input-SHA384", - ";Digest;true;sha512(_:);;;Argument[0];weak-password-hash-input-SHA512", - ";Array;true;sha2(_:);;;Argument[-1];weak-password-hash-input-SHA2", - ";Array;true;sha3(_:);;;Argument[-1];weak-password-hash-input-SHA3", - ";Array;true;sha224();;;Argument[-1];weak-password-hash-input-SHA224", - ";Array;true;sha256();;;Argument[-1];weak-password-hash-input-SHA256", - ";Array;true;sha384();;;Argument[-1];weak-password-hash-input-SHA384", - ";Array;true;sha512();;;Argument[-1];weak-password-hash-input-SHA512", - ";Data;true;sha2(_:);;;Argument[-1];weak-password-hash-input-SHA2", - ";Data;true;sha3(_:);;;Argument[-1];weak-password-hash-input-SHA3", - ";Data;true;sha224();;;Argument[-1];weak-password-hash-input-SHA224", - ";Data;true;sha256();;;Argument[-1];weak-password-hash-input-SHA256", - ";Data;true;sha384();;;Argument[-1];weak-password-hash-input-SHA384", - ";Data;true;sha512();;;Argument[-1];weak-password-hash-input-SHA512", - ";String;true;sha2(_:);;;Argument[-1];weak-password-hash-input-SHA2", - ";String;true;sha3(_:);;;Argument[-1];weak-password-hash-input-SHA3", - ";String;true;sha224();;;Argument[-1];weak-password-hash-input-SHA224", - ";String;true;sha256();;;Argument[-1];weak-password-hash-input-SHA256", - ";String;true;sha384();;;Argument[-1];weak-password-hash-input-SHA384", - ";String;true;sha512();;;Argument[-1];weak-password-hash-input-SHA512", - ] - } -} - -/** - * A sink defined in a CSV model. - */ -private class DefaultWeakPasswordHashingSink extends WeakPasswordHashingSink { - string algorithm; - - DefaultWeakPasswordHashingSink() { sinkNode(this, "weak-password-hash-input-" + algorithm) } - - override string getAlgorithm() { result = algorithm } -} - -/** - * A sink for weak password hashing through a call with a metatype qualifier. - */ -private class WeakPasswordHashingMetatypeSink extends WeakPasswordHashingSink { - string algorithm; - - WeakPasswordHashingMetatypeSink() { - exists(CallExpr ce, Type t | - // call target - ce.getStaticTarget().getName() = - ["hash(data:)", "hash(bufferPointer:)", "update(data:)", "update(bufferPointer:)"] and - // argument - ce.getAnArgument().getExpr() = this.asExpr() and - // qualifier - t = ce.getQualifier().getType() and - algorithm = ["SHA256", "SHA384", "SHA512"] and - ( - t.getFullName() = algorithm - or - exists(TypeDecl td | - td.getInterfaceType() = t and - td.getFullName() = algorithm - ) - ) - ) - } - - override string getAlgorithm() { result = algorithm } -} - -/** - * A barrier for weak password hashing, when it occurs inside of - * certain cryptographic algorithms as part of their design. - */ -class WeakPasswordHashingImplementationBarrier extends WeakPasswordHashingBarrier { - WeakPasswordHashingImplementationBarrier() { - this.asParameter() - .getDeclaringFunction() - .(Function) - .getDeclaringDecl*() - .(NominalTypeDecl) - .getName() = ["HMAC", "PBKDF1", "PBKDF2"] - } -} - -// Copied from swift/ql/lib/codeql/swift/security/WeakSensitiveDataHashingExtensions.qll. -/** - * Provides classes and predicates for reasoning about use of broken or weak - * cryptographic hashing algorithms on sensitive data. - */ - -/** - * A dataflow sink for weak sensitive data hashing vulnerabilities. That is, - * a `DataFlow::Node` that is passed into a weak hashing function. - */ -abstract class WeakSensitiveDataHashingSink extends DataFlow::Node { - /** - * Gets the name of the hashing algorithm, for display. - */ - abstract string getAlgorithm(); -} - -/** - * A barrier for weak sensitive data hashing vulnerabilities. - */ -abstract class WeakSensitiveDataHashingBarrier extends DataFlow::Node { } - -/** - * A unit class for adding additional flow steps. - */ -class WeakSensitiveDataHashingAdditionalFlowStep extends Unit { - /** - * Holds if the step from `node1` to `node2` should be considered a flow - * step for paths related to weak sensitive data hashing vulnerabilities. - */ - abstract predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo); -} - -private class WeakSensitiveDataHashingSinks extends SinkModelCsv { - override predicate row(string row) { - row = - [ - // CryptoKit - ";Insecure.MD5;true;hash(data:);;;Argument[0];weak-hash-input-MD5", - ";Insecure.MD5;true;hash(bufferPointer:);;;Argument[0];weak-hash-input-MD5", - ";Insecure.MD5;true;update(data:);;;Argument[0];weak-hash-input-MD5", - ";Insecure.MD5;true;update(bufferPointer:);;;Argument[0];weak-hash-input-MD5", - ";Insecure.SHA1;true;hash(data:);;;Argument[0];weak-hash-input-SHA1", - ";Insecure.SHA1;true;hash(bufferPointer:);;;Argument[0];weak-hash-input-SHA1", - ";Insecure.SHA1;true;update(data:);;;Argument[0];weak-hash-input-SHA1", - ";Insecure.SHA1;true;update(bufferPointer:);;;Argument[0];weak-hash-input-SHA1", - // CryptoSwift - ";MD5;true;calculate(for:);;;Argument[0];weak-hash-input-MD5", - ";MD5;true;callAsFunction(_:);;;Argument[0];weak-hash-input-MD5", - ";MD5;true;process(block:currentHash:);;;Argument[0];weak-hash-input-MD5", - ";MD5;true;update(withBytes:isLast:);;;Argument[0];weak-hash-input-MD5", - ";SHA1;true;calculate(for:);;;Argument[0];weak-hash-input-SHA1", - ";SHA1;true;callAsFunction(_:);;;Argument[0];weak-hash-input-SHA1", - ";SHA1;true;process(block:currentHash:);;;Argument[0];weak-hash-input-SHA1", - ";SHA1;true;update(withBytes:isLast:);;;Argument[0];weak-hash-input-SHA1", - ";Digest;true;md5(_:);;;Argument[0];weak-hash-input-MD5", - ";Digest;true;sha1(_:);;;Argument[0];weak-hash-input-SHA1", - ";Array;true;md5();;;Argument[-1];weak-hash-input-MD5", - ";Array;true;sha1();;;Argument[-1];weak-hash-input-SHA1", - ";Data;true;md5();;;Argument[-1];weak-hash-input-MD5", - ";Data;true;sha1();;;Argument[-1];weak-hash-input-SHA1", - ";String;true;md5();;;Argument[-1];weak-hash-input-MD5", - ";String;true;sha1();;;Argument[-1];weak-hash-input-SHA1", - ] - } -} - -/** - * A sink defined in a CSV model. - */ -private class DefaultWeakSensitiveDataHashingSink extends WeakSensitiveDataHashingSink { - string algorithm; - - DefaultWeakSensitiveDataHashingSink() { sinkNode(this, "weak-hash-input-" + algorithm) } - - override string getAlgorithm() { result = algorithm } -} - -/** - * A sink for weak sensitive data hashing through a call with a metatype qualifier. - */ -private class WeakSensitiveDataHashingMetatypeSink extends WeakSensitiveDataHashingSink { - string algorithm; - - WeakSensitiveDataHashingMetatypeSink() { - exists(CallExpr ce, Type t | - // call target - ce.getStaticTarget().getName() = - ["hash(data:)", "hash(bufferPointer:)", "update(data:)", "update(bufferPointer:)"] and - // argument - ce.getAnArgument().getExpr() = this.asExpr() and - // qualifier - t = ce.getQualifier().getType() and - algorithm = ["MD5", "SHA1"] and - ( - t.getFullName() = "Insecure." + algorithm - or - exists(TypeDecl td | - td.getInterfaceType() = t and - td.getFullName() = "Insecure." + algorithm - ) - ) - ) - } - - override string getAlgorithm() { result = algorithm } -} +import WeakPasswordHashingFlow::PathGraph from WeakPasswordHashingFlow::PathNode source, WeakPasswordHashingFlow::PathNode sink, string algorithm where WeakPasswordHashingFlow::flowPath(source, sink) and - algorithm = sink.getNode().(WeakPasswordHashingSink).getAlgorithm() + isWeakPasswordHashingSink(sink.getNode(), algorithm) select sink.getNode(), source, sink, "Insecure hashing algorithm (" + algorithm + ") depends on $@.", source.getNode(), - "password (" + source.getNode().asExpr() + ")" + "password (" + source.getNode().toString() + ")" diff --git a/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected index 2b0eed8d0c2b..92c988bca886 100644 --- a/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected +++ b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected @@ -1,104 +1,238 @@ #select -| testCryptoKit.swift:84:47:84:47 | passwd | testCryptoKit.swift:84:47:84:47 | passwd | testCryptoKit.swift:84:47:84:47 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:84:47:84:47 | passwd | password (passwd) | -| testCryptoKit.swift:85:52:85:52 | passwd | testCryptoKit.swift:85:52:85:52 | passwd | testCryptoKit.swift:85:52:85:52 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:85:52:85:52 | passwd | password (passwd) | -| testCryptoKit.swift:91:36:91:36 | passwd | testCryptoKit.swift:91:36:91:36 | passwd | testCryptoKit.swift:91:36:91:36 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:91:36:91:36 | passwd | password (passwd) | -| testCryptoKit.swift:92:45:92:45 | passwd | testCryptoKit.swift:92:45:92:45 | passwd | testCryptoKit.swift:92:45:92:45 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:92:45:92:45 | passwd | password (passwd) | -| testCryptoKit.swift:98:44:98:44 | passwd | testCryptoKit.swift:98:44:98:44 | passwd | testCryptoKit.swift:98:44:98:44 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:98:44:98:44 | passwd | password (passwd) | -| testCryptoKit.swift:99:53:99:53 | passwd | testCryptoKit.swift:99:53:99:53 | passwd | testCryptoKit.swift:99:53:99:53 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:99:53:99:53 | passwd | password (passwd) | -| testCryptoKit.swift:105:37:105:37 | passwd | testCryptoKit.swift:105:37:105:37 | passwd | testCryptoKit.swift:105:37:105:37 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:105:37:105:37 | passwd | password (passwd) | -| testCryptoKit.swift:106:46:106:46 | passwd | testCryptoKit.swift:106:46:106:46 | passwd | testCryptoKit.swift:106:46:106:46 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:106:46:106:46 | passwd | password (passwd) | -| testCryptoKit.swift:112:37:112:37 | passwd | testCryptoKit.swift:112:37:112:37 | passwd | testCryptoKit.swift:112:37:112:37 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:112:37:112:37 | passwd | password (passwd) | -| testCryptoKit.swift:113:46:113:46 | passwd | testCryptoKit.swift:113:46:113:46 | passwd | testCryptoKit.swift:113:46:113:46 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:113:46:113:46 | passwd | password (passwd) | -| testCryptoKit.swift:119:37:119:37 | passwd | testCryptoKit.swift:119:37:119:37 | passwd | testCryptoKit.swift:119:37:119:37 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:119:37:119:37 | passwd | password (passwd) | -| testCryptoKit.swift:120:46:120:46 | passwd | testCryptoKit.swift:120:46:120:46 | passwd | testCryptoKit.swift:120:46:120:46 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:120:46:120:46 | passwd | password (passwd) | -| testCryptoKit.swift:129:23:129:23 | passwd | testCryptoKit.swift:129:23:129:23 | passwd | testCryptoKit.swift:129:23:129:23 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:129:23:129:23 | passwd | password (passwd) | -| testCryptoKit.swift:138:23:138:23 | passwd | testCryptoKit.swift:138:23:138:23 | passwd | testCryptoKit.swift:138:23:138:23 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:138:23:138:23 | passwd | password (passwd) | -| testCryptoKit.swift:147:23:147:23 | passwd | testCryptoKit.swift:147:23:147:23 | passwd | testCryptoKit.swift:147:23:147:23 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:147:23:147:23 | passwd | password (passwd) | -| testCryptoKit.swift:156:23:156:23 | passwd | testCryptoKit.swift:156:23:156:23 | passwd | testCryptoKit.swift:156:23:156:23 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:156:23:156:23 | passwd | password (passwd) | -| testCryptoKit.swift:165:23:165:23 | passwd | testCryptoKit.swift:165:23:165:23 | passwd | testCryptoKit.swift:165:23:165:23 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:165:23:165:23 | passwd | password (passwd) | -| testCryptoKit.swift:174:32:174:32 | passwd | testCryptoKit.swift:174:32:174:32 | passwd | testCryptoKit.swift:174:32:174:32 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:174:32:174:32 | passwd | password (passwd) | -| testCryptoKit.swift:183:32:183:32 | passwd | testCryptoKit.swift:183:32:183:32 | passwd | testCryptoKit.swift:183:32:183:32 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:183:32:183:32 | passwd | password (passwd) | -| testCryptoKit.swift:192:32:192:32 | passwd | testCryptoKit.swift:192:32:192:32 | passwd | testCryptoKit.swift:192:32:192:32 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:192:32:192:32 | passwd | password (passwd) | -| testCryptoKit.swift:201:32:201:32 | passwd | testCryptoKit.swift:201:32:201:32 | passwd | testCryptoKit.swift:201:32:201:32 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:201:32:201:32 | passwd | password (passwd) | -| testCryptoKit.swift:210:32:210:32 | passwd | testCryptoKit.swift:210:32:210:32 | passwd | testCryptoKit.swift:210:32:210:32 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:210:32:210:32 | passwd | password (passwd) | -| testCryptoKit.swift:220:49:220:49 | passwordData | testCryptoKit.swift:220:49:220:49 | passwordData | testCryptoKit.swift:220:49:220:49 | passwordData | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:220:49:220:49 | passwordData | password (passwordData) | -| testCryptoKit.swift:224:33:224:57 | call to Data.init(_:) | testCryptoKit.swift:224:38:224:38 | passwordString | testCryptoKit.swift:224:33:224:57 | call to Data.init(_:) | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:224:38:224:38 | passwordString | password (passwordString) | -| testCryptoSwift.swift:154:30:154:30 | passwdArray | testCryptoSwift.swift:154:30:154:30 | passwdArray | testCryptoSwift.swift:154:30:154:30 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:154:30:154:30 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:157:31:157:31 | passwdArray | testCryptoSwift.swift:157:31:157:31 | passwdArray | testCryptoSwift.swift:157:31:157:31 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:157:31:157:31 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:160:47:160:47 | passwdArray | testCryptoSwift.swift:160:47:160:47 | passwdArray | testCryptoSwift.swift:160:47:160:47 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:160:47:160:47 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:163:47:163:47 | passwdArray | testCryptoSwift.swift:163:47:163:47 | passwdArray | testCryptoSwift.swift:163:47:163:47 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:163:47:163:47 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:167:20:167:20 | passwdArray | testCryptoSwift.swift:167:20:167:20 | passwdArray | testCryptoSwift.swift:167:20:167:20 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:167:20:167:20 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:170:21:170:21 | passwdArray | testCryptoSwift.swift:170:21:170:21 | passwdArray | testCryptoSwift.swift:170:21:170:21 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:170:21:170:21 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:173:23:173:23 | passwdArray | testCryptoSwift.swift:173:23:173:23 | passwdArray | testCryptoSwift.swift:173:23:173:23 | passwdArray | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:173:23:173:23 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:176:21:176:21 | passwdArray | testCryptoSwift.swift:176:21:176:21 | passwdArray | testCryptoSwift.swift:176:21:176:21 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:176:21:176:21 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:179:21:179:21 | passwdArray | testCryptoSwift.swift:179:21:179:21 | passwdArray | testCryptoSwift.swift:179:21:179:21 | passwdArray | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:179:21:179:21 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:183:9:183:9 | passwdArray | testCryptoSwift.swift:183:9:183:9 | passwdArray | testCryptoSwift.swift:183:9:183:9 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:183:9:183:9 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:186:9:186:9 | passwdArray | testCryptoSwift.swift:186:9:186:9 | passwdArray | testCryptoSwift.swift:186:9:186:9 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:186:9:186:9 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:189:9:189:9 | passwdArray | testCryptoSwift.swift:189:9:189:9 | passwdArray | testCryptoSwift.swift:189:9:189:9 | passwdArray | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:189:9:189:9 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:192:9:192:9 | passwdArray | testCryptoSwift.swift:192:9:192:9 | passwdArray | testCryptoSwift.swift:192:9:192:9 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:192:9:192:9 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:195:9:195:9 | passwdArray | testCryptoSwift.swift:195:9:195:9 | passwdArray | testCryptoSwift.swift:195:9:195:9 | passwdArray | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:195:9:195:9 | passwdArray | password (passwdArray) | -| testCryptoSwift.swift:201:9:201:9 | passwdData | testCryptoSwift.swift:201:9:201:9 | passwdData | testCryptoSwift.swift:201:9:201:9 | passwdData | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:201:9:201:9 | passwdData | password (passwdData) | -| testCryptoSwift.swift:204:9:204:9 | passwdData | testCryptoSwift.swift:204:9:204:9 | passwdData | testCryptoSwift.swift:204:9:204:9 | passwdData | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:204:9:204:9 | passwdData | password (passwdData) | -| testCryptoSwift.swift:207:9:207:9 | passwdData | testCryptoSwift.swift:207:9:207:9 | passwdData | testCryptoSwift.swift:207:9:207:9 | passwdData | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:207:9:207:9 | passwdData | password (passwdData) | -| testCryptoSwift.swift:210:9:210:9 | passwdData | testCryptoSwift.swift:210:9:210:9 | passwdData | testCryptoSwift.swift:210:9:210:9 | passwdData | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:210:9:210:9 | passwdData | password (passwdData) | -| testCryptoSwift.swift:213:9:213:9 | passwdData | testCryptoSwift.swift:213:9:213:9 | passwdData | testCryptoSwift.swift:213:9:213:9 | passwdData | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:213:9:213:9 | passwdData | password (passwdData) | -| testCryptoSwift.swift:219:9:219:9 | passwd | testCryptoSwift.swift:219:9:219:9 | passwd | testCryptoSwift.swift:219:9:219:9 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:219:9:219:9 | passwd | password (passwd) | -| testCryptoSwift.swift:222:9:222:9 | passwd | testCryptoSwift.swift:222:9:222:9 | passwd | testCryptoSwift.swift:222:9:222:9 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:222:9:222:9 | passwd | password (passwd) | -| testCryptoSwift.swift:225:9:225:9 | passwd | testCryptoSwift.swift:225:9:225:9 | passwd | testCryptoSwift.swift:225:9:225:9 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:225:9:225:9 | passwd | password (passwd) | -| testCryptoSwift.swift:228:9:228:9 | passwd | testCryptoSwift.swift:228:9:228:9 | passwd | testCryptoSwift.swift:228:9:228:9 | passwd | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:228:9:228:9 | passwd | password (passwd) | -| testCryptoSwift.swift:231:9:231:9 | passwd | testCryptoSwift.swift:231:9:231:9 | passwd | testCryptoSwift.swift:231:9:231:9 | passwd | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:231:9:231:9 | passwd | password (passwd) | +| testCryptoKit.swift:84:47:84:52 | passwd | testCryptoKit.swift:84:47:84:52 | passwd | testCryptoKit.swift:84:47:84:52 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:84:47:84:52 | passwd | password (passwd) | +| testCryptoKit.swift:84:47:84:52 | passwd | testCryptoKit.swift:84:47:84:52 | passwd | testCryptoKit.swift:84:47:84:52 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:84:47:84:52 | passwd | password (passwd) | +| testCryptoKit.swift:84:47:84:52 | passwd | testCryptoKit.swift:84:47:84:52 | passwd | testCryptoKit.swift:84:47:84:52 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:84:47:84:52 | passwd | password (passwd) | +| testCryptoKit.swift:84:47:84:52 | passwd | testCryptoKit.swift:84:47:84:52 | passwd | testCryptoKit.swift:84:47:84:52 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:84:47:84:52 | passwd | password (passwd) | +| testCryptoKit.swift:84:47:84:52 | passwd | testCryptoKit.swift:84:47:84:52 | passwd | testCryptoKit.swift:84:47:84:52 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:84:47:84:52 | passwd | password (passwd) | +| testCryptoKit.swift:85:52:85:57 | passwd | testCryptoKit.swift:85:52:85:57 | passwd | testCryptoKit.swift:85:52:85:57 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:85:52:85:57 | passwd | password (passwd) | +| testCryptoKit.swift:85:52:85:57 | passwd | testCryptoKit.swift:85:52:85:57 | passwd | testCryptoKit.swift:85:52:85:57 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:85:52:85:57 | passwd | password (passwd) | +| testCryptoKit.swift:85:52:85:57 | passwd | testCryptoKit.swift:85:52:85:57 | passwd | testCryptoKit.swift:85:52:85:57 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:85:52:85:57 | passwd | password (passwd) | +| testCryptoKit.swift:85:52:85:57 | passwd | testCryptoKit.swift:85:52:85:57 | passwd | testCryptoKit.swift:85:52:85:57 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:85:52:85:57 | passwd | password (passwd) | +| testCryptoKit.swift:85:52:85:57 | passwd | testCryptoKit.swift:85:52:85:57 | passwd | testCryptoKit.swift:85:52:85:57 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:85:52:85:57 | passwd | password (passwd) | +| testCryptoKit.swift:91:36:91:41 | passwd | testCryptoKit.swift:91:36:91:41 | passwd | testCryptoKit.swift:91:36:91:41 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:91:36:91:41 | passwd | password (passwd) | +| testCryptoKit.swift:91:36:91:41 | passwd | testCryptoKit.swift:91:36:91:41 | passwd | testCryptoKit.swift:91:36:91:41 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:91:36:91:41 | passwd | password (passwd) | +| testCryptoKit.swift:91:36:91:41 | passwd | testCryptoKit.swift:91:36:91:41 | passwd | testCryptoKit.swift:91:36:91:41 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:91:36:91:41 | passwd | password (passwd) | +| testCryptoKit.swift:91:36:91:41 | passwd | testCryptoKit.swift:91:36:91:41 | passwd | testCryptoKit.swift:91:36:91:41 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:91:36:91:41 | passwd | password (passwd) | +| testCryptoKit.swift:91:36:91:41 | passwd | testCryptoKit.swift:91:36:91:41 | passwd | testCryptoKit.swift:91:36:91:41 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:91:36:91:41 | passwd | password (passwd) | +| testCryptoKit.swift:92:45:92:50 | passwd | testCryptoKit.swift:92:45:92:50 | passwd | testCryptoKit.swift:92:45:92:50 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:92:45:92:50 | passwd | password (passwd) | +| testCryptoKit.swift:92:45:92:50 | passwd | testCryptoKit.swift:92:45:92:50 | passwd | testCryptoKit.swift:92:45:92:50 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:92:45:92:50 | passwd | password (passwd) | +| testCryptoKit.swift:92:45:92:50 | passwd | testCryptoKit.swift:92:45:92:50 | passwd | testCryptoKit.swift:92:45:92:50 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:92:45:92:50 | passwd | password (passwd) | +| testCryptoKit.swift:92:45:92:50 | passwd | testCryptoKit.swift:92:45:92:50 | passwd | testCryptoKit.swift:92:45:92:50 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:92:45:92:50 | passwd | password (passwd) | +| testCryptoKit.swift:92:45:92:50 | passwd | testCryptoKit.swift:92:45:92:50 | passwd | testCryptoKit.swift:92:45:92:50 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:92:45:92:50 | passwd | password (passwd) | +| testCryptoKit.swift:98:44:98:49 | passwd | testCryptoKit.swift:98:44:98:49 | passwd | testCryptoKit.swift:98:44:98:49 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:98:44:98:49 | passwd | password (passwd) | +| testCryptoKit.swift:98:44:98:49 | passwd | testCryptoKit.swift:98:44:98:49 | passwd | testCryptoKit.swift:98:44:98:49 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:98:44:98:49 | passwd | password (passwd) | +| testCryptoKit.swift:98:44:98:49 | passwd | testCryptoKit.swift:98:44:98:49 | passwd | testCryptoKit.swift:98:44:98:49 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:98:44:98:49 | passwd | password (passwd) | +| testCryptoKit.swift:98:44:98:49 | passwd | testCryptoKit.swift:98:44:98:49 | passwd | testCryptoKit.swift:98:44:98:49 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:98:44:98:49 | passwd | password (passwd) | +| testCryptoKit.swift:98:44:98:49 | passwd | testCryptoKit.swift:98:44:98:49 | passwd | testCryptoKit.swift:98:44:98:49 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:98:44:98:49 | passwd | password (passwd) | +| testCryptoKit.swift:99:53:99:58 | passwd | testCryptoKit.swift:99:53:99:58 | passwd | testCryptoKit.swift:99:53:99:58 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:99:53:99:58 | passwd | password (passwd) | +| testCryptoKit.swift:99:53:99:58 | passwd | testCryptoKit.swift:99:53:99:58 | passwd | testCryptoKit.swift:99:53:99:58 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:99:53:99:58 | passwd | password (passwd) | +| testCryptoKit.swift:99:53:99:58 | passwd | testCryptoKit.swift:99:53:99:58 | passwd | testCryptoKit.swift:99:53:99:58 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:99:53:99:58 | passwd | password (passwd) | +| testCryptoKit.swift:99:53:99:58 | passwd | testCryptoKit.swift:99:53:99:58 | passwd | testCryptoKit.swift:99:53:99:58 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:99:53:99:58 | passwd | password (passwd) | +| testCryptoKit.swift:99:53:99:58 | passwd | testCryptoKit.swift:99:53:99:58 | passwd | testCryptoKit.swift:99:53:99:58 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:99:53:99:58 | passwd | password (passwd) | +| testCryptoKit.swift:105:37:105:42 | passwd | testCryptoKit.swift:105:37:105:42 | passwd | testCryptoKit.swift:105:37:105:42 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:105:37:105:42 | passwd | password (passwd) | +| testCryptoKit.swift:105:37:105:42 | passwd | testCryptoKit.swift:105:37:105:42 | passwd | testCryptoKit.swift:105:37:105:42 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:105:37:105:42 | passwd | password (passwd) | +| testCryptoKit.swift:105:37:105:42 | passwd | testCryptoKit.swift:105:37:105:42 | passwd | testCryptoKit.swift:105:37:105:42 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:105:37:105:42 | passwd | password (passwd) | +| testCryptoKit.swift:105:37:105:42 | passwd | testCryptoKit.swift:105:37:105:42 | passwd | testCryptoKit.swift:105:37:105:42 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:105:37:105:42 | passwd | password (passwd) | +| testCryptoKit.swift:105:37:105:42 | passwd | testCryptoKit.swift:105:37:105:42 | passwd | testCryptoKit.swift:105:37:105:42 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:105:37:105:42 | passwd | password (passwd) | +| testCryptoKit.swift:106:46:106:51 | passwd | testCryptoKit.swift:106:46:106:51 | passwd | testCryptoKit.swift:106:46:106:51 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:106:46:106:51 | passwd | password (passwd) | +| testCryptoKit.swift:106:46:106:51 | passwd | testCryptoKit.swift:106:46:106:51 | passwd | testCryptoKit.swift:106:46:106:51 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:106:46:106:51 | passwd | password (passwd) | +| testCryptoKit.swift:106:46:106:51 | passwd | testCryptoKit.swift:106:46:106:51 | passwd | testCryptoKit.swift:106:46:106:51 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:106:46:106:51 | passwd | password (passwd) | +| testCryptoKit.swift:106:46:106:51 | passwd | testCryptoKit.swift:106:46:106:51 | passwd | testCryptoKit.swift:106:46:106:51 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:106:46:106:51 | passwd | password (passwd) | +| testCryptoKit.swift:106:46:106:51 | passwd | testCryptoKit.swift:106:46:106:51 | passwd | testCryptoKit.swift:106:46:106:51 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:106:46:106:51 | passwd | password (passwd) | +| testCryptoKit.swift:112:37:112:42 | passwd | testCryptoKit.swift:112:37:112:42 | passwd | testCryptoKit.swift:112:37:112:42 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:112:37:112:42 | passwd | password (passwd) | +| testCryptoKit.swift:112:37:112:42 | passwd | testCryptoKit.swift:112:37:112:42 | passwd | testCryptoKit.swift:112:37:112:42 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:112:37:112:42 | passwd | password (passwd) | +| testCryptoKit.swift:112:37:112:42 | passwd | testCryptoKit.swift:112:37:112:42 | passwd | testCryptoKit.swift:112:37:112:42 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:112:37:112:42 | passwd | password (passwd) | +| testCryptoKit.swift:112:37:112:42 | passwd | testCryptoKit.swift:112:37:112:42 | passwd | testCryptoKit.swift:112:37:112:42 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:112:37:112:42 | passwd | password (passwd) | +| testCryptoKit.swift:112:37:112:42 | passwd | testCryptoKit.swift:112:37:112:42 | passwd | testCryptoKit.swift:112:37:112:42 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:112:37:112:42 | passwd | password (passwd) | +| testCryptoKit.swift:113:46:113:51 | passwd | testCryptoKit.swift:113:46:113:51 | passwd | testCryptoKit.swift:113:46:113:51 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:113:46:113:51 | passwd | password (passwd) | +| testCryptoKit.swift:113:46:113:51 | passwd | testCryptoKit.swift:113:46:113:51 | passwd | testCryptoKit.swift:113:46:113:51 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:113:46:113:51 | passwd | password (passwd) | +| testCryptoKit.swift:113:46:113:51 | passwd | testCryptoKit.swift:113:46:113:51 | passwd | testCryptoKit.swift:113:46:113:51 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:113:46:113:51 | passwd | password (passwd) | +| testCryptoKit.swift:113:46:113:51 | passwd | testCryptoKit.swift:113:46:113:51 | passwd | testCryptoKit.swift:113:46:113:51 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:113:46:113:51 | passwd | password (passwd) | +| testCryptoKit.swift:113:46:113:51 | passwd | testCryptoKit.swift:113:46:113:51 | passwd | testCryptoKit.swift:113:46:113:51 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:113:46:113:51 | passwd | password (passwd) | +| testCryptoKit.swift:119:37:119:42 | passwd | testCryptoKit.swift:119:37:119:42 | passwd | testCryptoKit.swift:119:37:119:42 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:119:37:119:42 | passwd | password (passwd) | +| testCryptoKit.swift:119:37:119:42 | passwd | testCryptoKit.swift:119:37:119:42 | passwd | testCryptoKit.swift:119:37:119:42 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:119:37:119:42 | passwd | password (passwd) | +| testCryptoKit.swift:119:37:119:42 | passwd | testCryptoKit.swift:119:37:119:42 | passwd | testCryptoKit.swift:119:37:119:42 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:119:37:119:42 | passwd | password (passwd) | +| testCryptoKit.swift:119:37:119:42 | passwd | testCryptoKit.swift:119:37:119:42 | passwd | testCryptoKit.swift:119:37:119:42 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:119:37:119:42 | passwd | password (passwd) | +| testCryptoKit.swift:119:37:119:42 | passwd | testCryptoKit.swift:119:37:119:42 | passwd | testCryptoKit.swift:119:37:119:42 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:119:37:119:42 | passwd | password (passwd) | +| testCryptoKit.swift:120:46:120:51 | passwd | testCryptoKit.swift:120:46:120:51 | passwd | testCryptoKit.swift:120:46:120:51 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:120:46:120:51 | passwd | password (passwd) | +| testCryptoKit.swift:120:46:120:51 | passwd | testCryptoKit.swift:120:46:120:51 | passwd | testCryptoKit.swift:120:46:120:51 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:120:46:120:51 | passwd | password (passwd) | +| testCryptoKit.swift:120:46:120:51 | passwd | testCryptoKit.swift:120:46:120:51 | passwd | testCryptoKit.swift:120:46:120:51 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:120:46:120:51 | passwd | password (passwd) | +| testCryptoKit.swift:120:46:120:51 | passwd | testCryptoKit.swift:120:46:120:51 | passwd | testCryptoKit.swift:120:46:120:51 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:120:46:120:51 | passwd | password (passwd) | +| testCryptoKit.swift:120:46:120:51 | passwd | testCryptoKit.swift:120:46:120:51 | passwd | testCryptoKit.swift:120:46:120:51 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:120:46:120:51 | passwd | password (passwd) | +| testCryptoKit.swift:129:23:129:28 | passwd | testCryptoKit.swift:129:23:129:28 | passwd | testCryptoKit.swift:129:23:129:28 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:129:23:129:28 | passwd | password (passwd) | +| testCryptoKit.swift:129:23:129:28 | passwd | testCryptoKit.swift:129:23:129:28 | passwd | testCryptoKit.swift:129:23:129:28 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:129:23:129:28 | passwd | password (passwd) | +| testCryptoKit.swift:129:23:129:28 | passwd | testCryptoKit.swift:129:23:129:28 | passwd | testCryptoKit.swift:129:23:129:28 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:129:23:129:28 | passwd | password (passwd) | +| testCryptoKit.swift:129:23:129:28 | passwd | testCryptoKit.swift:129:23:129:28 | passwd | testCryptoKit.swift:129:23:129:28 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:129:23:129:28 | passwd | password (passwd) | +| testCryptoKit.swift:129:23:129:28 | passwd | testCryptoKit.swift:129:23:129:28 | passwd | testCryptoKit.swift:129:23:129:28 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:129:23:129:28 | passwd | password (passwd) | +| testCryptoKit.swift:138:23:138:28 | passwd | testCryptoKit.swift:138:23:138:28 | passwd | testCryptoKit.swift:138:23:138:28 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:138:23:138:28 | passwd | password (passwd) | +| testCryptoKit.swift:138:23:138:28 | passwd | testCryptoKit.swift:138:23:138:28 | passwd | testCryptoKit.swift:138:23:138:28 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:138:23:138:28 | passwd | password (passwd) | +| testCryptoKit.swift:138:23:138:28 | passwd | testCryptoKit.swift:138:23:138:28 | passwd | testCryptoKit.swift:138:23:138:28 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:138:23:138:28 | passwd | password (passwd) | +| testCryptoKit.swift:138:23:138:28 | passwd | testCryptoKit.swift:138:23:138:28 | passwd | testCryptoKit.swift:138:23:138:28 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:138:23:138:28 | passwd | password (passwd) | +| testCryptoKit.swift:138:23:138:28 | passwd | testCryptoKit.swift:138:23:138:28 | passwd | testCryptoKit.swift:138:23:138:28 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:138:23:138:28 | passwd | password (passwd) | +| testCryptoKit.swift:147:23:147:28 | passwd | testCryptoKit.swift:147:23:147:28 | passwd | testCryptoKit.swift:147:23:147:28 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:147:23:147:28 | passwd | password (passwd) | +| testCryptoKit.swift:147:23:147:28 | passwd | testCryptoKit.swift:147:23:147:28 | passwd | testCryptoKit.swift:147:23:147:28 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:147:23:147:28 | passwd | password (passwd) | +| testCryptoKit.swift:147:23:147:28 | passwd | testCryptoKit.swift:147:23:147:28 | passwd | testCryptoKit.swift:147:23:147:28 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:147:23:147:28 | passwd | password (passwd) | +| testCryptoKit.swift:147:23:147:28 | passwd | testCryptoKit.swift:147:23:147:28 | passwd | testCryptoKit.swift:147:23:147:28 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:147:23:147:28 | passwd | password (passwd) | +| testCryptoKit.swift:147:23:147:28 | passwd | testCryptoKit.swift:147:23:147:28 | passwd | testCryptoKit.swift:147:23:147:28 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:147:23:147:28 | passwd | password (passwd) | +| testCryptoKit.swift:156:23:156:28 | passwd | testCryptoKit.swift:156:23:156:28 | passwd | testCryptoKit.swift:156:23:156:28 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:156:23:156:28 | passwd | password (passwd) | +| testCryptoKit.swift:156:23:156:28 | passwd | testCryptoKit.swift:156:23:156:28 | passwd | testCryptoKit.swift:156:23:156:28 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:156:23:156:28 | passwd | password (passwd) | +| testCryptoKit.swift:156:23:156:28 | passwd | testCryptoKit.swift:156:23:156:28 | passwd | testCryptoKit.swift:156:23:156:28 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:156:23:156:28 | passwd | password (passwd) | +| testCryptoKit.swift:156:23:156:28 | passwd | testCryptoKit.swift:156:23:156:28 | passwd | testCryptoKit.swift:156:23:156:28 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:156:23:156:28 | passwd | password (passwd) | +| testCryptoKit.swift:156:23:156:28 | passwd | testCryptoKit.swift:156:23:156:28 | passwd | testCryptoKit.swift:156:23:156:28 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:156:23:156:28 | passwd | password (passwd) | +| testCryptoKit.swift:165:23:165:28 | passwd | testCryptoKit.swift:165:23:165:28 | passwd | testCryptoKit.swift:165:23:165:28 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:165:23:165:28 | passwd | password (passwd) | +| testCryptoKit.swift:165:23:165:28 | passwd | testCryptoKit.swift:165:23:165:28 | passwd | testCryptoKit.swift:165:23:165:28 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:165:23:165:28 | passwd | password (passwd) | +| testCryptoKit.swift:165:23:165:28 | passwd | testCryptoKit.swift:165:23:165:28 | passwd | testCryptoKit.swift:165:23:165:28 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:165:23:165:28 | passwd | password (passwd) | +| testCryptoKit.swift:165:23:165:28 | passwd | testCryptoKit.swift:165:23:165:28 | passwd | testCryptoKit.swift:165:23:165:28 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:165:23:165:28 | passwd | password (passwd) | +| testCryptoKit.swift:165:23:165:28 | passwd | testCryptoKit.swift:165:23:165:28 | passwd | testCryptoKit.swift:165:23:165:28 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:165:23:165:28 | passwd | password (passwd) | +| testCryptoKit.swift:174:32:174:37 | passwd | testCryptoKit.swift:174:32:174:37 | passwd | testCryptoKit.swift:174:32:174:37 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:174:32:174:37 | passwd | password (passwd) | +| testCryptoKit.swift:174:32:174:37 | passwd | testCryptoKit.swift:174:32:174:37 | passwd | testCryptoKit.swift:174:32:174:37 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:174:32:174:37 | passwd | password (passwd) | +| testCryptoKit.swift:174:32:174:37 | passwd | testCryptoKit.swift:174:32:174:37 | passwd | testCryptoKit.swift:174:32:174:37 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:174:32:174:37 | passwd | password (passwd) | +| testCryptoKit.swift:174:32:174:37 | passwd | testCryptoKit.swift:174:32:174:37 | passwd | testCryptoKit.swift:174:32:174:37 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:174:32:174:37 | passwd | password (passwd) | +| testCryptoKit.swift:174:32:174:37 | passwd | testCryptoKit.swift:174:32:174:37 | passwd | testCryptoKit.swift:174:32:174:37 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:174:32:174:37 | passwd | password (passwd) | +| testCryptoKit.swift:183:32:183:37 | passwd | testCryptoKit.swift:183:32:183:37 | passwd | testCryptoKit.swift:183:32:183:37 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:183:32:183:37 | passwd | password (passwd) | +| testCryptoKit.swift:183:32:183:37 | passwd | testCryptoKit.swift:183:32:183:37 | passwd | testCryptoKit.swift:183:32:183:37 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:183:32:183:37 | passwd | password (passwd) | +| testCryptoKit.swift:183:32:183:37 | passwd | testCryptoKit.swift:183:32:183:37 | passwd | testCryptoKit.swift:183:32:183:37 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:183:32:183:37 | passwd | password (passwd) | +| testCryptoKit.swift:183:32:183:37 | passwd | testCryptoKit.swift:183:32:183:37 | passwd | testCryptoKit.swift:183:32:183:37 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:183:32:183:37 | passwd | password (passwd) | +| testCryptoKit.swift:183:32:183:37 | passwd | testCryptoKit.swift:183:32:183:37 | passwd | testCryptoKit.swift:183:32:183:37 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:183:32:183:37 | passwd | password (passwd) | +| testCryptoKit.swift:192:32:192:37 | passwd | testCryptoKit.swift:192:32:192:37 | passwd | testCryptoKit.swift:192:32:192:37 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:192:32:192:37 | passwd | password (passwd) | +| testCryptoKit.swift:192:32:192:37 | passwd | testCryptoKit.swift:192:32:192:37 | passwd | testCryptoKit.swift:192:32:192:37 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:192:32:192:37 | passwd | password (passwd) | +| testCryptoKit.swift:192:32:192:37 | passwd | testCryptoKit.swift:192:32:192:37 | passwd | testCryptoKit.swift:192:32:192:37 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:192:32:192:37 | passwd | password (passwd) | +| testCryptoKit.swift:192:32:192:37 | passwd | testCryptoKit.swift:192:32:192:37 | passwd | testCryptoKit.swift:192:32:192:37 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:192:32:192:37 | passwd | password (passwd) | +| testCryptoKit.swift:192:32:192:37 | passwd | testCryptoKit.swift:192:32:192:37 | passwd | testCryptoKit.swift:192:32:192:37 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:192:32:192:37 | passwd | password (passwd) | +| testCryptoKit.swift:201:32:201:37 | passwd | testCryptoKit.swift:201:32:201:37 | passwd | testCryptoKit.swift:201:32:201:37 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:201:32:201:37 | passwd | password (passwd) | +| testCryptoKit.swift:201:32:201:37 | passwd | testCryptoKit.swift:201:32:201:37 | passwd | testCryptoKit.swift:201:32:201:37 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:201:32:201:37 | passwd | password (passwd) | +| testCryptoKit.swift:201:32:201:37 | passwd | testCryptoKit.swift:201:32:201:37 | passwd | testCryptoKit.swift:201:32:201:37 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:201:32:201:37 | passwd | password (passwd) | +| testCryptoKit.swift:201:32:201:37 | passwd | testCryptoKit.swift:201:32:201:37 | passwd | testCryptoKit.swift:201:32:201:37 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:201:32:201:37 | passwd | password (passwd) | +| testCryptoKit.swift:201:32:201:37 | passwd | testCryptoKit.swift:201:32:201:37 | passwd | testCryptoKit.swift:201:32:201:37 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:201:32:201:37 | passwd | password (passwd) | +| testCryptoKit.swift:210:32:210:37 | passwd | testCryptoKit.swift:210:32:210:37 | passwd | testCryptoKit.swift:210:32:210:37 | passwd | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:210:32:210:37 | passwd | password (passwd) | +| testCryptoKit.swift:210:32:210:37 | passwd | testCryptoKit.swift:210:32:210:37 | passwd | testCryptoKit.swift:210:32:210:37 | passwd | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:210:32:210:37 | passwd | password (passwd) | +| testCryptoKit.swift:210:32:210:37 | passwd | testCryptoKit.swift:210:32:210:37 | passwd | testCryptoKit.swift:210:32:210:37 | passwd | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:210:32:210:37 | passwd | password (passwd) | +| testCryptoKit.swift:210:32:210:37 | passwd | testCryptoKit.swift:210:32:210:37 | passwd | testCryptoKit.swift:210:32:210:37 | passwd | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:210:32:210:37 | passwd | password (passwd) | +| testCryptoKit.swift:210:32:210:37 | passwd | testCryptoKit.swift:210:32:210:37 | passwd | testCryptoKit.swift:210:32:210:37 | passwd | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:210:32:210:37 | passwd | password (passwd) | +| testCryptoKit.swift:220:49:220:60 | passwordData | testCryptoKit.swift:220:49:220:60 | passwordData | testCryptoKit.swift:220:49:220:60 | passwordData | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:220:49:220:60 | passwordData | password (passwordData) | +| testCryptoKit.swift:220:49:220:60 | passwordData | testCryptoKit.swift:220:49:220:60 | passwordData | testCryptoKit.swift:220:49:220:60 | passwordData | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:220:49:220:60 | passwordData | password (passwordData) | +| testCryptoKit.swift:220:49:220:60 | passwordData | testCryptoKit.swift:220:49:220:60 | passwordData | testCryptoKit.swift:220:49:220:60 | passwordData | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:220:49:220:60 | passwordData | password (passwordData) | +| testCryptoKit.swift:220:49:220:60 | passwordData | testCryptoKit.swift:220:49:220:60 | passwordData | testCryptoKit.swift:220:49:220:60 | passwordData | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:220:49:220:60 | passwordData | password (passwordData) | +| testCryptoKit.swift:220:49:220:60 | passwordData | testCryptoKit.swift:220:49:220:60 | passwordData | testCryptoKit.swift:220:49:220:60 | passwordData | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:220:49:220:60 | passwordData | password (passwordData) | +| testCryptoKit.swift:224:33:224:57 | Data(...) | testCryptoKit.swift:224:38:224:51 | passwordString | testCryptoKit.swift:224:33:224:57 | Data(...) | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:224:38:224:51 | passwordString | password (passwordString) | +| testCryptoKit.swift:224:33:224:57 | Data(...) | testCryptoKit.swift:224:38:224:51 | passwordString | testCryptoKit.swift:224:33:224:57 | Data(...) | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:224:38:224:51 | passwordString | password (passwordString) | +| testCryptoKit.swift:224:33:224:57 | Data(...) | testCryptoKit.swift:224:38:224:51 | passwordString | testCryptoKit.swift:224:33:224:57 | Data(...) | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:224:38:224:51 | passwordString | password (passwordString) | +| testCryptoKit.swift:224:33:224:57 | Data(...) | testCryptoKit.swift:224:38:224:51 | passwordString | testCryptoKit.swift:224:33:224:57 | Data(...) | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:224:38:224:51 | passwordString | password (passwordString) | +| testCryptoKit.swift:224:33:224:57 | Data(...) | testCryptoKit.swift:224:38:224:51 | passwordString | testCryptoKit.swift:224:33:224:57 | Data(...) | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:224:38:224:51 | passwordString | password (passwordString) | +| testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:154:30:154:40 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:154:30:154:40 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:154:30:154:40 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:157:31:157:41 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:157:31:157:41 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:157:31:157:41 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:160:47:160:57 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:160:47:160:57 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:160:47:160:57 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:163:47:163:57 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:163:47:163:57 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:163:47:163:57 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:167:20:167:30 | passwdArray | testCryptoSwift.swift:167:20:167:30 | passwdArray | testCryptoSwift.swift:167:20:167:30 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:167:20:167:30 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:170:21:170:31 | passwdArray | testCryptoSwift.swift:170:21:170:31 | passwdArray | testCryptoSwift.swift:170:21:170:31 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:170:21:170:31 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:173:23:173:33 | passwdArray | testCryptoSwift.swift:173:23:173:33 | passwdArray | testCryptoSwift.swift:173:23:173:33 | passwdArray | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:173:23:173:33 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:176:21:176:31 | passwdArray | testCryptoSwift.swift:176:21:176:31 | passwdArray | testCryptoSwift.swift:176:21:176:31 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:176:21:176:31 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:179:21:179:31 | passwdArray | testCryptoSwift.swift:179:21:179:31 | passwdArray | testCryptoSwift.swift:179:21:179:31 | passwdArray | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:179:21:179:31 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:183:9:183:25 | [self arg] ... .md5(...) | testCryptoSwift.swift:183:9:183:19 | passwdArray | testCryptoSwift.swift:183:9:183:25 | [self arg] ... .md5(...) | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:183:9:183:19 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:186:9:186:26 | [self arg] ... .sha1(...) | testCryptoSwift.swift:186:9:186:19 | passwdArray | testCryptoSwift.swift:186:9:186:26 | [self arg] ... .sha1(...) | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:186:9:186:19 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:189:9:189:28 | [self arg] ... .sha512(...) | testCryptoSwift.swift:189:9:189:19 | passwdArray | testCryptoSwift.swift:189:9:189:28 | [self arg] ... .sha512(...) | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:189:9:189:19 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:192:9:192:33 | [self arg] ... .sha2(...) | testCryptoSwift.swift:192:9:192:19 | passwdArray | testCryptoSwift.swift:192:9:192:33 | [self arg] ... .sha2(...) | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:192:9:192:19 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:195:9:195:33 | [self arg] ... .sha3(...) | testCryptoSwift.swift:195:9:195:19 | passwdArray | testCryptoSwift.swift:195:9:195:33 | [self arg] ... .sha3(...) | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:195:9:195:19 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:201:9:201:24 | [self arg] ... .md5(...) | testCryptoSwift.swift:201:9:201:18 | passwdData | testCryptoSwift.swift:201:9:201:24 | [self arg] ... .md5(...) | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:201:9:201:18 | passwdData | password (passwdData) | +| testCryptoSwift.swift:204:9:204:25 | [self arg] ... .sha1(...) | testCryptoSwift.swift:204:9:204:18 | passwdData | testCryptoSwift.swift:204:9:204:25 | [self arg] ... .sha1(...) | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:204:9:204:18 | passwdData | password (passwdData) | +| testCryptoSwift.swift:207:9:207:27 | [self arg] ... .sha512(...) | testCryptoSwift.swift:207:9:207:18 | passwdData | testCryptoSwift.swift:207:9:207:27 | [self arg] ... .sha512(...) | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:207:9:207:18 | passwdData | password (passwdData) | +| testCryptoSwift.swift:210:9:210:32 | [self arg] ... .sha2(...) | testCryptoSwift.swift:210:9:210:18 | passwdData | testCryptoSwift.swift:210:9:210:32 | [self arg] ... .sha2(...) | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:210:9:210:18 | passwdData | password (passwdData) | +| testCryptoSwift.swift:213:9:213:32 | [self arg] ... .sha3(...) | testCryptoSwift.swift:213:9:213:18 | passwdData | testCryptoSwift.swift:213:9:213:32 | [self arg] ... .sha3(...) | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:213:9:213:18 | passwdData | password (passwdData) | +| testCryptoSwift.swift:219:9:219:20 | [self arg] ... .md5(...) | testCryptoSwift.swift:219:9:219:14 | passwd | testCryptoSwift.swift:219:9:219:20 | [self arg] ... .md5(...) | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:219:9:219:14 | passwd | password (passwd) | +| testCryptoSwift.swift:222:9:222:21 | [self arg] ... .sha1(...) | testCryptoSwift.swift:222:9:222:14 | passwd | testCryptoSwift.swift:222:9:222:21 | [self arg] ... .sha1(...) | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:222:9:222:14 | passwd | password (passwd) | +| testCryptoSwift.swift:225:9:225:23 | [self arg] ... .sha512(...) | testCryptoSwift.swift:225:9:225:14 | passwd | testCryptoSwift.swift:225:9:225:23 | [self arg] ... .sha512(...) | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:225:9:225:14 | passwd | password (passwd) | +| testCryptoSwift.swift:228:9:228:28 | [self arg] ... .sha2(...) | testCryptoSwift.swift:228:9:228:14 | passwd | testCryptoSwift.swift:228:9:228:28 | [self arg] ... .sha2(...) | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:228:9:228:14 | passwd | password (passwd) | +| testCryptoSwift.swift:231:9:231:28 | [self arg] ... .sha3(...) | testCryptoSwift.swift:231:9:231:14 | passwd | testCryptoSwift.swift:231:9:231:28 | [self arg] ... .sha3(...) | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:231:9:231:14 | passwd | password (passwd) | edges -| testCryptoKit.swift:224:38:224:38 | passwordString | testCryptoKit.swift:224:38:224:53 | .utf8 | provenance | | -| testCryptoKit.swift:224:38:224:53 | .utf8 | testCryptoKit.swift:224:33:224:57 | call to Data.init(_:) | provenance | | +| testCryptoKit.swift:224:38:224:51 | passwordString | testCryptoKit.swift:224:38:224:56 | ... .utf8 | provenance | | +| testCryptoKit.swift:224:38:224:56 | ... .utf8 | testCryptoKit.swift:224:33:224:57 | Data(...) | provenance | | +| testCryptoSwift.swift:183:9:183:19 | passwdArray | testCryptoSwift.swift:183:9:183:25 | [self arg] ... .md5(...) | provenance | | +| testCryptoSwift.swift:186:9:186:19 | passwdArray | testCryptoSwift.swift:186:9:186:26 | [self arg] ... .sha1(...) | provenance | | +| testCryptoSwift.swift:189:9:189:19 | passwdArray | testCryptoSwift.swift:189:9:189:28 | [self arg] ... .sha512(...) | provenance | | +| testCryptoSwift.swift:192:9:192:19 | passwdArray | testCryptoSwift.swift:192:9:192:33 | [self arg] ... .sha2(...) | provenance | | +| testCryptoSwift.swift:195:9:195:19 | passwdArray | testCryptoSwift.swift:195:9:195:33 | [self arg] ... .sha3(...) | provenance | | +| testCryptoSwift.swift:201:9:201:18 | passwdData | testCryptoSwift.swift:201:9:201:24 | [self arg] ... .md5(...) | provenance | | +| testCryptoSwift.swift:204:9:204:18 | passwdData | testCryptoSwift.swift:204:9:204:25 | [self arg] ... .sha1(...) | provenance | | +| testCryptoSwift.swift:207:9:207:18 | passwdData | testCryptoSwift.swift:207:9:207:27 | [self arg] ... .sha512(...) | provenance | | +| testCryptoSwift.swift:210:9:210:18 | passwdData | testCryptoSwift.swift:210:9:210:32 | [self arg] ... .sha2(...) | provenance | | +| testCryptoSwift.swift:213:9:213:18 | passwdData | testCryptoSwift.swift:213:9:213:32 | [self arg] ... .sha3(...) | provenance | | +| testCryptoSwift.swift:219:9:219:14 | passwd | testCryptoSwift.swift:219:9:219:20 | [self arg] ... .md5(...) | provenance | | +| testCryptoSwift.swift:222:9:222:14 | passwd | testCryptoSwift.swift:222:9:222:21 | [self arg] ... .sha1(...) | provenance | | +| testCryptoSwift.swift:225:9:225:14 | passwd | testCryptoSwift.swift:225:9:225:23 | [self arg] ... .sha512(...) | provenance | | +| testCryptoSwift.swift:228:9:228:14 | passwd | testCryptoSwift.swift:228:9:228:28 | [self arg] ... .sha2(...) | provenance | | +| testCryptoSwift.swift:231:9:231:14 | passwd | testCryptoSwift.swift:231:9:231:28 | [self arg] ... .sha3(...) | provenance | | nodes -| testCryptoKit.swift:84:47:84:47 | passwd | semmle.label | passwd | -| testCryptoKit.swift:85:52:85:52 | passwd | semmle.label | passwd | -| testCryptoKit.swift:91:36:91:36 | passwd | semmle.label | passwd | -| testCryptoKit.swift:92:45:92:45 | passwd | semmle.label | passwd | -| testCryptoKit.swift:98:44:98:44 | passwd | semmle.label | passwd | -| testCryptoKit.swift:99:53:99:53 | passwd | semmle.label | passwd | -| testCryptoKit.swift:105:37:105:37 | passwd | semmle.label | passwd | -| testCryptoKit.swift:106:46:106:46 | passwd | semmle.label | passwd | -| testCryptoKit.swift:112:37:112:37 | passwd | semmle.label | passwd | -| testCryptoKit.swift:113:46:113:46 | passwd | semmle.label | passwd | -| testCryptoKit.swift:119:37:119:37 | passwd | semmle.label | passwd | -| testCryptoKit.swift:120:46:120:46 | passwd | semmle.label | passwd | -| testCryptoKit.swift:129:23:129:23 | passwd | semmle.label | passwd | -| testCryptoKit.swift:138:23:138:23 | passwd | semmle.label | passwd | -| testCryptoKit.swift:147:23:147:23 | passwd | semmle.label | passwd | -| testCryptoKit.swift:156:23:156:23 | passwd | semmle.label | passwd | -| testCryptoKit.swift:165:23:165:23 | passwd | semmle.label | passwd | -| testCryptoKit.swift:174:32:174:32 | passwd | semmle.label | passwd | -| testCryptoKit.swift:183:32:183:32 | passwd | semmle.label | passwd | -| testCryptoKit.swift:192:32:192:32 | passwd | semmle.label | passwd | -| testCryptoKit.swift:201:32:201:32 | passwd | semmle.label | passwd | -| testCryptoKit.swift:210:32:210:32 | passwd | semmle.label | passwd | -| testCryptoKit.swift:220:49:220:49 | passwordData | semmle.label | passwordData | -| testCryptoKit.swift:224:33:224:57 | call to Data.init(_:) | semmle.label | call to Data.init(_:) | -| testCryptoKit.swift:224:38:224:38 | passwordString | semmle.label | passwordString | -| testCryptoKit.swift:224:38:224:53 | .utf8 | semmle.label | .utf8 | -| testCryptoSwift.swift:154:30:154:30 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:157:31:157:31 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:160:47:160:47 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:163:47:163:47 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:167:20:167:20 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:170:21:170:21 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:173:23:173:23 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:176:21:176:21 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:179:21:179:21 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:183:9:183:9 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:186:9:186:9 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:189:9:189:9 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:192:9:192:9 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:195:9:195:9 | passwdArray | semmle.label | passwdArray | -| testCryptoSwift.swift:201:9:201:9 | passwdData | semmle.label | passwdData | -| testCryptoSwift.swift:204:9:204:9 | passwdData | semmle.label | passwdData | -| testCryptoSwift.swift:207:9:207:9 | passwdData | semmle.label | passwdData | -| testCryptoSwift.swift:210:9:210:9 | passwdData | semmle.label | passwdData | -| testCryptoSwift.swift:213:9:213:9 | passwdData | semmle.label | passwdData | -| testCryptoSwift.swift:219:9:219:9 | passwd | semmle.label | passwd | -| testCryptoSwift.swift:222:9:222:9 | passwd | semmle.label | passwd | -| testCryptoSwift.swift:225:9:225:9 | passwd | semmle.label | passwd | -| testCryptoSwift.swift:228:9:228:9 | passwd | semmle.label | passwd | -| testCryptoSwift.swift:231:9:231:9 | passwd | semmle.label | passwd | +| testCryptoKit.swift:84:47:84:52 | passwd | semmle.label | passwd | +| testCryptoKit.swift:85:52:85:57 | passwd | semmle.label | passwd | +| testCryptoKit.swift:91:36:91:41 | passwd | semmle.label | passwd | +| testCryptoKit.swift:92:45:92:50 | passwd | semmle.label | passwd | +| testCryptoKit.swift:98:44:98:49 | passwd | semmle.label | passwd | +| testCryptoKit.swift:99:53:99:58 | passwd | semmle.label | passwd | +| testCryptoKit.swift:105:37:105:42 | passwd | semmle.label | passwd | +| testCryptoKit.swift:106:46:106:51 | passwd | semmle.label | passwd | +| testCryptoKit.swift:112:37:112:42 | passwd | semmle.label | passwd | +| testCryptoKit.swift:113:46:113:51 | passwd | semmle.label | passwd | +| testCryptoKit.swift:119:37:119:42 | passwd | semmle.label | passwd | +| testCryptoKit.swift:120:46:120:51 | passwd | semmle.label | passwd | +| testCryptoKit.swift:129:23:129:28 | passwd | semmle.label | passwd | +| testCryptoKit.swift:138:23:138:28 | passwd | semmle.label | passwd | +| testCryptoKit.swift:147:23:147:28 | passwd | semmle.label | passwd | +| testCryptoKit.swift:156:23:156:28 | passwd | semmle.label | passwd | +| testCryptoKit.swift:165:23:165:28 | passwd | semmle.label | passwd | +| testCryptoKit.swift:174:32:174:37 | passwd | semmle.label | passwd | +| testCryptoKit.swift:183:32:183:37 | passwd | semmle.label | passwd | +| testCryptoKit.swift:192:32:192:37 | passwd | semmle.label | passwd | +| testCryptoKit.swift:201:32:201:37 | passwd | semmle.label | passwd | +| testCryptoKit.swift:210:32:210:37 | passwd | semmle.label | passwd | +| testCryptoKit.swift:220:49:220:60 | passwordData | semmle.label | passwordData | +| testCryptoKit.swift:224:33:224:57 | Data(...) | semmle.label | Data(...) | +| testCryptoKit.swift:224:38:224:51 | passwordString | semmle.label | passwordString | +| testCryptoKit.swift:224:38:224:56 | ... .utf8 | semmle.label | ... .utf8 | +| testCryptoSwift.swift:154:30:154:40 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:157:31:157:41 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:160:47:160:57 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:163:47:163:57 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:167:20:167:30 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:170:21:170:31 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:173:23:173:33 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:176:21:176:31 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:179:21:179:31 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:183:9:183:19 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:183:9:183:25 | [self arg] ... .md5(...) | semmle.label | [self arg] ... .md5(...) | +| testCryptoSwift.swift:186:9:186:19 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:186:9:186:26 | [self arg] ... .sha1(...) | semmle.label | [self arg] ... .sha1(...) | +| testCryptoSwift.swift:189:9:189:19 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:189:9:189:28 | [self arg] ... .sha512(...) | semmle.label | [self arg] ... .sha512(...) | +| testCryptoSwift.swift:192:9:192:19 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:192:9:192:33 | [self arg] ... .sha2(...) | semmle.label | [self arg] ... .sha2(...) | +| testCryptoSwift.swift:195:9:195:19 | passwdArray | semmle.label | passwdArray | +| testCryptoSwift.swift:195:9:195:33 | [self arg] ... .sha3(...) | semmle.label | [self arg] ... .sha3(...) | +| testCryptoSwift.swift:201:9:201:18 | passwdData | semmle.label | passwdData | +| testCryptoSwift.swift:201:9:201:24 | [self arg] ... .md5(...) | semmle.label | [self arg] ... .md5(...) | +| testCryptoSwift.swift:204:9:204:18 | passwdData | semmle.label | passwdData | +| testCryptoSwift.swift:204:9:204:25 | [self arg] ... .sha1(...) | semmle.label | [self arg] ... .sha1(...) | +| testCryptoSwift.swift:207:9:207:18 | passwdData | semmle.label | passwdData | +| testCryptoSwift.swift:207:9:207:27 | [self arg] ... .sha512(...) | semmle.label | [self arg] ... .sha512(...) | +| testCryptoSwift.swift:210:9:210:18 | passwdData | semmle.label | passwdData | +| testCryptoSwift.swift:210:9:210:32 | [self arg] ... .sha2(...) | semmle.label | [self arg] ... .sha2(...) | +| testCryptoSwift.swift:213:9:213:18 | passwdData | semmle.label | passwdData | +| testCryptoSwift.swift:213:9:213:32 | [self arg] ... .sha3(...) | semmle.label | [self arg] ... .sha3(...) | +| testCryptoSwift.swift:219:9:219:14 | passwd | semmle.label | passwd | +| testCryptoSwift.swift:219:9:219:20 | [self arg] ... .md5(...) | semmle.label | [self arg] ... .md5(...) | +| testCryptoSwift.swift:222:9:222:14 | passwd | semmle.label | passwd | +| testCryptoSwift.swift:222:9:222:21 | [self arg] ... .sha1(...) | semmle.label | [self arg] ... .sha1(...) | +| testCryptoSwift.swift:225:9:225:14 | passwd | semmle.label | passwd | +| testCryptoSwift.swift:225:9:225:23 | [self arg] ... .sha512(...) | semmle.label | [self arg] ... .sha512(...) | +| testCryptoSwift.swift:228:9:228:14 | passwd | semmle.label | passwd | +| testCryptoSwift.swift:228:9:228:28 | [self arg] ... .sha2(...) | semmle.label | [self arg] ... .sha2(...) | +| testCryptoSwift.swift:231:9:231:14 | passwd | semmle.label | passwd | +| testCryptoSwift.swift:231:9:231:28 | [self arg] ... .sha3(...) | semmle.label | [self arg] ... .sha3(...) | subpaths diff --git a/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.qlref b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.qlref index 24744b4a4250..8648f309dcfb 100644 --- a/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.qlref +++ b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.qlref @@ -1,2 +1,3 @@ -query: queries/Security/CWE-328/WeakPasswordHashing.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +query: queries/security/CWE-328/WeakPasswordHashing.ql +postprocess: + - utils/test/InlineExpectationsTestQuery.ql diff --git a/unified/ql/test/query-tests/security/CWE-328/testArgon2Swift.swift b/unified/ql/test/query-tests/security/CWE-328/testArgon2Swift.swift index e88fb5eb2c73..c0a02ef8b4e1 100644 --- a/unified/ql/test/query-tests/security/CWE-328/testArgon2Swift.swift +++ b/unified/ql/test/query-tests/security/CWE-328/testArgon2Swift.swift @@ -36,7 +36,7 @@ class Argon2Swift { // --- tests --- func testGoodExample(passwordString: String) { - // this is the "good" example from the .qhelp + // this is the "good" example from the `.qhelp` let salt = Salt.newSalt() let result = try! Argon2Swift.hashPasswordString(password: passwordString, salt: salt) // GOOD (suitable password hash) let passwordHash = result.encodedString() diff --git a/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift b/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift index d2faf8812248..6c9410276e35 100644 --- a/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift +++ b/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift @@ -81,166 +81,166 @@ enum Insecure { // --- tests --- func testHashMethods(passwd : UnsafeRawBufferPointer, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { - var hash = Crypto.Insecure.MD5.hash(data: passwd) // $ Alert[swift/weak-password-hashing] - hash = Crypto.Insecure.MD5.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] - hash = Crypto.Insecure.MD5.hash(data: cert) // $ Alert[swift/weak-sensitive-data-hashing] - hash = Crypto.Insecure.MD5.hash(data: encrypted_passwd) // GOOD (not sensitive) - hash = Crypto.Insecure.MD5.hash(data: account_no) // $ Alert[swift/weak-sensitive-data-hashing] - hash = Crypto.Insecure.MD5.hash(data: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] - - hash = Insecure.MD5.hash(data: passwd) // $ Alert[swift/weak-password-hashing] - hash = Insecure.MD5.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] - hash = Insecure.MD5.hash(data: cert) // $ Alert[swift/weak-sensitive-data-hashing] - hash = Insecure.MD5.hash(data: encrypted_passwd) // GOOD (not sensitive) - hash = Insecure.MD5.hash(data: account_no) // $ Alert[swift/weak-sensitive-data-hashing] - hash = Insecure.MD5.hash(data: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] - - hash = Crypto.Insecure.SHA1.hash(data: passwd) // $ Alert[swift/weak-password-hashing] - hash = Crypto.Insecure.SHA1.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] - hash = Crypto.Insecure.SHA1.hash(data: cert) // $ Alert[swift/weak-sensitive-data-hashing] - hash = Crypto.Insecure.SHA1.hash(data: encrypted_passwd) // GOOD (not sensitive) - hash = Crypto.Insecure.SHA1.hash(data: account_no) // $ Alert[swift/weak-sensitive-data-hashing] - hash = Crypto.Insecure.SHA1.hash(data: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] - - hash = Crypto.SHA256.hash(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash = Crypto.SHA256.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash = Crypto.SHA256.hash(data: cert) // GOOD, computationally expensive hash not required - hash = Crypto.SHA256.hash(data: encrypted_passwd) // GOOD, not sensitive - hash = Crypto.SHA256.hash(data: account_no) // GOOD, computationally expensive hash not required - hash = Crypto.SHA256.hash(data: credit_card_no) // GOOD, computationally expensive hash not required - - hash = Crypto.SHA384.hash(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash = Crypto.SHA384.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash = Crypto.SHA384.hash(data: cert) // GOOD, computationally expensive hash not required - hash = Crypto.SHA384.hash(data: encrypted_passwd) // GOOD, not sensitive - hash = Crypto.SHA384.hash(data: account_no) // GOOD, computationally expensive hash not required - hash = Crypto.SHA384.hash(data: credit_card_no) // GOOD, computationally expensive hash not required - - hash = Crypto.SHA512.hash(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash = Crypto.SHA512.hash(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash = Crypto.SHA512.hash(data: cert) // GOOD, computationally expensive hash not required - hash = Crypto.SHA512.hash(data: encrypted_passwd) // GOOD, not sensitive - hash = Crypto.SHA512.hash(data: account_no) // GOOD, computationally expensive hash not required - hash = Crypto.SHA512.hash(data: credit_card_no) // GOOD, computationally expensive hash not required + var hash = Crypto.Insecure.MD5.hash(data: passwd) // $ Alert[unified/swift/weak-password-hashing] + hash = Crypto.Insecure.MD5.hash(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] + hash = Crypto.Insecure.MD5.hash(data: cert) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash = Crypto.Insecure.MD5.hash(data: encrypted_passwd) // GOOD (not sensitive) + hash = Crypto.Insecure.MD5.hash(data: account_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash = Crypto.Insecure.MD5.hash(data: credit_card_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + + hash = Insecure.MD5.hash(data: passwd) // $ Alert[unified/swift/weak-password-hashing] + hash = Insecure.MD5.hash(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] + hash = Insecure.MD5.hash(data: cert) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash = Insecure.MD5.hash(data: encrypted_passwd) // GOOD (not sensitive) + hash = Insecure.MD5.hash(data: account_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash = Insecure.MD5.hash(data: credit_card_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + + hash = Crypto.Insecure.SHA1.hash(data: passwd) // $ Alert[unified/swift/weak-password-hashing] + hash = Crypto.Insecure.SHA1.hash(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] + hash = Crypto.Insecure.SHA1.hash(data: cert) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash = Crypto.Insecure.SHA1.hash(data: encrypted_passwd) // GOOD (not sensitive) + hash = Crypto.Insecure.SHA1.hash(data: account_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash = Crypto.Insecure.SHA1.hash(data: credit_card_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + + hash = Crypto.SHA256.hash(data: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash = Crypto.SHA256.hash(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash = Crypto.SHA256.hash(data: cert) // GOOD, computationally expensive hash not required + hash = Crypto.SHA256.hash(data: encrypted_passwd) // GOOD, not sensitive + hash = Crypto.SHA256.hash(data: account_no) // GOOD, computationally expensive hash not required + hash = Crypto.SHA256.hash(data: credit_card_no) // GOOD, computationally expensive hash not required + + hash = Crypto.SHA384.hash(data: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash = Crypto.SHA384.hash(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash = Crypto.SHA384.hash(data: cert) // GOOD, computationally expensive hash not required + hash = Crypto.SHA384.hash(data: encrypted_passwd) // GOOD, not sensitive + hash = Crypto.SHA384.hash(data: account_no) // GOOD, computationally expensive hash not required + hash = Crypto.SHA384.hash(data: credit_card_no) // GOOD, computationally expensive hash not required + + hash = Crypto.SHA512.hash(data: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash = Crypto.SHA512.hash(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash = Crypto.SHA512.hash(data: cert) // GOOD, computationally expensive hash not required + hash = Crypto.SHA512.hash(data: encrypted_passwd) // GOOD, not sensitive + hash = Crypto.SHA512.hash(data: account_no) // GOOD, computationally expensive hash not required + hash = Crypto.SHA512.hash(data: credit_card_no) // GOOD, computationally expensive hash not required } func testMD5UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { var hash = Crypto.Insecure.MD5() - hash.update(data: passwd) // $ Alert[swift/weak-password-hashing] - hash.update(data: cert) // $ Alert[swift/weak-sensitive-data-hashing] - hash.update(data: encrypted_passwd) // GOOD (not sensitive) - hash.update(data: account_no) // $ Alert[swift/weak-sensitive-data-hashing] - hash.update(data: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(data: passwd) // $ Alert[unified/swift/weak-password-hashing] + hash.update(data: cert) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash.update(data: encrypted_passwd) // GOOD (not sensitive) + hash.update(data: account_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash.update(data: credit_card_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] } func testSHA1UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { var hash = Crypto.Insecure.SHA1() - hash.update(data: passwd) // $ Alert[swift/weak-password-hashing] - hash.update(data: cert) // $ Alert[swift/weak-sensitive-data-hashing] - hash.update(data: encrypted_passwd) // GOOD (not sensitive) - hash.update(data: account_no) // $ Alert[swift/weak-sensitive-data-hashing] - hash.update(data: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(data: passwd) // $ Alert[unified/swift/weak-password-hashing] + hash.update(data: cert) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash.update(data: encrypted_passwd) // GOOD (not sensitive) + hash.update(data: account_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash.update(data: credit_card_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] } func testSHA256UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { var hash = Crypto.SHA256() - hash.update(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash.update(data: cert) // GOOD - hash.update(data: encrypted_passwd) // GOOD (not sensitive) - hash.update(data: account_no) // GOOD - hash.update(data: credit_card_no) // GOOD + hash.update(data: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash.update(data: cert) // GOOD + hash.update(data: encrypted_passwd) // GOOD (not sensitive) + hash.update(data: account_no) // GOOD + hash.update(data: credit_card_no) // GOOD } func testSHA384UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { var hash = Crypto.SHA384() - hash.update(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash.update(data: cert) // GOOD - hash.update(data: encrypted_passwd) // GOOD (not sensitive) - hash.update(data: account_no) // GOOD - hash.update(data: credit_card_no) // GOOD + hash.update(data: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash.update(data: cert) // GOOD + hash.update(data: encrypted_passwd) // GOOD (not sensitive) + hash.update(data: account_no) // GOOD + hash.update(data: credit_card_no) // GOOD } func testSHA512UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) { var hash = Crypto.SHA512() - hash.update(data: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash.update(data: cert) // GOOD - hash.update(data: encrypted_passwd) // GOOD (not sensitive) - hash.update(data: account_no) // GOOD - hash.update(data: credit_card_no) // GOOD + hash.update(data: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash.update(data: cert) // GOOD + hash.update(data: encrypted_passwd) // GOOD (not sensitive) + hash.update(data: account_no) // GOOD + hash.update(data: credit_card_no) // GOOD } func testMD5UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) { var hash = Crypto.Insecure.MD5() - hash.update(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] - hash.update(bufferPointer: cert) // $ Alert[swift/weak-sensitive-data-hashing] - hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) - hash.update(bufferPointer: account_no) // $ Alert[swift/weak-sensitive-data-hashing] - hash.update(bufferPointer: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] + hash.update(bufferPointer: cert) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) + hash.update(bufferPointer: account_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash.update(bufferPointer: credit_card_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] } func testSHA1UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) { var hash = Crypto.Insecure.SHA1() - hash.update(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] - hash.update(bufferPointer: cert) // $ Alert[swift/weak-sensitive-data-hashing] - hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) - hash.update(bufferPointer: account_no) // $ Alert[swift/weak-sensitive-data-hashing] - hash.update(bufferPointer: credit_card_no) // $ Alert[swift/weak-sensitive-data-hashing] + hash.update(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] + hash.update(bufferPointer: cert) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) + hash.update(bufferPointer: account_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + hash.update(bufferPointer: credit_card_no) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] } func testSHA256UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) { var hash = Crypto.SHA256() - hash.update(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash.update(bufferPointer: cert) // GOOD - hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) - hash.update(bufferPointer: account_no) // GOOD - hash.update(bufferPointer: credit_card_no) // GOOD + hash.update(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash.update(bufferPointer: cert) // GOOD + hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) + hash.update(bufferPointer: account_no) // GOOD + hash.update(bufferPointer: credit_card_no) // GOOD } func testSHA384UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) { var hash = Crypto.SHA384() - hash.update(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash.update(bufferPointer: cert) // GOOD - hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) - hash.update(bufferPointer: account_no) // GOOD - hash.update(bufferPointer: credit_card_no) // GOOD + hash.update(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash.update(bufferPointer: cert) // GOOD + hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) + hash.update(bufferPointer: account_no) // GOOD + hash.update(bufferPointer: credit_card_no) // GOOD } func testSHA512UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) { var hash = Crypto.SHA512() - hash.update(bufferPointer: passwd) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash - hash.update(bufferPointer: cert) // GOOD - hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) - hash.update(bufferPointer: account_no) // GOOD - hash.update(bufferPointer: credit_card_no) // GOOD + hash.update(bufferPointer: passwd) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) + hash.update(bufferPointer: cert) // GOOD + hash.update(bufferPointer: encrypted_passwd) // GOOD (not sensitive) + hash.update(bufferPointer: account_no) // GOOD + hash.update(bufferPointer: credit_card_no) // GOOD } func testBadExample(passwordString: String) { - // this is the "bad" example from the .qhelp + // this is the "bad" example from the `.qhelp` let passwordData = Data(passwordString.utf8) - let passwordHash = Crypto.SHA512.hash(data: passwordData) // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + let passwordHash = Crypto.SHA512.hash(data: passwordData) // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) // ... - if Crypto.SHA512.hash(data: Data(passwordString.utf8)) == passwordHash { // $ Alert[swift/weak-password-hashing] // BAD, not a computationally expensive hash + if Crypto.SHA512.hash(data: Data(passwordString.utf8)) == passwordHash { // $ Alert[unified/swift/weak-password-hashing] (not a computationally expensive hash) // ... } } func testWithFlowAndMetatypes(cardNumber: String) { - let value1 = Data(cardNumber.utf8); // $ Source[swift/weak-sensitive-data-hashing] - let _digest1 = Insecure.MD5.hash(data: value1); // $ Alert[swift/weak-sensitive-data-hashing] + let value1 = Data(cardNumber.utf8); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + let _digest1 = Insecure.MD5.hash(data: value1); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] - let value2 = Data(cardNumber.utf8); // $ Source[swift/weak-sensitive-data-hashing] + let value2 = Data(cardNumber.utf8); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] let hasher2 = Insecure.MD5.self; // metatype - let _digest2 = hasher2.hash(data: value2); // $ Alert[swift/weak-sensitive-data-hashing] + let _digest2 = hasher2.hash(data: value2); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] - let value3 = Data(cardNumber.utf8); // $ Source[swift/weak-sensitive-data-hashing] - let _digest3 = (Insecure.MD5.self).hash(data: value3); // $ Alert[swift/weak-sensitive-data-hashing] + let value3 = Data(cardNumber.utf8); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + let _digest3 = (Insecure.MD5.self).hash(data: value3); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] - let value4 = Data(cardNumber.utf8); // $ Source[swift/weak-sensitive-data-hashing] + let value4 = Data(cardNumber.utf8); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] testReceiver1(value: value4); - let value5 = Data(cardNumber.utf8); // $ Source[swift/weak-sensitive-data-hashing] + let value5 = Data(cardNumber.utf8); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] testReceiver2(hasher: Insecure.MD5.self, value: value5); let value6 = Data(cardNumber.utf8); @@ -248,13 +248,13 @@ func testWithFlowAndMetatypes(cardNumber: String) { } func testReceiver1(value: Data) { - let _digest = Insecure.MD5.hash(data: value); // $ Alert[swift/weak-sensitive-data-hashing] + let _digest = Insecure.MD5.hash(data: value); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] } func testReceiver2(hasher: Insecure.MD5.Type, value: Data) { - let _digest = hasher.hash(data: value); // $ Alert[swift/weak-sensitive-data-hashing] + let _digest = hasher.hash(data: value); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] } func testReceiver3(hasher: H.Type, value: Data) { - let _digest = hasher.hash(data: value); // $ MISSING: Alert[swift/weak-sensitive-data-hashing] // BAD [NOT DETECTED] + let _digest = hasher.hash(data: value); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] } diff --git a/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift b/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift index a6f4584230e7..be3a136b9682 100644 --- a/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift +++ b/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift @@ -150,83 +150,84 @@ extension String { func testArrays(harmlessArray: Array, phoneNumberArray: Array, passwdArray: Array) { _ = MD5().calculate(for: harmlessArray) // GOOD (not sensitive) - _ = MD5().calculate(for: phoneNumberArray) // $ Alert[swift/weak-sensitive-data-hashing] - _ = MD5().calculate(for: passwdArray) // $ Alert[swift/weak-password-hashing] + _ = MD5().calculate(for: phoneNumberArray) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + _ = MD5().calculate(for: passwdArray) // $ Alert[unified/swift/weak-password-hashing] _ = SHA1().calculate(for: harmlessArray) // GOOD (not sensitive) - _ = SHA1().calculate(for: phoneNumberArray) // $ Alert[swift/weak-sensitive-data-hashing] - _ = SHA1().calculate(for: passwdArray) // $ Alert[swift/weak-password-hashing] + _ = SHA1().calculate(for: phoneNumberArray) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + _ = SHA1().calculate(for: passwdArray) // $ Alert[unified/swift/weak-password-hashing] _ = SHA2(variant: .sha512).calculate(for: harmlessArray) // GOOD _ = SHA2(variant: .sha512).calculate(for: phoneNumberArray) // GOOD - _ = SHA2(variant: .sha512).calculate(for: passwdArray) // $ Alert[swift/weak-password-hashing] + _ = SHA2(variant: .sha512).calculate(for: passwdArray) // $ Alert[unified/swift/weak-password-hashing] _ = SHA3(variant: .sha512).calculate(for: harmlessArray) // GOOD _ = SHA3(variant: .sha512).calculate(for: phoneNumberArray) // GOOD - _ = SHA3(variant: .sha512).calculate(for: passwdArray) // $ Alert[swift/weak-password-hashing] + _ = SHA3(variant: .sha512).calculate(for: passwdArray) // $ Alert[unified/swift/weak-password-hashing] _ = Digest.md5(harmlessArray) // GOOD (not sensitive) - _ = Digest.md5(phoneNumberArray) // $ Alert[swift/weak-sensitive-data-hashing] - _ = Digest.md5(passwdArray) // $ Alert[swift/weak-password-hashing] + _ = Digest.md5(phoneNumberArray) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + _ = Digest.md5(passwdArray) // $ Alert[unified/swift/weak-password-hashing] _ = Digest.sha1(harmlessArray) // GOOD (not sensitive) - _ = Digest.sha1(phoneNumberArray) // $ Alert[swift/weak-sensitive-data-hashing] - _ = Digest.sha1(passwdArray) // $ Alert[swift/weak-password-hashing] + _ = Digest.sha1(phoneNumberArray) // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + _ = Digest.sha1(passwdArray) // $ Alert[unified/swift/weak-password-hashing] _ = Digest.sha512(harmlessArray) // GOOD (not sensitive) _ = Digest.sha512(phoneNumberArray) // GOOD - _ = Digest.sha512(passwdArray) // $ Alert[swift/weak-password-hashing] + _ = Digest.sha512(passwdArray) // $ Alert[unified/swift/weak-password-hashing] _ = Digest.sha2(harmlessArray, variant: .sha512) // GOOD (not sensitive) _ = Digest.sha2(phoneNumberArray, variant: .sha512) // GOOD - _ = Digest.sha2(passwdArray, variant: .sha512) // $ Alert[swift/weak-password-hashing] + _ = Digest.sha2(passwdArray, variant: .sha512) // $ Alert[unified/swift/weak-password-hashing] _ = Digest.sha3(harmlessArray, variant: .sha512) // GOOD (not sensitive) _ = Digest.sha3(phoneNumberArray, variant: .sha512) // GOOD - _ = Digest.sha3(passwdArray, variant: .sha512) // $ Alert[swift/weak-password-hashing] + _ = Digest.sha3(passwdArray, variant: .sha512) // $ Alert[unified/swift/weak-password-hashing] _ = harmlessArray.md5() // GOOD (not sensitive) - _ = phoneNumberArray.md5() // $ Alert[swift/weak-sensitive-data-hashing] - _ = passwdArray.md5() // $ Alert[swift/weak-password-hashing] + _ = phoneNumberArray.md5() // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + _ = passwdArray.md5() // $ Alert[unified/swift/weak-password-hashing] _ = harmlessArray.sha1() // GOOD (not sensitive) - _ = phoneNumberArray.sha1() // $ Alert[swift/weak-sensitive-data-hashing] - _ = passwdArray.sha1() // $ Alert[swift/weak-password-hashing] + _ = phoneNumberArray.sha1() // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + _ = passwdArray.sha1() // $ Alert[unified/swift/weak-password-hashing] _ = harmlessArray.sha512() // GOOD _ = phoneNumberArray.sha512() // GOOD - _ = passwdArray.sha512() // $ Alert[swift/weak-password-hashing] + _ = passwdArray.sha512() // $ Alert[unified/swift/weak-password-hashing] _ = harmlessArray.sha2(.sha512) // GOOD _ = phoneNumberArray.sha2(.sha512) // GOOD - _ = passwdArray.sha2(.sha512) // $ Alert[swift/weak-password-hashing] + _ = passwdArray.sha2(.sha512) // $ Alert[unified/swift/weak-password-hashing] _ = harmlessArray.sha3(.sha512) // GOOD _ = phoneNumberArray.sha3(.sha512) // GOOD - _ = passwdArray.sha3(.sha512) // $ Alert[swift/weak-password-hashing] + _ = passwdArray.sha3(.sha512) // $ Alert[unified/swift/weak-password-hashing] } func testData(harmlessData: Data, medicalData: Data, passwdData: Data) { _ = harmlessData.md5() // GOOD (not sensitive) - _ = medicalData.md5() // $ Alert[swift/weak-sensitive-data-hashing] - _ = passwdData.md5() // $ Alert[swift/weak-password-hashing] + _ = medicalData.md5() // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + _ = passwdData.md5() // $ Alert[unified/swift/weak-password-hashing] _ = harmlessData.sha1() // GOOD (not sensitive) - _ = medicalData.sha1() // $ Alert[swift/weak-sensitive-data-hashing] - _ = passwdData.sha1() // $ Alert[swift/weak-password-hashing] + _ = medicalData.sha1() // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + _ = passwdData.sha1() // $ Alert[unified/swift/weak-password-hashing] _ = harmlessData.sha512() // GOOD _ = medicalData.sha512() // GOOD - _ = passwdData.sha512() // $ Alert[swift/weak-password-hashing] + _ = passwdData.sha512() // $ Alert[unified/swift/weak-password-hashing] _ = harmlessData.sha2(.sha512) // GOOD _ = medicalData.sha2(.sha512) // GOOD - _ = passwdData.sha2(.sha512) // $ Alert[swift/weak-password-hashing] + _ = passwdData.sha2(.sha512) // $ Alert[unified/swift/weak-password-hashing] _ = harmlessData.sha3(.sha512) // GOOD _ = medicalData.sha3(.sha512) // GOOD - _ = passwdData.sha3(.sha512) // $ Alert[swift/weak-password-hashing] + _ = passwdData.sha3(.sha512) // $ Alert[unified/swift/weak-password-hashing] } func testStrings(creditCardNumber: String, passwd: String) { _ = "harmless".md5() // GOOD (not sensitive) - _ = creditCardNumber.md5() // $ Alert[swift/weak-sensitive-data-hashing] - _ = passwd.md5() // $ Alert[swift/weak-password-hashing] + _ = creditCardNumber.md5() // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + _ = passwd.md5() // $ Alert[unified/swift/weak-password-hashing] _ = "harmless".sha1() // GOOD (not sensitive) - _ = creditCardNumber.sha1() // $ Alert[swift/weak-sensitive-data-hashing] - _ = passwd.sha1() // $ Alert[swift/weak-password-hashing] + _ = creditCardNumber.sha1() // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] + _ = passwd.sha1() // $ Alert[unified/swift/weak-password-hashing] _ = "harmless".sha512() // GOOD _ = creditCardNumber.sha512() // GOOD - _ = passwd.sha512() // $ Alert[swift/weak-password-hashing] + _ = passwd.sha512() // $ Alert[unified/swift/weak-password-hashing] _ = "harmless".sha2(.sha512) // GOOD _ = creditCardNumber.sha2(.sha512) // GOOD - _ = passwd.sha2(.sha512) // $ Alert[swift/weak-password-hashing] + _ = passwd.sha2(.sha512) // $ Alert[unified/swift/weak-password-hashing] _ = "harmless".sha3(.sha512) // GOOD _ = creditCardNumber.sha3(.sha512) // GOOD - _ = passwd.sha3(.sha512) // $ Alert[swift/weak-password-hashing] + _ = passwd.sha3(.sha512) // $ Alert[unified/swift/weak-password-hashing] } + From 951a41d57c22af3e6e489d7efb4cb4835e4f98c1 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Wed, 2 Dec 2026 19:05:49 +0000 Subject: [PATCH 4/8] unified: Fix SHA3 sink kind in legacy Swift models Correct the four CryptoSwift SHA3 sink models in legacy-swift.model.json that mistakenly used weak-password-hash-input-SHA2 instead of weak-password-hash-input-SHA3, and update WeakPasswordHashing.expected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- unified/ql/lib/ext/legacy-swift.model.json | 8 ++++---- .../security/CWE-328/WeakPasswordHashing.expected | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/unified/ql/lib/ext/legacy-swift.model.json b/unified/ql/lib/ext/legacy-swift.model.json index f714f181aee7..83e899c17717 100644 --- a/unified/ql/lib/ext/legacy-swift.model.json +++ b/unified/ql/lib/ext/legacy-swift.model.json @@ -261,10 +261,10 @@ ["", "SHA384", true, "hash(data:)", "", "", "Argument[data:]", "weak-password-hash-input-SHA384", "manual"], ["", "SHA384", true, "update(bufferPointer:)", "", "", "Argument[bufferPointer:]", "weak-password-hash-input-SHA384", "manual"], ["", "SHA384", true, "update(data:)", "", "", "Argument[data:]", "weak-password-hash-input-SHA384", "manual"], - ["", "SHA3", true, "callAsFunction(_:)", "", "", "Argument[0]", "weak-password-hash-input-SHA2", "manual"], - ["", "SHA3", true, "calculate(for:)", "", "", "Argument[for:]", "weak-password-hash-input-SHA2", "manual"], - ["", "SHA3", true, "process(block:currentHash:)", "", "", "Argument[block:]", "weak-password-hash-input-SHA2", "manual"], - ["", "SHA3", true, "update(withBytes:isLast?:)", "", "", "Argument[withBytes:]", "weak-password-hash-input-SHA2", "manual"], + ["", "SHA3", true, "callAsFunction(_:)", "", "", "Argument[0]", "weak-password-hash-input-SHA3", "manual"], + ["", "SHA3", true, "calculate(for:)", "", "", "Argument[for:]", "weak-password-hash-input-SHA3", "manual"], + ["", "SHA3", true, "process(block:currentHash:)", "", "", "Argument[block:]", "weak-password-hash-input-SHA3", "manual"], + ["", "SHA3", true, "update(withBytes:isLast?:)", "", "", "Argument[withBytes:]", "weak-password-hash-input-SHA3", "manual"], ["", "SHA512", true, "hash(bufferPointer:)", "", "", "Argument[bufferPointer:]", "weak-password-hash-input-SHA512", "manual"], ["", "SHA512", true, "hash(data:)", "", "", "Argument[data:]", "weak-password-hash-input-SHA512", "manual"], ["", "SHA512", true, "update(bufferPointer:)", "", "", "Argument[bufferPointer:]", "weak-password-hash-input-SHA512", "manual"], diff --git a/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected index 92c988bca886..72f02cc232f8 100644 --- a/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected +++ b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected @@ -122,15 +122,19 @@ | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:154:30:154:40 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:154:30:154:40 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:154:30:154:40 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:154:30:154:40 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:157:31:157:41 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:157:31:157:41 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:157:31:157:41 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | testCryptoSwift.swift:157:31:157:41 | passwdArray | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:157:31:157:41 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:160:47:160:57 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:160:47:160:57 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:160:47:160:57 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | testCryptoSwift.swift:160:47:160:57 | passwdArray | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:160:47:160:57 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:163:47:163:57 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:163:47:163:57 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:163:47:163:57 | passwdArray | password (passwdArray) | +| testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | testCryptoSwift.swift:163:47:163:57 | passwdArray | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:163:47:163:57 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:167:20:167:30 | passwdArray | testCryptoSwift.swift:167:20:167:30 | passwdArray | testCryptoSwift.swift:167:20:167:30 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:167:20:167:30 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:170:21:170:31 | passwdArray | testCryptoSwift.swift:170:21:170:31 | passwdArray | testCryptoSwift.swift:170:21:170:31 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:170:21:170:31 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:173:23:173:33 | passwdArray | testCryptoSwift.swift:173:23:173:33 | passwdArray | testCryptoSwift.swift:173:23:173:33 | passwdArray | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:173:23:173:33 | passwdArray | password (passwdArray) | From dde9daf8607482ed9a9bd370af82d6b9cdd4ab89 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Wed, 2 Dec 2026 19:06:04 +0000 Subject: [PATCH 5/8] unified: Add barrier and metatype test cases for CWE-328 Add test cases covering the HMAC/PBKDF1/PBKDF2 implementation barrier (both struct and extension declarations, plus a control helper) in testCryptoSwift.swift, and a SHA256.self metatype password-hashing case in testCryptoKit.swift. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CWE-328/WeakPasswordHashing.expected | 20 ++++++++++++++++ .../security/CWE-328/testCryptoKit.swift | 6 ++++- .../security/CWE-328/testCryptoSwift.swift | 23 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected index 72f02cc232f8..b0483b35d6ee 100644 --- a/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected +++ b/unified/ql/test/query-tests/security/CWE-328/WeakPasswordHashing.expected @@ -119,6 +119,11 @@ | testCryptoKit.swift:224:33:224:57 | Data(...) | testCryptoKit.swift:224:38:224:51 | passwordString | testCryptoKit.swift:224:33:224:57 | Data(...) | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:224:38:224:51 | passwordString | password (passwordString) | | testCryptoKit.swift:224:33:224:57 | Data(...) | testCryptoKit.swift:224:38:224:51 | passwordString | testCryptoKit.swift:224:33:224:57 | Data(...) | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:224:38:224:51 | passwordString | password (passwordString) | | testCryptoKit.swift:224:33:224:57 | Data(...) | testCryptoKit.swift:224:38:224:51 | passwordString | testCryptoKit.swift:224:33:224:57 | Data(...) | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:224:38:224:51 | passwordString | password (passwordString) | +| testCryptoKit.swift:251:39:251:44 | value7 | testCryptoKit.swift:249:23:249:36 | passwordString | testCryptoKit.swift:251:39:251:44 | value7 | Insecure hashing algorithm (MD5) depends on $@. | testCryptoKit.swift:249:23:249:36 | passwordString | password (passwordString) | +| testCryptoKit.swift:251:39:251:44 | value7 | testCryptoKit.swift:249:23:249:36 | passwordString | testCryptoKit.swift:251:39:251:44 | value7 | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoKit.swift:249:23:249:36 | passwordString | password (passwordString) | +| testCryptoKit.swift:251:39:251:44 | value7 | testCryptoKit.swift:249:23:249:36 | passwordString | testCryptoKit.swift:251:39:251:44 | value7 | Insecure hashing algorithm (SHA256) depends on $@. | testCryptoKit.swift:249:23:249:36 | passwordString | password (passwordString) | +| testCryptoKit.swift:251:39:251:44 | value7 | testCryptoKit.swift:249:23:249:36 | passwordString | testCryptoKit.swift:251:39:251:44 | value7 | Insecure hashing algorithm (SHA384) depends on $@. | testCryptoKit.swift:249:23:249:36 | passwordString | password (passwordString) | +| testCryptoKit.swift:251:39:251:44 | value7 | testCryptoKit.swift:249:23:249:36 | passwordString | testCryptoKit.swift:251:39:251:44 | value7 | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoKit.swift:249:23:249:36 | passwordString | password (passwordString) | | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | Insecure hashing algorithm (MD5) depends on $@. | testCryptoSwift.swift:154:30:154:40 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | Insecure hashing algorithm (SHA1) depends on $@. | testCryptoSwift.swift:154:30:154:40 | passwdArray | password (passwdArray) | | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | testCryptoSwift.swift:154:30:154:40 | passwdArray | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:154:30:154:40 | passwdArray | password (passwdArray) | @@ -155,9 +160,14 @@ | testCryptoSwift.swift:225:9:225:23 | [self arg] ... .sha512(...) | testCryptoSwift.swift:225:9:225:14 | passwd | testCryptoSwift.swift:225:9:225:23 | [self arg] ... .sha512(...) | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:225:9:225:14 | passwd | password (passwd) | | testCryptoSwift.swift:228:9:228:28 | [self arg] ... .sha2(...) | testCryptoSwift.swift:228:9:228:14 | passwd | testCryptoSwift.swift:228:9:228:28 | [self arg] ... .sha2(...) | Insecure hashing algorithm (SHA2) depends on $@. | testCryptoSwift.swift:228:9:228:14 | passwd | password (passwd) | | testCryptoSwift.swift:231:9:231:28 | [self arg] ... .sha3(...) | testCryptoSwift.swift:231:9:231:14 | passwd | testCryptoSwift.swift:231:9:231:28 | [self arg] ... .sha3(...) | Insecure hashing algorithm (SHA3) depends on $@. | testCryptoSwift.swift:231:9:231:14 | passwd | password (passwd) | +| testCryptoSwift.swift:248:30:248:34 | bytes | testCryptoSwift.swift:255:36:255:46 | passwdArray | testCryptoSwift.swift:248:30:248:34 | bytes | Insecure hashing algorithm (SHA512) depends on $@. | testCryptoSwift.swift:255:36:255:46 | passwdArray | password (passwdArray) | edges | testCryptoKit.swift:224:38:224:51 | passwordString | testCryptoKit.swift:224:38:224:56 | ... .utf8 | provenance | | | testCryptoKit.swift:224:38:224:56 | ... .utf8 | testCryptoKit.swift:224:33:224:57 | Data(...) | provenance | | +| testCryptoKit.swift:249:9:249:14 | value7 | testCryptoKit.swift:251:39:251:44 | value7 | provenance | | +| testCryptoKit.swift:249:18:249:42 | Data(...) | testCryptoKit.swift:249:9:249:14 | value7 | provenance | | +| testCryptoKit.swift:249:23:249:36 | passwordString | testCryptoKit.swift:249:23:249:41 | ... .utf8 | provenance | | +| testCryptoKit.swift:249:23:249:41 | ... .utf8 | testCryptoKit.swift:249:18:249:42 | Data(...) | provenance | | | testCryptoSwift.swift:183:9:183:19 | passwdArray | testCryptoSwift.swift:183:9:183:25 | [self arg] ... .md5(...) | provenance | | | testCryptoSwift.swift:186:9:186:19 | passwdArray | testCryptoSwift.swift:186:9:186:26 | [self arg] ... .sha1(...) | provenance | | | testCryptoSwift.swift:189:9:189:19 | passwdArray | testCryptoSwift.swift:189:9:189:28 | [self arg] ... .sha512(...) | provenance | | @@ -173,6 +183,8 @@ edges | testCryptoSwift.swift:225:9:225:14 | passwd | testCryptoSwift.swift:225:9:225:23 | [self arg] ... .sha512(...) | provenance | | | testCryptoSwift.swift:228:9:228:14 | passwd | testCryptoSwift.swift:228:9:228:28 | [self arg] ... .sha2(...) | provenance | | | testCryptoSwift.swift:231:9:231:14 | passwd | testCryptoSwift.swift:231:9:231:28 | [self arg] ... .sha3(...) | provenance | | +| testCryptoSwift.swift:247:24:247:28 | bytes | testCryptoSwift.swift:248:30:248:34 | bytes | provenance | | +| testCryptoSwift.swift:255:36:255:46 | passwdArray | testCryptoSwift.swift:247:24:247:28 | bytes | provenance | | nodes | testCryptoKit.swift:84:47:84:52 | passwd | semmle.label | passwd | | testCryptoKit.swift:85:52:85:57 | passwd | semmle.label | passwd | @@ -200,6 +212,11 @@ nodes | testCryptoKit.swift:224:33:224:57 | Data(...) | semmle.label | Data(...) | | testCryptoKit.swift:224:38:224:51 | passwordString | semmle.label | passwordString | | testCryptoKit.swift:224:38:224:56 | ... .utf8 | semmle.label | ... .utf8 | +| testCryptoKit.swift:249:9:249:14 | value7 | semmle.label | value7 | +| testCryptoKit.swift:249:18:249:42 | Data(...) | semmle.label | Data(...) | +| testCryptoKit.swift:249:23:249:36 | passwordString | semmle.label | passwordString | +| testCryptoKit.swift:249:23:249:41 | ... .utf8 | semmle.label | ... .utf8 | +| testCryptoKit.swift:251:39:251:44 | value7 | semmle.label | value7 | | testCryptoSwift.swift:154:30:154:40 | passwdArray | semmle.label | passwdArray | | testCryptoSwift.swift:157:31:157:41 | passwdArray | semmle.label | passwdArray | | testCryptoSwift.swift:160:47:160:57 | passwdArray | semmle.label | passwdArray | @@ -239,4 +256,7 @@ nodes | testCryptoSwift.swift:228:9:228:28 | [self arg] ... .sha2(...) | semmle.label | [self arg] ... .sha2(...) | | testCryptoSwift.swift:231:9:231:14 | passwd | semmle.label | passwd | | testCryptoSwift.swift:231:9:231:28 | [self arg] ... .sha3(...) | semmle.label | [self arg] ... .sha3(...) | +| testCryptoSwift.swift:247:24:247:28 | bytes | semmle.label | bytes | +| testCryptoSwift.swift:248:30:248:34 | bytes | semmle.label | bytes | +| testCryptoSwift.swift:255:36:255:46 | passwdArray | semmle.label | passwdArray | subpaths diff --git a/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift b/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift index 6c9410276e35..9a52810b4496 100644 --- a/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift +++ b/unified/ql/test/query-tests/security/CWE-328/testCryptoKit.swift @@ -226,7 +226,7 @@ func testBadExample(passwordString: String) { } } -func testWithFlowAndMetatypes(cardNumber: String) { +func testWithFlowAndMetatypes(cardNumber: String, passwordString: String) { let value1 = Data(cardNumber.utf8); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] let _digest1 = Insecure.MD5.hash(data: value1); // $ MISSING: Alert[unified/swift/weak-sensitive-data-hashing] @@ -245,6 +245,10 @@ func testWithFlowAndMetatypes(cardNumber: String) { let value6 = Data(cardNumber.utf8); testReceiver3(hasher: Insecure.MD5.self, value: value6); + + let value7 = Data(passwordString.utf8); // $ Source[unified/swift/weak-password-hashing] + let hasher7 = SHA256.self; // metatype + let _digest7 = hasher7.hash(data: value7); // $ Alert[unified/swift/weak-password-hashing] } func testReceiver1(value: Data) { diff --git a/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift b/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift index be3a136b9682..aae91aa07f0b 100644 --- a/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift +++ b/unified/ql/test/query-tests/security/CWE-328/testCryptoSwift.swift @@ -231,3 +231,26 @@ func testStrings(creditCardNumber: String, passwd: String) { _ = passwd.sha3(.sha512) // $ Alert[unified/swift/weak-password-hashing] } +struct PBKDF2 { + static func derive(bytes: Array) -> Array { + return Digest.sha512(bytes) // GOOD (inside PBKDF2 implementation) + } +} + +extension PBKDF2 { + static func deriveInExtension(bytes: Array) -> Array { + return Digest.sha512(bytes) // GOOD (inside PBKDF2 extension) + } +} + +struct CustomHasher { + static func derive(bytes: Array) -> Array { + return Digest.sha512(bytes) // $ Alert[unified/swift/weak-password-hashing] + } +} + +func testImplementationBarrier(passwdArray: Array) { + _ = PBKDF2.derive(bytes: passwdArray) + _ = PBKDF2.deriveInExtension(bytes: passwdArray) + _ = CustomHasher.derive(bytes: passwdArray) // $ Source[unified/swift/weak-password-hashing] +} From da89b66a5f1bca428db5c4ba75909f4f49cf81b5 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Wed, 2 Dec 2026 19:06:06 +0000 Subject: [PATCH 6/8] unified: Fix libsodium anchor link in WeakPasswordHashing.qhelp Update the libsodium bindings anchor from #bindings-programming-languages to #bindings-for-programming-languages in WeakPasswordHashing.qhelp. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ql/src/queries/security/CWE-328/WeakPasswordHashing.qhelp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.qhelp b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.qhelp index 0e26c11703b1..390c5b12fa64 100644 --- a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.qhelp +++ b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.qhelp @@ -85,7 +85,7 @@ GitHub: CryptoSwift README - Password-Based Key Derivation Function
  • - libsodium: libsodium bindings for other languages + libsodium: libsodium bindings for other languages
  • GitHub: Argon2Swift From 689a0ee1b80d7572fc2de5ab3416e68bc982be87 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Thu, 3 Dec 2026 13:54:32 +0000 Subject: [PATCH 7/8] Refactor barrier predicate for weak password hashing Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../ql/src/queries/security/CWE-328/WeakPasswordHashing.ql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql index ac0d3bb66915..b68e2210b183 100644 --- a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql +++ b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql @@ -41,9 +41,8 @@ module WeakPasswordHashingConfig implements DataFlow::ConfigSig { predicate isBarrier(DataFlow::Node node) { // A barrier for weak password hashing, when it occurs inside of // certain cryptographic algorithms as part of their design. - exists(Parameter param, ClassLikeDeclaration cls, string name | - node.asExpr() = param.getPattern() and - param.getParent().getParent+() = cls and + exists(ClassLikeDeclaration cls, string name | + node.asExpr().getParent+() = cls and ( name = cls.resolve().getName() or From 15d8fcaefd6743287861fdad5bbaa006a7337204 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:01:00 +0000 Subject: [PATCH 8/8] Unified: Add observeDiffInformedIncrementalMode predicate. --- unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql index b68e2210b183..295708c0c794 100644 --- a/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql +++ b/unified/ql/src/queries/security/CWE-328/WeakPasswordHashing.ql @@ -61,6 +61,8 @@ module WeakPasswordHashingConfig implements DataFlow::ConfigSig { // make sinks barriers so that we only report the closest instance isSink(node) } + + predicate observeDiffInformedIncrementalMode() { any() } } module WeakPasswordHashingFlow = TaintTracking::Global;