Repository navigation
Conversation
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>
|
QHelp previews: java/ql/src/Security/CWE/CWE-327/BrokenCryptoAlgorithm.qhelpUse of a broken or risky cryptographic algorithmUsing broken or weak cryptographic algorithms may compromise security guarantees such as confidentiality, integrity, and authenticity. Many cryptographic algorithms are known to be weak or flawed. The security guarantees of a system often rely on the underlying cryptography, so using a weak algorithm can have severe consequences. For example:
RecommendationEnsure that you use a strong, modern cryptographic algorithm. Use at least AES-128 or RSA-2048. Do not use the ECB encryption mode since it is vulnerable to replay and other attacks. ExampleThe following code shows an example of using a java // BAD: DES is a weak algorithm
Cipher des = Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
byte[] encrypted = cipher.doFinal(input.getBytes("UTF-8"));
// ...
// GOOD: AES is a strong algorithm
Cipher aes = Cipher.getInstance("AES");
// ...References
|
There was a problem hiding this comment.
🟡 Changes recommended
The new DES exclusions drop existing weak-algorithm alerts for PBEWithSHA1AndDESedE and DESedeRFC3211Wrap because neither matches the replacement aliases.
1 open issue
What changed in this PR
Updates Java cryptography analysis for NIST SP 800-131A Rev. 2 and recognizes ChaCha20 algorithms as secure.
Changes:
- Adds Triple DES and Skipjack detection, with dedicated explanations and guards against single-DES misclassification.
- Recognizes ChaCha20 and Poly1305 variants to reduce false positives.
- Adds regression tests, updates expected results and the NIST reference, and documents the analysis changes.
| File | Description |
|---|---|
java/ql/test/query-tests/security/CWE-327/semmle/tests/Test.java |
Adds weak-algorithm alerts and secure ChaCha20 cases. |
java/ql/test/query-tests/security/CWE-327/semmle/tests/BrokenCryptoAlgorithm.expected |
Records new Triple DES and Skipjack results. |
java/ql/test/library-tests/Encryption/Test.java |
Adds insecure aliases and secure algorithm strings. |
java/ql/test/library-tests/Encryption/secure.expected |
Records secure ChaCha20 recognition. |
java/ql/test/library-tests/Encryption/insecure.expected |
Records dedicated Triple DES and Skipjack explanations. |
java/ql/test/library-tests/Encryption/cryptoalgospec.expected |
Updates source locations after test additions. |
java/ql/src/Security/CWE/CWE-327/BrokenCryptoAlgorithm.qhelp |
Links to NIST Rev. 2 over HTTPS. |
java/ql/lib/semmle/code/java/security/Encryption.qll |
Updates insecure matching and secure algorithm recognition. |
java/ql/lib/change-notes/2026-11-24-encryption-nist-800-131ar2.md |
Documents changes to both cryptography queries. |
Review effort: Max (adaptive)
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>
There was a problem hiding this comment.
🟡 Changes recommended
Inconsistent regex scoping lets weak algorithms escape both detection queries, while a registered Triple DES cipher is unrecognized and the NIST guidance misrepresents permitted legacy operations.
3 open issues
1 resolved since last review
Review effort: Max (adaptive)
| // 3TDEA (Triple DES) has different names across JCA, JSSE, and Bouncy Castle. | ||
| name = | ||
| [ | ||
| "DES[-_]?ede((RFC3211)?Wrap)?", "(?i)PBEWithSHA1AndDESede", "Triple[-_]?DES", "3[-_]?DES", |
| name = | ||
| [ | ||
| "DES[-_]?ede((RFC3211)?Wrap)?", "(?i)PBEWithSHA1AndDESede", "Triple[-_]?DES", "3[-_]?DES", | ||
| "DES[-_]?3" |
| "It uses a 64-bit block size, making it vulnerable to birthday attacks, and has been disallowed by NIST. Consider using AES instead." | ||
| or | ||
| name = ["SKIPJACK", "Skipjack"] and | ||
| reason = | ||
| "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." |


Summary
Supersedes #13830 (originally contributed by @unprovable), updated for the current
Encryption.qlldesign now that NIST SP 800-131A Rev. 2's end-of-2023 deprecation of 3TDEA (Triple DES) is in effect.DESede,DESedeWrap,TripleDES,3DES,DES3) andSKIPJACK/SkipjacktoinsecureAlgorithmwith NIST SP 800-131A Rev. 2 explanations inEncryption.qll.DESwith negative lookbehinds/lookahead so 3DES strings (such as"DESede","DESedeWrap","TripleDES", and"3DES") are no longer matched by singleDESwith its 56-bit key-length message or reported twice, and all-uppercase/lowercase variants such as"DESEDE"are also detected.ChaCha20andChaCha20Poly1305(covering JCA standard"ChaCha20"and"ChaCha20-Poly1305"from JEP 329 as well as unhyphenated"ChaCha20Poly1305") togetASecureAlgorithmName()sojava/potentially-weak-cryptographic-algorithmno longer flags them.BrokenCryptoAlgorithm.qhelpto link to NIST SP 800-131A Rev. 2 over HTTPS.Evidence
codeql test run -j 0 java/ql/test/query-tests/security/CWE-327/semmle/tests java/ql/test/library-tests/Encryptionpasses all 5 tests (BrokenCryptoAlgorithm.qlref,MaybeBrokenCryptoAlgorithm.qlref,secure.ql,cryptoalgospec.ql,insecure.ql).