- ECB should not be used as a mode for encryption. With a fixed key, identical plaintext blocks always produce identical ciphertext blocks. This reveals patterns in the plaintext, even when the ciphertext cannot be decrypted.
+ ECB should not be used as a mode for encryption. With a fixed key, identical plaintext blocks always produce identical ciphertext blocks. This can expose sensitive information by revealing patterns in the plaintext.
- Use an authenticated encryption mode such as GCM where available. If CBC is used, generate a fresh, unpredictable initialization vector for each encryption and use a separate message authentication mechanism to protect ciphertext integrity. Changing the cipher mode alone does not prevent replay attacks.
+ Use an authenticated encryption mode such as GCM where available. If CBC is used, generate a fresh, unpredictable initialization vector for each encryption and use a separate message authentication mechanism to protect ciphertext integrity.
- The following example shows six cases of instantiating a cipher with different block modes. In the 'BAD' cases, the mode of encryption is ECB, which reveals patterns in the plaintext. In the 'GOOD' cases, the encryption mode is CBC with a randomly generated initialization vector, avoiding ECB's deterministic encryption of individual blocks. Authentication of the ciphertext is not shown.
+ The following example shows six cases of instantiating a cipher with different block modes. In the 'BAD' cases, the encryption mode is ECB, which reveals patterns in the plaintext. In the 'GOOD' cases, the encryption mode is CBC with a randomly generated initialization vector, avoiding this issue. Authentication of the ciphertext is not shown.
From dddf31e30249c6ca75582a6d372a72077a8caf94 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Thu, 26 Nov 2026 15:37:04 +0000
Subject: [PATCH 13/16] Unified: Remove duplicate ECB sink models
The AES and Blowfish sinks are already in crypto.model.json; remove the legacy copies restored by the merge.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
unified/ql/lib/ext/legacy-swift.model.json | 3 ---
1 file changed, 3 deletions(-)
diff --git a/unified/ql/lib/ext/legacy-swift.model.json b/unified/ql/lib/ext/legacy-swift.model.json
index 284c3af43d30..7c3e82ed32a5 100644
--- a/unified/ql/lib/ext/legacy-swift.model.json
+++ b/unified/ql/lib/ext/legacy-swift.model.json
@@ -177,10 +177,7 @@
["", "NSMutableString", true, "character(at:)", "", "", "Argument[at:]", "nsstring-length", "manual"],
["", "NSMutableString", true, "substring(from:)", "", "", "Argument[from:]", "nsstring-length", "manual"],
["", "NSMutableString", true, "substring(to:)", "", "", "Argument[to:]", "nsstring-length", "manual"],
- ["", "AES", true, "init(key:blockMode:)", "", "", "Argument[blockMode:]", "encryption-block-mode", "manual"],
- ["", "AES", true, "init(key:blockMode:padding:)", "", "", "Argument[blockMode:]", "encryption-block-mode", "manual"],
["", "NSRegularExpression", true, "init(pattern:options?:)", "", "", "Argument[pattern:]", "regex-use", "manual"],
- ["", "Blowfish", true, "init(key:blockMode?:padding:)", "", "", "Argument[blockMode:]", "encryption-block-mode", "manual"],
["", "URLSessionConfiguration", false, "tlsMaximumSupportedProtocol", "", "", "PostUpdate", "tls-protocol-version", "manual"],
["", "URLSessionConfiguration", false, "tlsMinimumSupportedProtocol", "", "", "PostUpdate", "tls-protocol-version", "manual"],
["", "URLSessionConfiguration", false, "tlsMaximumSupportedProtocolVersion", "", "", "PostUpdate", "tls-protocol-version", "manual"],
From d6acf69935bce81ae5c91f9dc7cb889907d4ea23 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Thu, 26 Nov 2026 15:37:29 +0000
Subject: [PATCH 14/16] Unified: Mark defaulted crypto parameters optional
Match CryptoSwift AES calls with or without padding and preserve the defaulted Blowfish block mode in the moved sink model.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
unified/ql/lib/ext/crypto.model.json | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/unified/ql/lib/ext/crypto.model.json b/unified/ql/lib/ext/crypto.model.json
index b2078d6d9b16..dbcd5530a68c 100644
--- a/unified/ql/lib/ext/crypto.model.json
+++ b/unified/ql/lib/ext/crypto.model.json
@@ -17,9 +17,8 @@
},
"data": [
// namespace, type, subtypes, name, signature, ext, input, kind, provenance
- ["", "AES", true, "init(key:blockMode:)", "", "", "Argument[blockMode:]", "encryption-block-mode", "manual"],
- ["", "AES", true, "init(key:blockMode:padding:)", "", "", "Argument[blockMode:]", "encryption-block-mode", "manual"],
- ["", "Blowfish", true, "init(key:blockMode:padding:)", "", "", "Argument[blockMode:]", "encryption-block-mode", "manual"]
+ ["", "AES", true, "init(key:blockMode:padding?:)", "", "", "Argument[blockMode:]", "encryption-block-mode", "manual"],
+ ["", "Blowfish", true, "init(key:blockMode?:padding:)", "", "", "Argument[blockMode:]", "encryption-block-mode", "manual"]
]
}
]
From 22f94e117c640557079f44e58eb9f1c90ede7a3e Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Fri, 27 Nov 2026 15:51:08 +0000
Subject: [PATCH 15/16] Unified: Fix example code and copy it into test.
---
.../queries/security/CWE-327/ECBEncryption.swift | 2 +-
.../CWE-327/ECBEncryption/ECBEncryption.expected | 6 ++++++
.../security/CWE-327/ECBEncryption/test.swift | 16 ++++++++++++++++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/unified/ql/src/queries/security/CWE-327/ECBEncryption.swift b/unified/ql/src/queries/security/CWE-327/ECBEncryption.swift
index 12c7fdf0ac5a..80001fed4ad7 100644
--- a/unified/ql/src/queries/security/CWE-327/ECBEncryption.swift
+++ b/unified/ql/src/queries/security/CWE-327/ECBEncryption.swift
@@ -10,7 +10,7 @@ func encrypt(key : Key, padding : Padding) {
// GOOD: ECB is not used for block mode
_ = try AES(key: key, blockMode: CBC(iv: AES.randomIV(AES.blockSize)), padding: padding)
_ = try AES(key: key, blockMode: CBC(iv: AES.randomIV(AES.blockSize)))
- _ = try Blowfish(key: key, blockMode: CBC(iv: Blowfish.randomIV(Blowfish.blockSize), padding: padding)
+ _ = try Blowfish(key: key, blockMode: CBC(iv: Blowfish.randomIV(Blowfish.blockSize)), padding: padding)
// ...
}
diff --git a/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/ECBEncryption.expected b/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/ECBEncryption.expected
index bfd54bef4e9a..eabdd3721a02 100644
--- a/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/ECBEncryption.expected
+++ b/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/ECBEncryption.expected
@@ -8,6 +8,9 @@
| test.swift:71:42:71:44 | ecb | test.swift:50:12:50:16 | ECB(...) | test.swift:71:42:71:44 | ecb | The initialization of the cipher 'ecb' uses the insecure ECB block mode from $@. | test.swift:50:12:50:16 | ECB(...) | ECB(...) |
| test.swift:72:42:72:46 | ECB(...) | test.swift:72:42:72:46 | ECB(...) | test.swift:72:42:72:46 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:72:42:72:46 | ECB(...) | ECB(...) |
| test.swift:73:42:73:58 | getECBBlockMode(...) | test.swift:39:9:39:13 | ECB(...) | test.swift:73:42:73:58 | getECBBlockMode(...) | The initialization of the cipher 'getECBBlockMode(...)' uses the insecure ECB block mode from $@. | test.swift:39:9:39:13 | ECB(...) | ECB(...) |
+| test.swift:84:35:84:39 | ECB(...) | test.swift:84:35:84:39 | ECB(...) | test.swift:84:35:84:39 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:84:35:84:39 | ECB(...) | ECB(...) |
+| test.swift:85:35:85:39 | ECB(...) | test.swift:85:35:85:39 | ECB(...) | test.swift:85:35:85:39 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:85:35:85:39 | ECB(...) | ECB(...) |
+| test.swift:86:40:86:44 | ECB(...) | test.swift:86:40:86:44 | ECB(...) | test.swift:86:40:86:44 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:86:40:86:44 | ECB(...) | ECB(...) |
edges
| test.swift:39:9:39:13 | ECB(...) | test.swift:60:37:60:53 | getECBBlockMode(...) | provenance | |
| test.swift:39:9:39:13 | ECB(...) | test.swift:61:37:61:53 | getECBBlockMode(...) | provenance | |
@@ -29,4 +32,7 @@ nodes
| test.swift:71:42:71:44 | ecb | semmle.label | ecb |
| test.swift:72:42:72:46 | ECB(...) | semmle.label | ECB(...) |
| test.swift:73:42:73:58 | getECBBlockMode(...) | semmle.label | getECBBlockMode(...) |
+| test.swift:84:35:84:39 | ECB(...) | semmle.label | ECB(...) |
+| test.swift:85:35:85:39 | ECB(...) | semmle.label | ECB(...) |
+| test.swift:86:40:86:44 | ECB(...) | semmle.label | ECB(...) |
subpaths
diff --git a/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/test.swift b/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/test.swift
index 4e47ae924c66..dd0434c57232 100644
--- a/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/test.swift
+++ b/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/test.swift
@@ -76,3 +76,19 @@ func test1() {
let bg2 = Blowfish(key: key, blockMode: CBC(iv: iv), padding: padding) // GOOD
let bg3 = Blowfish(key: key, blockMode: getCBCBlockMode(), padding: padding) // GOOD
}
+
+func doc_example_encrypt(key : Key, padding : Padding) {
+ // ...
+
+ // BAD: ECB is used for block mode
+ _ = try AES(key: key, blockMode: ECB(), padding: padding) // $ Alert[unified/swift/ecb-encryption]
+ _ = try AES(key: key, blockMode: ECB()) // $ Alert[unified/swift/ecb-encryption]
+ _ = try Blowfish(key: key, blockMode: ECB(), padding: padding) // $ Alert[unified/swift/ecb-encryption]
+
+ // GOOD: ECB is not used for block mode
+ _ = try AES(key: key, blockMode: CBC(iv: AES.randomIV(AES.blockSize)), padding: padding)
+ _ = try AES(key: key, blockMode: CBC(iv: AES.randomIV(AES.blockSize)))
+ _ = try Blowfish(key: key, blockMode: CBC(iv: Blowfish.randomIV(Blowfish.blockSize)), padding: padding)
+
+ // ...
+}
From 33a764278fe88e67b139cf167d99c86ff48d41c3 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Fri, 27 Nov 2026 16:14:26 +0000
Subject: [PATCH 16/16] Unified: Fix the example still not compiling.
---
.../security/CWE-327/ECBEncryption.swift | 6 +-
.../ECBEncryption/ECBEncryption.expected | 68 +++++++++----------
.../security/CWE-327/ECBEncryption/test.swift | 16 ++++-
3 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/unified/ql/src/queries/security/CWE-327/ECBEncryption.swift b/unified/ql/src/queries/security/CWE-327/ECBEncryption.swift
index 80001fed4ad7..e7dd8e138fae 100644
--- a/unified/ql/src/queries/security/CWE-327/ECBEncryption.swift
+++ b/unified/ql/src/queries/security/CWE-327/ECBEncryption.swift
@@ -8,9 +8,9 @@ func encrypt(key : Key, padding : Padding) {
_ = try Blowfish(key: key, blockMode: ECB(), padding: padding)
// GOOD: ECB is not used for block mode
- _ = try AES(key: key, blockMode: CBC(iv: AES.randomIV(AES.blockSize)), padding: padding)
- _ = try AES(key: key, blockMode: CBC(iv: AES.randomIV(AES.blockSize)))
- _ = try Blowfish(key: key, blockMode: CBC(iv: Blowfish.randomIV(Blowfish.blockSize)), padding: padding)
+ _ = try AES(key: key, blockMode: CBC(iv: randomIV(AES.blockSize)), padding: padding)
+ _ = try AES(key: key, blockMode: CBC(iv: randomIV(AES.blockSize)))
+ _ = try Blowfish(key: key, blockMode: CBC(iv: randomIV(Blowfish.blockSize)), padding: padding)
// ...
}
diff --git a/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/ECBEncryption.expected b/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/ECBEncryption.expected
index eabdd3721a02..c46a1684b82f 100644
--- a/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/ECBEncryption.expected
+++ b/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/ECBEncryption.expected
@@ -1,38 +1,38 @@
#select
-| test.swift:56:37:56:39 | ecb | test.swift:50:12:50:16 | ECB(...) | test.swift:56:37:56:39 | ecb | The initialization of the cipher 'ecb' uses the insecure ECB block mode from $@. | test.swift:50:12:50:16 | ECB(...) | ECB(...) |
-| test.swift:57:37:57:39 | ecb | test.swift:50:12:50:16 | ECB(...) | test.swift:57:37:57:39 | ecb | The initialization of the cipher 'ecb' uses the insecure ECB block mode from $@. | test.swift:50:12:50:16 | ECB(...) | ECB(...) |
-| test.swift:58:37:58:41 | ECB(...) | test.swift:58:37:58:41 | ECB(...) | test.swift:58:37:58:41 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:58:37:58:41 | ECB(...) | ECB(...) |
-| test.swift:59:37:59:41 | ECB(...) | test.swift:59:37:59:41 | ECB(...) | test.swift:59:37:59:41 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:59:37:59:41 | ECB(...) | ECB(...) |
-| test.swift:60:37:60:53 | getECBBlockMode(...) | test.swift:39:9:39:13 | ECB(...) | test.swift:60:37:60:53 | getECBBlockMode(...) | The initialization of the cipher 'getECBBlockMode(...)' uses the insecure ECB block mode from $@. | test.swift:39:9:39:13 | ECB(...) | ECB(...) |
-| test.swift:61:37:61:53 | getECBBlockMode(...) | test.swift:39:9:39:13 | ECB(...) | test.swift:61:37:61:53 | getECBBlockMode(...) | The initialization of the cipher 'getECBBlockMode(...)' uses the insecure ECB block mode from $@. | test.swift:39:9:39:13 | ECB(...) | ECB(...) |
-| test.swift:71:42:71:44 | ecb | test.swift:50:12:50:16 | ECB(...) | test.swift:71:42:71:44 | ecb | The initialization of the cipher 'ecb' uses the insecure ECB block mode from $@. | test.swift:50:12:50:16 | ECB(...) | ECB(...) |
-| test.swift:72:42:72:46 | ECB(...) | test.swift:72:42:72:46 | ECB(...) | test.swift:72:42:72:46 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:72:42:72:46 | ECB(...) | ECB(...) |
-| test.swift:73:42:73:58 | getECBBlockMode(...) | test.swift:39:9:39:13 | ECB(...) | test.swift:73:42:73:58 | getECBBlockMode(...) | The initialization of the cipher 'getECBBlockMode(...)' uses the insecure ECB block mode from $@. | test.swift:39:9:39:13 | ECB(...) | ECB(...) |
-| test.swift:84:35:84:39 | ECB(...) | test.swift:84:35:84:39 | ECB(...) | test.swift:84:35:84:39 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:84:35:84:39 | ECB(...) | ECB(...) |
-| test.swift:85:35:85:39 | ECB(...) | test.swift:85:35:85:39 | ECB(...) | test.swift:85:35:85:39 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:85:35:85:39 | ECB(...) | ECB(...) |
-| test.swift:86:40:86:44 | ECB(...) | test.swift:86:40:86:44 | ECB(...) | test.swift:86:40:86:44 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:86:40:86:44 | ECB(...) | ECB(...) |
+| test.swift:60:37:60:39 | ecb | test.swift:54:12:54:16 | ECB(...) | test.swift:60:37:60:39 | ecb | The initialization of the cipher 'ecb' uses the insecure ECB block mode from $@. | test.swift:54:12:54:16 | ECB(...) | ECB(...) |
+| test.swift:61:37:61:39 | ecb | test.swift:54:12:54:16 | ECB(...) | test.swift:61:37:61:39 | ecb | The initialization of the cipher 'ecb' uses the insecure ECB block mode from $@. | test.swift:54:12:54:16 | ECB(...) | ECB(...) |
+| test.swift:62:37:62:41 | ECB(...) | test.swift:62:37:62:41 | ECB(...) | test.swift:62:37:62:41 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:62:37:62:41 | ECB(...) | ECB(...) |
+| test.swift:63:37:63:41 | ECB(...) | test.swift:63:37:63:41 | ECB(...) | test.swift:63:37:63:41 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:63:37:63:41 | ECB(...) | ECB(...) |
+| test.swift:64:37:64:53 | getECBBlockMode(...) | test.swift:43:9:43:13 | ECB(...) | test.swift:64:37:64:53 | getECBBlockMode(...) | The initialization of the cipher 'getECBBlockMode(...)' uses the insecure ECB block mode from $@. | test.swift:43:9:43:13 | ECB(...) | ECB(...) |
+| test.swift:65:37:65:53 | getECBBlockMode(...) | test.swift:43:9:43:13 | ECB(...) | test.swift:65:37:65:53 | getECBBlockMode(...) | The initialization of the cipher 'getECBBlockMode(...)' uses the insecure ECB block mode from $@. | test.swift:43:9:43:13 | ECB(...) | ECB(...) |
+| test.swift:75:42:75:44 | ecb | test.swift:54:12:54:16 | ECB(...) | test.swift:75:42:75:44 | ecb | The initialization of the cipher 'ecb' uses the insecure ECB block mode from $@. | test.swift:54:12:54:16 | ECB(...) | ECB(...) |
+| test.swift:76:42:76:46 | ECB(...) | test.swift:76:42:76:46 | ECB(...) | test.swift:76:42:76:46 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:76:42:76:46 | ECB(...) | ECB(...) |
+| test.swift:77:42:77:58 | getECBBlockMode(...) | test.swift:43:9:43:13 | ECB(...) | test.swift:77:42:77:58 | getECBBlockMode(...) | The initialization of the cipher 'getECBBlockMode(...)' uses the insecure ECB block mode from $@. | test.swift:43:9:43:13 | ECB(...) | ECB(...) |
+| test.swift:94:35:94:39 | ECB(...) | test.swift:94:35:94:39 | ECB(...) | test.swift:94:35:94:39 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:94:35:94:39 | ECB(...) | ECB(...) |
+| test.swift:95:35:95:39 | ECB(...) | test.swift:95:35:95:39 | ECB(...) | test.swift:95:35:95:39 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:95:35:95:39 | ECB(...) | ECB(...) |
+| test.swift:96:40:96:44 | ECB(...) | test.swift:96:40:96:44 | ECB(...) | test.swift:96:40:96:44 | ECB(...) | The initialization of the cipher 'ECB(...)' uses the insecure ECB block mode from $@. | test.swift:96:40:96:44 | ECB(...) | ECB(...) |
edges
-| test.swift:39:9:39:13 | ECB(...) | test.swift:60:37:60:53 | getECBBlockMode(...) | provenance | |
-| test.swift:39:9:39:13 | ECB(...) | test.swift:61:37:61:53 | getECBBlockMode(...) | provenance | |
-| test.swift:39:9:39:13 | ECB(...) | test.swift:73:42:73:58 | getECBBlockMode(...) | provenance | |
-| test.swift:50:6:50:8 | ecb | test.swift:56:37:56:39 | ecb | provenance | |
-| test.swift:50:6:50:8 | ecb | test.swift:57:37:57:39 | ecb | provenance | |
-| test.swift:50:6:50:8 | ecb | test.swift:71:42:71:44 | ecb | provenance | |
-| test.swift:50:12:50:16 | ECB(...) | test.swift:50:6:50:8 | ecb | provenance | |
+| test.swift:43:9:43:13 | ECB(...) | test.swift:64:37:64:53 | getECBBlockMode(...) | provenance | |
+| test.swift:43:9:43:13 | ECB(...) | test.swift:65:37:65:53 | getECBBlockMode(...) | provenance | |
+| test.swift:43:9:43:13 | ECB(...) | test.swift:77:42:77:58 | getECBBlockMode(...) | provenance | |
+| test.swift:54:6:54:8 | ecb | test.swift:60:37:60:39 | ecb | provenance | |
+| test.swift:54:6:54:8 | ecb | test.swift:61:37:61:39 | ecb | provenance | |
+| test.swift:54:6:54:8 | ecb | test.swift:75:42:75:44 | ecb | provenance | |
+| test.swift:54:12:54:16 | ECB(...) | test.swift:54:6:54:8 | ecb | provenance | |
nodes
-| test.swift:39:9:39:13 | ECB(...) | semmle.label | ECB(...) |
-| test.swift:50:6:50:8 | ecb | semmle.label | ecb |
-| test.swift:50:12:50:16 | ECB(...) | semmle.label | ECB(...) |
-| test.swift:56:37:56:39 | ecb | semmle.label | ecb |
-| test.swift:57:37:57:39 | ecb | semmle.label | ecb |
-| test.swift:58:37:58:41 | ECB(...) | semmle.label | ECB(...) |
-| test.swift:59:37:59:41 | ECB(...) | semmle.label | ECB(...) |
-| test.swift:60:37:60:53 | getECBBlockMode(...) | semmle.label | getECBBlockMode(...) |
-| test.swift:61:37:61:53 | getECBBlockMode(...) | semmle.label | getECBBlockMode(...) |
-| test.swift:71:42:71:44 | ecb | semmle.label | ecb |
-| test.swift:72:42:72:46 | ECB(...) | semmle.label | ECB(...) |
-| test.swift:73:42:73:58 | getECBBlockMode(...) | semmle.label | getECBBlockMode(...) |
-| test.swift:84:35:84:39 | ECB(...) | semmle.label | ECB(...) |
-| test.swift:85:35:85:39 | ECB(...) | semmle.label | ECB(...) |
-| test.swift:86:40:86:44 | ECB(...) | semmle.label | ECB(...) |
+| test.swift:43:9:43:13 | ECB(...) | semmle.label | ECB(...) |
+| test.swift:54:6:54:8 | ecb | semmle.label | ecb |
+| test.swift:54:12:54:16 | ECB(...) | semmle.label | ECB(...) |
+| test.swift:60:37:60:39 | ecb | semmle.label | ecb |
+| test.swift:61:37:61:39 | ecb | semmle.label | ecb |
+| test.swift:62:37:62:41 | ECB(...) | semmle.label | ECB(...) |
+| test.swift:63:37:63:41 | ECB(...) | semmle.label | ECB(...) |
+| test.swift:64:37:64:53 | getECBBlockMode(...) | semmle.label | getECBBlockMode(...) |
+| test.swift:65:37:65:53 | getECBBlockMode(...) | semmle.label | getECBBlockMode(...) |
+| test.swift:75:42:75:44 | ecb | semmle.label | ecb |
+| test.swift:76:42:76:46 | ECB(...) | semmle.label | ECB(...) |
+| test.swift:77:42:77:58 | getECBBlockMode(...) | semmle.label | getECBBlockMode(...) |
+| test.swift:94:35:94:39 | ECB(...) | semmle.label | ECB(...) |
+| test.swift:95:35:95:39 | ECB(...) | semmle.label | ECB(...) |
+| test.swift:96:40:96:44 | ECB(...) | semmle.label | ECB(...) |
subpaths
diff --git a/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/test.swift b/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/test.swift
index dd0434c57232..14c09b177cad 100644
--- a/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/test.swift
+++ b/unified/ql/test/query-tests/security/CWE-327/ECBEncryption/test.swift
@@ -4,12 +4,16 @@
// These stubs roughly follows the same structure as classes from CryptoSwift
class AES
{
+ static let blockSize = 16
+
init(key: Array, blockMode: BlockMode, padding: Padding) { }
init(key: Array, blockMode: BlockMode) { }
}
class Blowfish
{
+ static let blockSize = 8
+
init(key: Array, blockMode: BlockMode, padding: Padding) { }
}
@@ -77,6 +81,12 @@ func test1() {
let bg3 = Blowfish(key: key, blockMode: getCBCBlockMode(), padding: padding) // GOOD
}
+typealias Key = Array
+
+func randomIV(_ blockSize: Int) -> Array {
+ return (0..