/
jdbc-sqli.yaml
62 lines (62 loc) · 1.74 KB
/
jdbc-sqli.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
rules:
- id: jdbc-sqli
message: >-
Detected a formatted string in a SQL statement. This could lead to SQL
injection if variables in the SQL statement are not properly sanitized.
Use a prepared statements (java.sql.PreparedStatement) instead. You
can obtain a PreparedStatement using 'connection.prepareStatement'.
languages: [java]
severity: WARNING
patterns:
- pattern-either:
- patterns:
- pattern-either:
- pattern-inside: |
String $SQL = $X + $Y;
...
- pattern-inside: |
String $SQL = String.format(...);
...
- pattern-inside: |
$VAL $FUNC(...,String $SQL,...) {
...
}
- pattern-not-inside: |
String $SQL = "..." + "...";
...
- pattern: $S.$METHOD($SQL,...)
- pattern: |
$S.$METHOD(String.format(...),...);
- pattern: |
$S.$METHOD($X + $Y,...);
- pattern-either:
- pattern-inside: |
java.sql.Statement $S = ...;
...
- pattern-inside: |
$TYPE $FUNC(...,java.sql.Statement $S,...) {
...
}
- pattern-not: |
$S.$METHOD("..." + "...",...);
- metavariable-regex:
metavariable: $METHOD
regex: ^(executeQuery|execute|executeUpdate|executeLargeUpdate|addBatch|nativeSQL)$
metadata:
cwe:
- "CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')"
category: security
technology:
- jdbc
owasp:
- A01:2017 - Injection
- A03:2021 - Injection
references:
- https://owasp.org/Top10/A03_2021-Injection
cwe2022-top25: true
cwe2021-top25: true
subcategory:
- audit
likelihood: LOW
impact: HIGH
confidence: LOW