From d6cdbcc2b50662f9dc2d8aa037ffb4919186d6b6 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Tue, 24 Nov 2026 11:54:39 +0000 Subject: [PATCH 1/2] Java: Update Encryption.qll for NIST SP 800-131A Rev. 2 Report SKIPJACK and 3DES variants (DESede, DESedeWrap, TripleDES, 3DES) with dedicated insecurity explanations, prevent single-DES from misclassifying 3DES strings, and add ChaCha20 / ChaCha20-Poly1305 to the secure algorithm allowlist. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../2026-11-24-encryption-nist-800-131ar2.md | 5 +++++ .../semmle/code/java/security/Encryption.qll | 16 ++++++++++++++-- .../CWE/CWE-327/BrokenCryptoAlgorithm.qhelp | 2 +- .../ql/test/library-tests/Encryption/Test.java | 9 +++++++++ .../Encryption/cryptoalgospec.expected | 4 ++-- .../library-tests/Encryption/insecure.expected | 18 ++++++++++++------ .../library-tests/Encryption/secure.expected | 7 +++++-- .../tests/BrokenCryptoAlgorithm.expected | 12 ++++++++++++ .../security/CWE-327/semmle/tests/Test.java | 14 ++++++++++++++ 9 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 java/ql/lib/change-notes/2026-11-24-encryption-nist-800-131ar2.md diff --git a/java/ql/lib/change-notes/2026-11-24-encryption-nist-800-131ar2.md b/java/ql/lib/change-notes/2026-11-24-encryption-nist-800-131ar2.md new file mode 100644 index 000000000000..f9f16902391d --- /dev/null +++ b/java/ql/lib/change-notes/2026-11-24-encryption-nist-800-131ar2.md @@ -0,0 +1,5 @@ +--- +category: minorAnalysis +--- +* Updated the `java/weak-cryptographic-algorithm` query in line with NIST SP 800-131A Rev. 2 to report `SKIPJACK` (`Skipjack`) as insecure and to report Triple DES (`DESede`, `DESedeWrap`, `TripleDES`, `3DES`) with a dedicated Triple DES explanation rather than the single-DES message, including uppercase and lowercase variants. +* Updated the `java/potentially-weak-cryptographic-algorithm` query to recognize `ChaCha20`, `ChaCha20-Poly1305`, and `ChaCha20Poly1305` as secure algorithms, removing false positives. diff --git a/java/ql/lib/semmle/code/java/security/Encryption.qll b/java/ql/lib/semmle/code/java/security/Encryption.qll index 24fd949b5222..804a52df4d8d 100644 --- a/java/ql/lib/semmle/code/java/security/Encryption.qll +++ b/java/ql/lib/semmle/code/java/security/Encryption.qll @@ -208,10 +208,20 @@ private string algorithmRegex(string algorithmString) { * `reason` explains why it is insecure. */ predicate insecureAlgorithm(string name, string reason) { - name = "DES" and + // Exclude 3DES variants (such as TripleDES, 3DES, and DESede), which are handled separately below. + name = "(?
  • NIST, FIPS 140 Annex a: Approved Security Functions.
  • -
  • NIST, SP 800-131A: +
  • NIST, SP 800-131A: Transitions: Recommendation for Transitioning the Use of Cryptographic Algorithms and Key Lengths.
  • diff --git a/java/ql/test/library-tests/Encryption/Test.java b/java/ql/test/library-tests/Encryption/Test.java index 91bc293c9640..cbbd5c885672 100644 --- a/java/ql/test/library-tests/Encryption/Test.java +++ b/java/ql/test/library-tests/Encryption/Test.java @@ -11,6 +11,12 @@ class Test { "des_function", "function_using_des", "EncryptWithDES", + "DESede", + "DESedeWrap", + "TripleDES", + "3DES", + "SKIPJACK", + "Skipjack", "RC2", "RC4", "ARCFOUR", @@ -21,6 +27,9 @@ class Test { List goodStrings = Arrays.asList( "AES", "AES_function", + "ChaCha20", + "ChaCha20-Poly1305", + "ChaCha20Poly1305", // false negative - can't think of a good way to detect this without // catching things we shouldn't "AESEncryption"); diff --git a/java/ql/test/library-tests/Encryption/cryptoalgospec.expected b/java/ql/test/library-tests/Encryption/cryptoalgospec.expected index ab6bb4081bbd..486ed8b1102b 100644 --- a/java/ql/test/library-tests/Encryption/cryptoalgospec.expected +++ b/java/ql/test/library-tests/Encryption/cryptoalgospec.expected @@ -1,2 +1,2 @@ -| Test.java:41:4:41:17 | super(...) | Test.java:41:10:41:15 | "some" | -| Test.java:45:3:45:38 | getInstance(...) | Test.java:45:29:45:37 | "another" | +| Test.java:50:4:50:17 | super(...) | Test.java:50:10:50:15 | "some" | +| Test.java:54:3:54:38 | getInstance(...) | Test.java:54:29:54:37 | "another" | diff --git a/java/ql/test/library-tests/Encryption/insecure.expected b/java/ql/test/library-tests/Encryption/insecure.expected index eda453984376..87350327986d 100644 --- a/java/ql/test/library-tests/Encryption/insecure.expected +++ b/java/ql/test/library-tests/Encryption/insecure.expected @@ -3,9 +3,15 @@ | Test.java:11:4:11:17 | "des_function" | It has a short key length of 56 bits, making it vulnerable to brute-force attacks. Consider using AES instead. | | Test.java:12:4:12:23 | "function_using_des" | It has a short key length of 56 bits, making it vulnerable to brute-force attacks. Consider using AES instead. | | Test.java:13:4:13:19 | "EncryptWithDES" | It has a short key length of 56 bits, making it vulnerable to brute-force attacks. Consider using AES instead. | -| Test.java:14:4:14:8 | "RC2" | It is vulnerable to related-key attacks. Consider using AES instead. | -| Test.java:15:4:15:8 | "RC4" | It has multiple vulnerabilities, including biases in its output and susceptibility to several attacks. Consider using AES instead. | -| Test.java:16:4:16:12 | "ARCFOUR" | It has multiple vulnerabilities, including biases in its output and susceptibility to several attacks. Consider using AES instead. | -| Test.java:17:4:17:8 | "RC5" | It is vulnerable to differential and related-key attacks. Consider using AES instead. | -| Test.java:18:4:18:22 | "AES/ECB/NoPadding" | ECB mode, as in AES/ECB/NoPadding for example, is vulnerable to replay and other attacks. Consider using GCM instead. | -| Test.java:19:4:19:25 | "AES/CBC/PKCS5Padding" | CBC mode with PKCS#5 or PKCS#7 padding is vulnerable to padding oracle attacks. Consider using GCM instead. | +| Test.java:14:4:14:11 | "DESede" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:15:4:15:15 | "DESedeWrap" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:16:4:16:14 | "TripleDES" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:17:4:17:9 | "3DES" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:18:4:18:13 | "SKIPJACK" | It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:19:4:19:13 | "Skipjack" | It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:20:4:20:8 | "RC2" | It is vulnerable to related-key attacks. Consider using AES instead. | +| Test.java:21:4:21:8 | "RC4" | It has multiple vulnerabilities, including biases in its output and susceptibility to several attacks. Consider using AES instead. | +| Test.java:22:4:22:12 | "ARCFOUR" | It has multiple vulnerabilities, including biases in its output and susceptibility to several attacks. Consider using AES instead. | +| Test.java:23:4:23:8 | "RC5" | It is vulnerable to differential and related-key attacks. Consider using AES instead. | +| Test.java:24:4:24:22 | "AES/ECB/NoPadding" | ECB mode, as in AES/ECB/NoPadding for example, is vulnerable to replay and other attacks. Consider using GCM instead. | +| Test.java:25:4:25:25 | "AES/CBC/PKCS5Padding" | CBC mode with PKCS#5 or PKCS#7 padding is vulnerable to padding oracle attacks. Consider using GCM instead. | diff --git a/java/ql/test/library-tests/Encryption/secure.expected b/java/ql/test/library-tests/Encryption/secure.expected index 18291dd062a8..6362acd0787d 100644 --- a/java/ql/test/library-tests/Encryption/secure.expected +++ b/java/ql/test/library-tests/Encryption/secure.expected @@ -1,2 +1,5 @@ -| Test.java:22:4:22:8 | "AES" | -| Test.java:23:4:23:17 | "AES_function" | +| Test.java:28:4:28:8 | "AES" | +| Test.java:29:4:29:17 | "AES_function" | +| Test.java:30:4:30:13 | "ChaCha20" | +| Test.java:31:4:31:22 | "ChaCha20-Poly1305" | +| Test.java:32:4:32:21 | "ChaCha20Poly1305" | diff --git a/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.expected b/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.expected index 7780618a0bec..70a6f3f13e78 100644 --- a/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.expected +++ b/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.expected @@ -5,6 +5,12 @@ | Test.java:47:14:47:55 | getInstance(...) | Test.java:47:33:47:54 | "AES/CBC/PKCS5PADDING" | Test.java:47:33:47:54 | "AES/CBC/PKCS5PADDING" | Cryptographic algorithm $@ is insecure. CBC mode with PKCS#5 or PKCS#7 padding is vulnerable to padding oracle attacks. Consider using GCM instead. | Test.java:47:33:47:54 | "AES/CBC/PKCS5PADDING" | AES/CBC/PKCS5PADDING | | Test.java:48:14:48:55 | getInstance(...) | Test.java:48:33:48:54 | "aes/cbc/pkcs5padding" | Test.java:48:33:48:54 | "aes/cbc/pkcs5padding" | Cryptographic algorithm $@ is insecure. CBC mode with PKCS#5 or PKCS#7 padding is vulnerable to padding oracle attacks. Consider using GCM instead. | Test.java:48:33:48:54 | "aes/cbc/pkcs5padding" | aes/cbc/pkcs5padding | | Test.java:49:14:49:55 | getInstance(...) | Test.java:49:33:49:54 | "AES/cbc/Pkcs5Padding" | Test.java:49:33:49:54 | "AES/cbc/Pkcs5Padding" | Cryptographic algorithm $@ is insecure. CBC mode with PKCS#5 or PKCS#7 padding is vulnerable to padding oracle attacks. Consider using GCM instead. | Test.java:49:33:49:54 | "AES/cbc/Pkcs5Padding" | AES/cbc/Pkcs5Padding | +| Test.java:53:14:53:58 | getInstance(...) | Test.java:53:33:53:57 | "DESede/CBC/PKCS5Padding" | Test.java:53:33:53:57 | "DESede/CBC/PKCS5Padding" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:53:33:53:57 | "DESede/CBC/PKCS5Padding" | DESede/CBC/PKCS5Padding | +| Test.java:54:14:54:41 | getInstance(...) | Test.java:54:33:54:40 | "DESEDE" | Test.java:54:33:54:40 | "DESEDE" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:54:33:54:40 | "DESEDE" | DESEDE | +| Test.java:55:14:55:44 | getInstance(...) | Test.java:55:33:55:43 | "TripleDES" | Test.java:55:33:55:43 | "TripleDES" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:55:33:55:43 | "TripleDES" | TripleDES | +| Test.java:56:14:56:39 | getInstance(...) | Test.java:56:33:56:38 | "3DES" | Test.java:56:33:56:38 | "3DES" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:56:33:56:38 | "3DES" | 3DES | +| Test.java:57:14:57:43 | getInstance(...) | Test.java:57:33:57:42 | "SKIPJACK" | Test.java:57:33:57:42 | "SKIPJACK" | Cryptographic algorithm $@ is insecure. It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:57:33:57:42 | "SKIPJACK" | SKIPJACK | +| Test.java:58:14:58:43 | getInstance(...) | Test.java:58:33:58:42 | "Skipjack" | Test.java:58:33:58:42 | "Skipjack" | Cryptographic algorithm $@ is insecure. It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:58:33:58:42 | "Skipjack" | Skipjack | edges nodes | Test.java:19:45:19:49 | "DES" | semmle.label | "DES" | @@ -13,4 +19,10 @@ nodes | Test.java:47:33:47:54 | "AES/CBC/PKCS5PADDING" | semmle.label | "AES/CBC/PKCS5PADDING" | | Test.java:48:33:48:54 | "aes/cbc/pkcs5padding" | semmle.label | "aes/cbc/pkcs5padding" | | Test.java:49:33:49:54 | "AES/cbc/Pkcs5Padding" | semmle.label | "AES/cbc/Pkcs5Padding" | +| Test.java:53:33:53:57 | "DESede/CBC/PKCS5Padding" | semmle.label | "DESede/CBC/PKCS5Padding" | +| Test.java:54:33:54:40 | "DESEDE" | semmle.label | "DESEDE" | +| Test.java:55:33:55:43 | "TripleDES" | semmle.label | "TripleDES" | +| Test.java:56:33:56:38 | "3DES" | semmle.label | "3DES" | +| Test.java:57:33:57:42 | "SKIPJACK" | semmle.label | "SKIPJACK" | +| Test.java:58:33:58:42 | "Skipjack" | semmle.label | "Skipjack" | subpaths diff --git a/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java index d4809693d378..43fa96e15e3b 100644 --- a/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java @@ -48,6 +48,20 @@ public void test() { cipher = Cipher.getInstance("aes/cbc/pkcs5padding"); // $ Alert[java/weak-cryptographic-algorithm] cipher = Cipher.getInstance("AES/cbc/Pkcs5Padding"); // $ Alert[java/weak-cryptographic-algorithm] } + { + // BAD: Triple DES (3TDEA) and Skipjack are disallowed by NIST SP 800-131A Rev. 2 + cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("DESEDE"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("TripleDES"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("3DES"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("SKIPJACK"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("Skipjack"); // $ Alert[java/weak-cryptographic-algorithm] + } + // GOOD: ChaCha20 and ChaCha20-Poly1305 are strong modern algorithms + keyGenerator = KeyGenerator.getInstance("ChaCha20"); + cipher = Cipher.getInstance("ChaCha20-Poly1305"); + cipher = Cipher.getInstance("ChaCha20Poly1305"); + // GOOD: ECIES is a strong algorithm cipher = Cipher.getInstance("ECIES"); cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); From 7d58eb10ccff0529580e5ed68ed8e37fe0818512 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Tue, 24 Nov 2026 14:42:56 +0000 Subject: [PATCH 2/2] Java: Preserve legacy Triple DES algorithm alerts Recognize case-insensitive PBEWithSHA1AndDESede aliases and the RFC3211 wrapping suffix. Add regression tests ensuring each name has exactly one Triple DES explanation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../semmle/code/java/security/Encryption.qll | 6 +++- .../test/library-tests/Encryption/Test.java | 6 ++++ .../Encryption/cryptoalgospec.expected | 4 +-- .../Encryption/insecure.expected | 26 ++++++++++------- .../library-tests/Encryption/secure.expected | 10 +++---- .../tests/BrokenCryptoAlgorithm.expected | 28 +++++++++++++------ .../security/CWE-327/semmle/tests/Test.java | 6 ++++ 7 files changed, 60 insertions(+), 26 deletions(-) diff --git a/java/ql/lib/semmle/code/java/security/Encryption.qll b/java/ql/lib/semmle/code/java/security/Encryption.qll index 804a52df4d8d..f1f2b55d95ed 100644 --- a/java/ql/lib/semmle/code/java/security/Encryption.qll +++ b/java/ql/lib/semmle/code/java/security/Encryption.qll @@ -214,7 +214,11 @@ predicate insecureAlgorithm(string name, string reason) { "It has a short key length of 56 bits, making it vulnerable to brute-force attacks. Consider using AES instead." or // 3TDEA (Triple DES) has different names across JCA, JSSE, and Bouncy Castle. - name = ["DES[-_]?ede(Wrap)?", "Triple[-_]?DES", "3[-_]?DES", "DES[-_]?3"] and + name = + [ + "DES[-_]?ede((RFC3211)?Wrap)?", "(?i)PBEWithSHA1AndDESede", "Triple[-_]?DES", "3[-_]?DES", + "DES[-_]?3" + ] and reason = "It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead." or diff --git a/java/ql/test/library-tests/Encryption/Test.java b/java/ql/test/library-tests/Encryption/Test.java index cbbd5c885672..ca79a3472816 100644 --- a/java/ql/test/library-tests/Encryption/Test.java +++ b/java/ql/test/library-tests/Encryption/Test.java @@ -13,6 +13,12 @@ class Test { "EncryptWithDES", "DESede", "DESedeWrap", + "DESedeRFC3211Wrap", + "DESEDERFC3211WRAP", + "desederfc3211wrap", + "PBEWithSHA1AndDESedE", + "PBEWITHSHA1ANDDESEDE", + "pbewithsha1anddesede", "TripleDES", "3DES", "SKIPJACK", diff --git a/java/ql/test/library-tests/Encryption/cryptoalgospec.expected b/java/ql/test/library-tests/Encryption/cryptoalgospec.expected index 486ed8b1102b..59368e5dd945 100644 --- a/java/ql/test/library-tests/Encryption/cryptoalgospec.expected +++ b/java/ql/test/library-tests/Encryption/cryptoalgospec.expected @@ -1,2 +1,2 @@ -| Test.java:50:4:50:17 | super(...) | Test.java:50:10:50:15 | "some" | -| Test.java:54:3:54:38 | getInstance(...) | Test.java:54:29:54:37 | "another" | +| Test.java:56:4:56:17 | super(...) | Test.java:56:10:56:15 | "some" | +| Test.java:60:3:60:38 | getInstance(...) | Test.java:60:29:60:37 | "another" | diff --git a/java/ql/test/library-tests/Encryption/insecure.expected b/java/ql/test/library-tests/Encryption/insecure.expected index 87350327986d..8c98d7f19959 100644 --- a/java/ql/test/library-tests/Encryption/insecure.expected +++ b/java/ql/test/library-tests/Encryption/insecure.expected @@ -5,13 +5,19 @@ | Test.java:13:4:13:19 | "EncryptWithDES" | It has a short key length of 56 bits, making it vulnerable to brute-force attacks. Consider using AES instead. | | Test.java:14:4:14:11 | "DESede" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | | Test.java:15:4:15:15 | "DESedeWrap" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | -| Test.java:16:4:16:14 | "TripleDES" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | -| Test.java:17:4:17:9 | "3DES" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | -| Test.java:18:4:18:13 | "SKIPJACK" | It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | -| Test.java:19:4:19:13 | "Skipjack" | It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | -| Test.java:20:4:20:8 | "RC2" | It is vulnerable to related-key attacks. Consider using AES instead. | -| Test.java:21:4:21:8 | "RC4" | It has multiple vulnerabilities, including biases in its output and susceptibility to several attacks. Consider using AES instead. | -| Test.java:22:4:22:12 | "ARCFOUR" | It has multiple vulnerabilities, including biases in its output and susceptibility to several attacks. Consider using AES instead. | -| Test.java:23:4:23:8 | "RC5" | It is vulnerable to differential and related-key attacks. Consider using AES instead. | -| Test.java:24:4:24:22 | "AES/ECB/NoPadding" | ECB mode, as in AES/ECB/NoPadding for example, is vulnerable to replay and other attacks. Consider using GCM instead. | -| Test.java:25:4:25:25 | "AES/CBC/PKCS5Padding" | CBC mode with PKCS#5 or PKCS#7 padding is vulnerable to padding oracle attacks. Consider using GCM instead. | +| Test.java:16:4:16:22 | "DESedeRFC3211Wrap" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:17:4:17:22 | "DESEDERFC3211WRAP" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:18:4:18:22 | "desederfc3211wrap" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:19:4:19:25 | "PBEWithSHA1AndDESedE" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:20:4:20:25 | "PBEWITHSHA1ANDDESEDE" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:21:4:21:25 | "pbewithsha1anddesede" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:22:4:22:14 | "TripleDES" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:23:4:23:9 | "3DES" | It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:24:4:24:13 | "SKIPJACK" | It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:25:4:25:13 | "Skipjack" | It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | +| Test.java:26:4:26:8 | "RC2" | It is vulnerable to related-key attacks. Consider using AES instead. | +| Test.java:27:4:27:8 | "RC4" | It has multiple vulnerabilities, including biases in its output and susceptibility to several attacks. Consider using AES instead. | +| Test.java:28:4:28:12 | "ARCFOUR" | It has multiple vulnerabilities, including biases in its output and susceptibility to several attacks. Consider using AES instead. | +| Test.java:29:4:29:8 | "RC5" | It is vulnerable to differential and related-key attacks. Consider using AES instead. | +| Test.java:30:4:30:22 | "AES/ECB/NoPadding" | ECB mode, as in AES/ECB/NoPadding for example, is vulnerable to replay and other attacks. Consider using GCM instead. | +| Test.java:31:4:31:25 | "AES/CBC/PKCS5Padding" | CBC mode with PKCS#5 or PKCS#7 padding is vulnerable to padding oracle attacks. Consider using GCM instead. | diff --git a/java/ql/test/library-tests/Encryption/secure.expected b/java/ql/test/library-tests/Encryption/secure.expected index 6362acd0787d..1dbf16c51fe5 100644 --- a/java/ql/test/library-tests/Encryption/secure.expected +++ b/java/ql/test/library-tests/Encryption/secure.expected @@ -1,5 +1,5 @@ -| Test.java:28:4:28:8 | "AES" | -| Test.java:29:4:29:17 | "AES_function" | -| Test.java:30:4:30:13 | "ChaCha20" | -| Test.java:31:4:31:22 | "ChaCha20-Poly1305" | -| Test.java:32:4:32:21 | "ChaCha20Poly1305" | +| Test.java:34:4:34:8 | "AES" | +| Test.java:35:4:35:17 | "AES_function" | +| Test.java:36:4:36:13 | "ChaCha20" | +| Test.java:37:4:37:22 | "ChaCha20-Poly1305" | +| Test.java:38:4:38:21 | "ChaCha20Poly1305" | diff --git a/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.expected b/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.expected index 70a6f3f13e78..c2817753eec6 100644 --- a/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.expected +++ b/java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.expected @@ -7,10 +7,16 @@ | Test.java:49:14:49:55 | getInstance(...) | Test.java:49:33:49:54 | "AES/cbc/Pkcs5Padding" | Test.java:49:33:49:54 | "AES/cbc/Pkcs5Padding" | Cryptographic algorithm $@ is insecure. CBC mode with PKCS#5 or PKCS#7 padding is vulnerable to padding oracle attacks. Consider using GCM instead. | Test.java:49:33:49:54 | "AES/cbc/Pkcs5Padding" | AES/cbc/Pkcs5Padding | | Test.java:53:14:53:58 | getInstance(...) | Test.java:53:33:53:57 | "DESede/CBC/PKCS5Padding" | Test.java:53:33:53:57 | "DESede/CBC/PKCS5Padding" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:53:33:53:57 | "DESede/CBC/PKCS5Padding" | DESede/CBC/PKCS5Padding | | Test.java:54:14:54:41 | getInstance(...) | Test.java:54:33:54:40 | "DESEDE" | Test.java:54:33:54:40 | "DESEDE" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:54:33:54:40 | "DESEDE" | DESEDE | -| Test.java:55:14:55:44 | getInstance(...) | Test.java:55:33:55:43 | "TripleDES" | Test.java:55:33:55:43 | "TripleDES" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:55:33:55:43 | "TripleDES" | TripleDES | -| Test.java:56:14:56:39 | getInstance(...) | Test.java:56:33:56:38 | "3DES" | Test.java:56:33:56:38 | "3DES" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:56:33:56:38 | "3DES" | 3DES | -| Test.java:57:14:57:43 | getInstance(...) | Test.java:57:33:57:42 | "SKIPJACK" | Test.java:57:33:57:42 | "SKIPJACK" | Cryptographic algorithm $@ is insecure. It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:57:33:57:42 | "SKIPJACK" | SKIPJACK | -| Test.java:58:14:58:43 | getInstance(...) | Test.java:58:33:58:42 | "Skipjack" | Test.java:58:33:58:42 | "Skipjack" | Cryptographic algorithm $@ is insecure. It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:58:33:58:42 | "Skipjack" | Skipjack | +| Test.java:55:14:55:52 | getInstance(...) | Test.java:55:33:55:51 | "DESedeRFC3211Wrap" | Test.java:55:33:55:51 | "DESedeRFC3211Wrap" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:55:33:55:51 | "DESedeRFC3211Wrap" | DESedeRFC3211Wrap | +| Test.java:56:14:56:52 | getInstance(...) | Test.java:56:33:56:51 | "DESEDERFC3211WRAP" | Test.java:56:33:56:51 | "DESEDERFC3211WRAP" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:56:33:56:51 | "DESEDERFC3211WRAP" | DESEDERFC3211WRAP | +| Test.java:57:14:57:52 | getInstance(...) | Test.java:57:33:57:51 | "desederfc3211wrap" | Test.java:57:33:57:51 | "desederfc3211wrap" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:57:33:57:51 | "desederfc3211wrap" | desederfc3211wrap | +| Test.java:58:14:58:55 | getInstance(...) | Test.java:58:33:58:54 | "PBEWithSHA1AndDESedE" | Test.java:58:33:58:54 | "PBEWithSHA1AndDESedE" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:58:33:58:54 | "PBEWithSHA1AndDESedE" | PBEWithSHA1AndDESedE | +| Test.java:59:14:59:55 | getInstance(...) | Test.java:59:33:59:54 | "PBEWITHSHA1ANDDESEDE" | Test.java:59:33:59:54 | "PBEWITHSHA1ANDDESEDE" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:59:33:59:54 | "PBEWITHSHA1ANDDESEDE" | PBEWITHSHA1ANDDESEDE | +| Test.java:60:14:60:55 | getInstance(...) | Test.java:60:33:60:54 | "pbewithsha1anddesede" | Test.java:60:33:60:54 | "pbewithsha1anddesede" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:60:33:60:54 | "pbewithsha1anddesede" | pbewithsha1anddesede | +| Test.java:61:14:61:44 | getInstance(...) | Test.java:61:33:61:43 | "TripleDES" | Test.java:61:33:61:43 | "TripleDES" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:61:33:61:43 | "TripleDES" | TripleDES | +| Test.java:62:14:62:39 | getInstance(...) | Test.java:62:33:62:38 | "3DES" | Test.java:62:33:62:38 | "3DES" | Cryptographic algorithm $@ is insecure. It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:62:33:62:38 | "3DES" | 3DES | +| Test.java:63:14:63:43 | getInstance(...) | Test.java:63:33:63:42 | "SKIPJACK" | Test.java:63:33:63:42 | "SKIPJACK" | Cryptographic algorithm $@ is insecure. It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:63:33:63:42 | "SKIPJACK" | SKIPJACK | +| Test.java:64:14:64:43 | getInstance(...) | Test.java:64:33:64:42 | "Skipjack" | Test.java:64:33:64:42 | "Skipjack" | Cryptographic algorithm $@ is insecure. It has a short key length of 80 bits, making it vulnerable to brute-force attacks, and has been disallowed by NIST. Consider using AES instead. | Test.java:64:33:64:42 | "Skipjack" | Skipjack | edges nodes | Test.java:19:45:19:49 | "DES" | semmle.label | "DES" | @@ -21,8 +27,14 @@ nodes | Test.java:49:33:49:54 | "AES/cbc/Pkcs5Padding" | semmle.label | "AES/cbc/Pkcs5Padding" | | Test.java:53:33:53:57 | "DESede/CBC/PKCS5Padding" | semmle.label | "DESede/CBC/PKCS5Padding" | | Test.java:54:33:54:40 | "DESEDE" | semmle.label | "DESEDE" | -| Test.java:55:33:55:43 | "TripleDES" | semmle.label | "TripleDES" | -| Test.java:56:33:56:38 | "3DES" | semmle.label | "3DES" | -| Test.java:57:33:57:42 | "SKIPJACK" | semmle.label | "SKIPJACK" | -| Test.java:58:33:58:42 | "Skipjack" | semmle.label | "Skipjack" | +| Test.java:55:33:55:51 | "DESedeRFC3211Wrap" | semmle.label | "DESedeRFC3211Wrap" | +| Test.java:56:33:56:51 | "DESEDERFC3211WRAP" | semmle.label | "DESEDERFC3211WRAP" | +| Test.java:57:33:57:51 | "desederfc3211wrap" | semmle.label | "desederfc3211wrap" | +| Test.java:58:33:58:54 | "PBEWithSHA1AndDESedE" | semmle.label | "PBEWithSHA1AndDESedE" | +| Test.java:59:33:59:54 | "PBEWITHSHA1ANDDESEDE" | semmle.label | "PBEWITHSHA1ANDDESEDE" | +| Test.java:60:33:60:54 | "pbewithsha1anddesede" | semmle.label | "pbewithsha1anddesede" | +| Test.java:61:33:61:43 | "TripleDES" | semmle.label | "TripleDES" | +| Test.java:62:33:62:38 | "3DES" | semmle.label | "3DES" | +| Test.java:63:33:63:42 | "SKIPJACK" | semmle.label | "SKIPJACK" | +| Test.java:64:33:64:42 | "Skipjack" | semmle.label | "Skipjack" | subpaths diff --git a/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java b/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java index 43fa96e15e3b..1ec28ef22817 100644 --- a/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java +++ b/java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java @@ -52,6 +52,12 @@ public void test() { // BAD: Triple DES (3TDEA) and Skipjack are disallowed by NIST SP 800-131A Rev. 2 cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); // $ Alert[java/weak-cryptographic-algorithm] cipher = Cipher.getInstance("DESEDE"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("DESedeRFC3211Wrap"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("DESEDERFC3211WRAP"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("desederfc3211wrap"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("PBEWithSHA1AndDESedE"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("PBEWITHSHA1ANDDESEDE"); // $ Alert[java/weak-cryptographic-algorithm] + cipher = Cipher.getInstance("pbewithsha1anddesede"); // $ Alert[java/weak-cryptographic-algorithm] cipher = Cipher.getInstance("TripleDES"); // $ Alert[java/weak-cryptographic-algorithm] cipher = Cipher.getInstance("3DES"); // $ Alert[java/weak-cryptographic-algorithm] cipher = Cipher.getInstance("SKIPJACK"); // $ Alert[java/weak-cryptographic-algorithm]