Repository navigation
Expand file tree
/
Copy pathjava-web-taint.yaml
More file actions
231 lines (217 loc) · 8.79 KB
/
Copy pathjava-web-taint.yaml
File metadata and controls
231 lines (217 loc) · 8.79 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# ============================================================================
# Robusta Studio - Java Web Application Security Rules
# Copyright (c) 2026 Robusta Studio. All rights reserved.
#
# Taint-tracking rules for Java Servlet, Spring Boot, and JEE applications.
# Derived from 60,517 real-world CVE and HackerOne vulnerability records.
# Dataset: PentesterFlow/OffsecCyber
#
# Usage: semgrep --config java-web-taint.yaml /path/to/project
# ============================================================================
rules:
# -- CWE-89 | SQL Injection ------------------------------------------------
- id: robusta-java-sqli-taint
mode: taint
message: >
HTTP request parameter concatenated into SQL query via Statement.
Use PreparedStatement with ? placeholders and setString()/setInt().
metadata:
cwe: ["CWE-89"]
owasp: ["A03:2021 Injection"]
confidence: HIGH
impact: HIGH
author: Robusta Studio
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
severity: ERROR
languages: [java]
pattern-sources:
- patterns:
- pattern-either:
- pattern: (HttpServletRequest $REQ).getParameter(...)
- pattern: (HttpServletRequest $REQ).getParameterValues(...)
- pattern: (HttpServletRequest $REQ).getHeader(...)
- pattern: (HttpServletRequest $REQ).getQueryString()
- pattern: (HttpServletRequest $REQ).getPathInfo()
pattern-sinks:
- patterns:
- pattern-either:
- pattern: (Statement $S).executeQuery($Q)
- pattern: (Statement $S).execute($Q)
- pattern: (Statement $S).executeUpdate($Q)
- pattern: (JdbcTemplate $T).queryForList($Q, ...)
- pattern: (JdbcTemplate $T).queryForObject($Q, ...)
- pattern: (JdbcTemplate $T).query($Q, ...)
- pattern: (JdbcTemplate $T).update($Q, ...)
- focus-metavariable: $Q
pattern-sanitizers:
- patterns:
- pattern-either:
- pattern: Integer.parseInt(...)
- pattern: Long.parseLong(...)
- pattern: (PreparedStatement $PS).setString(...)
# -- CWE-78 | OS Command Injection -----------------------------------------
- id: robusta-java-cmdi-taint
mode: taint
message: >
HTTP input reaches Runtime.exec() or ProcessBuilder with shell invocation.
CVE-2019-0232: Tomcat CGI passes request args to Windows cmd.exe.
Use ProcessBuilder with explicit argument list (no shell).
metadata:
cwe: ["CWE-78"]
confidence: HIGH
impact: CRITICAL
author: Robusta Studio
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
references:
- https://nvd.nist.gov/vuln/detail/CVE-2019-0232
severity: ERROR
languages: [java]
pattern-sources:
- patterns:
- pattern-either:
- pattern: (HttpServletRequest $REQ).getParameter(...)
- pattern: (HttpServletRequest $REQ).getHeader(...)
- pattern: (HttpServletRequest $REQ).getPathInfo()
pattern-sinks:
- patterns:
- pattern-either:
- pattern: Runtime.getRuntime().exec($CMD)
- pattern: Runtime.getRuntime().exec($CMD, ...)
- pattern: new ProcessBuilder($CMD).start()
- pattern: new ProcessBuilder("sh", "-c", $CMD)
- pattern: new ProcessBuilder("cmd", "/c", $CMD)
- pattern: new ProcessBuilder(Arrays.asList("sh", "-c", $CMD))
- focus-metavariable: $CMD
pattern-sanitizers:
- patterns:
- pattern: Integer.parseInt(...)
# -- CWE-502 | Insecure Deserialization -------------------------------------
- id: robusta-java-deser-taint
mode: taint
message: >
HTTP/network data reaches ObjectInputStream without an ObjectInputFilter.
CVE-2025-53770: SharePoint deserialization RCE (actively exploited).
Use ObjectInputFilter (Java 9+) with class allowlist, or switch to JSON.
metadata:
cwe: ["CWE-502"]
owasp: ["A08:2021 Software and Data Integrity Failures"]
confidence: HIGH
impact: CRITICAL
author: Robusta Studio
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
references:
- https://nvd.nist.gov/vuln/detail/CVE-2025-53770
severity: ERROR
languages: [java]
pattern-sources:
- patterns:
- pattern-either:
- pattern: (HttpServletRequest $REQ).getInputStream()
- pattern: (HttpServletRequest $REQ).getReader()
- pattern: (Socket $S).getInputStream()
- pattern: (ServletRequest $REQ).getInputStream()
pattern-sinks:
- patterns:
- pattern-either:
- pattern: new ObjectInputStream($STREAM)
- pattern: (ObjectInputStream $OIS).readObject()
- pattern: (XMLDecoder $D).readObject()
- focus-metavariable: $STREAM
# -- CWE-611 | XML External Entity (XXE) -----------------------------------
- id: robusta-java-xxe-unsafe-factory
patterns:
- pattern: |
DocumentBuilderFactory $DBF = DocumentBuilderFactory.newInstance();
...
$DBF.newDocumentBuilder().parse($INPUT);
- pattern-not-inside: |
DocumentBuilderFactory $DBF = DocumentBuilderFactory.newInstance();
...
$DBF.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
...
message: >
DocumentBuilderFactory parses XML without disabling DOCTYPE declarations.
Enables XXE to read files, SSRF to internal hosts, or DoS (billion laughs).
Set setFeature("http://apache.org/xml/features/disallow-doctype-decl", true).
metadata:
cwe: ["CWE-611"]
owasp: ["A05:2021 Security Misconfiguration"]
confidence: HIGH
impact: HIGH
author: Robusta Studio
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
severity: ERROR
languages: [java]
- id: robusta-java-xxe-saxparser
patterns:
- pattern: |
SAXParserFactory $SPF = SAXParserFactory.newInstance();
...
$SPF.newSAXParser().parse($INPUT, ...);
- pattern-not-inside: |
SAXParserFactory $SPF = SAXParserFactory.newInstance();
...
$SPF.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
...
message: >
SAXParser without disallow-doctype-decl is vulnerable to XXE.
metadata:
cwe: ["CWE-611"]
confidence: HIGH
impact: HIGH
author: Robusta Studio
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
severity: ERROR
languages: [java]
# -- CWE-917 | Expression Language Injection -------------------------------
- id: robusta-java-el-injection-taint
mode: taint
message: >
User input evaluated as an Expression Language expression → RCE.
Use pre-compiled EL expressions or reject user input in EL context.
metadata:
cwe: ["CWE-917"]
confidence: HIGH
impact: CRITICAL
author: Robusta Studio
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
severity: ERROR
languages: [java]
pattern-sources:
- patterns:
- pattern-either:
- pattern: (HttpServletRequest $REQ).getParameter(...)
- pattern: (HttpServletRequest $REQ).getHeader(...)
pattern-sinks:
- patterns:
- pattern-either:
- pattern: $PARSER.parseExpression($EXPR)
- pattern: $FACTORY.createValueExpression($CTX, $EXPR, ...)
- pattern: $EVAL.evaluate($EXPR, ...)
- pattern: OgnlUtil.getValue($EXPR, ...)
- focus-metavariable: $EXPR
# -- CWE-90 | LDAP Injection -----------------------------------------------
- id: robusta-java-ldapi-taint
mode: taint
message: >
User input concatenated into LDAP search filter. Escape with
javax.naming.ldap filter encoding or use a parameterized filter builder.
metadata:
cwe: ["CWE-90"]
confidence: HIGH
impact: HIGH
author: Robusta Studio
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
severity: ERROR
languages: [java]
pattern-sources:
- patterns:
- pattern-either:
- pattern: (HttpServletRequest $REQ).getParameter(...)
pattern-sinks:
- patterns:
- pattern-either:
- pattern: (DirContext $CTX).search($BASE, $FILTER, ...)
- pattern: (InitialDirContext $CTX).search($BASE, $FILTER, ...)
- pattern: (LdapContext $CTX).search($BASE, $FILTER, ...)
- focus-metavariable: $FILTER