Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d7facb4

Browse files
committed
Add missing broken crypto algorithms
1 parent 9ff6d68 commit d7facb4

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

java/ql/src/Security/CWE/CWE-327/BrokenCryptoAlgorithm.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ data.</p>
1212
</overview>
1313
<recommendation>
1414

15-
<p>Ensure that you use a strong, modern cryptographic algorithm. Use at least AES-128 or RSA-2048.</p>
15+
<p>Ensure 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 reply attacks.</p>
1616

1717
</recommendation>
1818
<example>

java/ql/src/semmle/code/java/security/Encryption.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ string getAnInsecureAlgorithmName() {
9797
result = "RC2" or
9898
result = "RC4" or
9999
result = "RC5" or
100-
result = "ARCFOUR" // a variant of RC4
100+
result = "ARCFOUR" or // a variant of RC4
101+
result = "ECB" or // encryption mode ECB like AES/ECB/NoPadding is vulnerable to replay attacks
102+
result = "AES/CBC/PKCS5Padding" // CBC mode of operation with PKCS#5 (or PKCS#7) padding is vulnerable to padding oracle attacks
101103
}
102104

103105
/**

java/ql/test/library-tests/Encryption/Test.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ class Test {
1010
"des",
1111
"des_function",
1212
"function_using_des",
13-
"EncryptWithDES");
13+
"EncryptWithDES",
14+
"AES/ECB/NoPadding",
15+
"AES/CBC/PKCS5Padding");
16+
1417

1518
List<String> goodStrings = Arrays.asList(
1619
"AES",

java/ql/test/library-tests/Encryption/insecure.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
| Test.java:11:4:11:17 | "des_function" |
44
| Test.java:12:4:12:23 | "function_using_des" |
55
| Test.java:13:4:13:19 | "EncryptWithDES" |
6+
| Test.java:14:4:14:22 | "AES/ECB/NoPadding" |
7+
| Test.java:15:4:15:25 | "AES/CBC/PKCS5Padding" |

0 commit comments

Comments
 (0)