Skip to content

Commit fbcefd3

Browse files
committed
fix(java): match RSA prefix case-insensitively in RsaWithoutOaepQuery
1 parent 400d4c4 commit fbcefd3

4 files changed

Lines changed: 12 additions & 8 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
category: minorAnalysis
33
---
4-
* The `java/weak-cryptographic-algorithm` and `java/potentially-weak-cryptographic-algorithm` queries now match cryptographic algorithm names and modes case-insensitively (for example, `AES/CBC/PKCS5PADDING` and `AES/cbc/Pkcs5Padding`).
4+
* The `java/weak-cryptographic-algorithm`, `java/potentially-weak-cryptographic-algorithm`, and `java/rsa-without-oaep` queries now match cryptographic algorithm names and modes case-insensitively (for example, `AES/CBC/PKCS5PADDING` and `AES/cbc/Pkcs5Padding`).

‎java/ql/lib/semmle/code/java/security/RsaWithoutOaepQuery.qll‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import semmle.code.java.dataflow.DataFlow
1010
module RsaWithoutOaepConfig implements DataFlow::ConfigSig {
1111
predicate isSource(DataFlow::Node src) {
1212
exists(CompileTimeConstantExpr specExpr, string spec |
13-
specExpr.getStringValue() = spec and
13+
specExpr.getStringValue().toUpperCase() = spec and
1414
specExpr = src.asExpr() and
1515
spec.matches("RSA/%") and
1616
not spec.matches("%OAEP%")
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#select
22
| RsaWithoutOaepTest.java:5:44:5:62 | "RSA/ECB/NoPadding" | RsaWithoutOaepTest.java:5:44:5:62 | "RSA/ECB/NoPadding" | RsaWithoutOaepTest.java:5:44:5:62 | "RSA/ECB/NoPadding" | This specification is used to $@ without OAEP padding. | RsaWithoutOaepTest.java:5:44:5:62 | "RSA/ECB/NoPadding" | initialize an RSA cipher |
3-
| RsaWithoutOaepTest.java:15:32:15:50 | "RSA/ECB/NoPadding" : String | RsaWithoutOaepTest.java:15:32:15:50 | "RSA/ECB/NoPadding" : String | RsaWithoutOaepTest.java:11:35:11:38 | spec | This specification is used to $@ without OAEP padding. | RsaWithoutOaepTest.java:11:35:11:38 | spec | initialize an RSA cipher |
3+
| RsaWithoutOaepTest.java:6:49:6:67 | "rsa/ECB/NoPadding" | RsaWithoutOaepTest.java:6:49:6:67 | "rsa/ECB/NoPadding" | RsaWithoutOaepTest.java:6:49:6:67 | "rsa/ECB/NoPadding" | This specification is used to $@ without OAEP padding. | RsaWithoutOaepTest.java:6:49:6:67 | "rsa/ECB/NoPadding" | initialize an RSA cipher |
4+
| RsaWithoutOaepTest.java:17:32:17:50 | "RSA/ECB/NoPadding" : String | RsaWithoutOaepTest.java:17:32:17:50 | "RSA/ECB/NoPadding" : String | RsaWithoutOaepTest.java:13:35:13:38 | spec | This specification is used to $@ without OAEP padding. | RsaWithoutOaepTest.java:13:35:13:38 | spec | initialize an RSA cipher |
45
edges
5-
| RsaWithoutOaepTest.java:10:29:10:39 | spec : String | RsaWithoutOaepTest.java:11:35:11:38 | spec | provenance | |
6-
| RsaWithoutOaepTest.java:15:32:15:50 | "RSA/ECB/NoPadding" : String | RsaWithoutOaepTest.java:10:29:10:39 | spec : String | provenance | |
6+
| RsaWithoutOaepTest.java:12:29:12:39 | spec : String | RsaWithoutOaepTest.java:13:35:13:38 | spec | provenance | |
7+
| RsaWithoutOaepTest.java:17:32:17:50 | "RSA/ECB/NoPadding" : String | RsaWithoutOaepTest.java:12:29:12:39 | spec : String | provenance | |
78
nodes
89
| RsaWithoutOaepTest.java:5:44:5:62 | "RSA/ECB/NoPadding" | semmle.label | "RSA/ECB/NoPadding" |
9-
| RsaWithoutOaepTest.java:10:29:10:39 | spec : String | semmle.label | spec : String |
10-
| RsaWithoutOaepTest.java:11:35:11:38 | spec | semmle.label | spec |
11-
| RsaWithoutOaepTest.java:15:32:15:50 | "RSA/ECB/NoPadding" : String | semmle.label | "RSA/ECB/NoPadding" : String |
10+
| RsaWithoutOaepTest.java:6:49:6:67 | "rsa/ECB/NoPadding" | semmle.label | "rsa/ECB/NoPadding" |
11+
| RsaWithoutOaepTest.java:12:29:12:39 | spec : String | semmle.label | spec : String |
12+
| RsaWithoutOaepTest.java:13:35:13:38 | spec | semmle.label | spec |
13+
| RsaWithoutOaepTest.java:17:32:17:50 | "RSA/ECB/NoPadding" : String | semmle.label | "RSA/ECB/NoPadding" : String |
1214
subpaths

‎java/ql/test/query-tests/security/CWE-780/RsaWithoutOaepTest.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
class RsaWithoutOaep {
44
public void test() throws Exception {
55
Cipher rsaBad = Cipher.getInstance("RSA/ECB/NoPadding"); // $ Alert
6+
Cipher rsaBadLower = Cipher.getInstance("rsa/ECB/NoPadding"); // $ Alert
67

78
Cipher rsaGood = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding");
9+
Cipher rsaGoodLower = Cipher.getInstance("rsa/ecb/oaepwithsha-1andmgf1padding");
810
}
911

1012
public Cipher getCipher(String spec) throws Exception {

0 commit comments

Comments
 (0)