Skip to content

Commit 8678d5f

Browse files
committed
Java: Model untrusted user data types
Model the datatypes that may be populated on demand from request parameters.
1 parent 8bd5f74 commit 8678d5f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

java/ql/src/semmle/code/java/frameworks/spring/SpringController.qll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,27 @@ class SpringModelResponseType extends RefType {
295295
exists(SpringModel model | usesType(model.getATypeInModel(), this))
296296
}
297297
}
298+
299+
/**
300+
* A user data type which may be populated from a HTTP request.
301+
*
302+
* This includes types directly referred to as either @ModelAttribute or @RequestBody parameters,
303+
* or types which are referred to by those types.
304+
*/
305+
class SpringUntrustedDataType extends RefType {
306+
SpringUntrustedDataType() {
307+
exists(SpringRequestMappingParameter p |
308+
p.isModelAttribute()
309+
or
310+
p.getAnAnnotation().(SpringServletInputAnnotation).getType().hasName("RequestBody")
311+
|
312+
this.fromSource() and
313+
this = p.getType()
314+
)
315+
or
316+
exists(SpringUntrustedDataType mt |
317+
this = mt.getAField().getType() and
318+
this.fromSource()
319+
)
320+
}
321+
}

0 commit comments

Comments
 (0)