|
11 | 11 | */ |
12 | 12 |
|
13 | 13 | import java |
14 | | -import semmle.code.java.dataflow.TaintTracking |
15 | | -import semmle.code.java.dataflow.FlowSources |
16 | | -private import semmle.code.java.dataflow.ExternalFlow |
17 | | - |
18 | | -/** |
19 | | - * A message interpolator Type that perform Expression Language (EL) evaluations |
20 | | - */ |
21 | | -class ELMessageInterpolatorType extends RefType { |
22 | | - ELMessageInterpolatorType() { |
23 | | - this.getASourceSupertype*() |
24 | | - .hasQualifiedName("org.hibernate.validator.messageinterpolation", |
25 | | - ["ResourceBundleMessageInterpolator", "ValueFormatterMessageInterpolator"]) |
26 | | - } |
27 | | -} |
28 | | - |
29 | | -/** |
30 | | - * A method call that sets the application's default message interpolator. |
31 | | - */ |
32 | | -class SetMessageInterpolatorCall extends MethodAccess { |
33 | | - SetMessageInterpolatorCall() { |
34 | | - exists(Method m, RefType t | |
35 | | - this.getMethod() = m and |
36 | | - m.getDeclaringType().getASourceSupertype*() = t and |
37 | | - ( |
38 | | - t.hasQualifiedName("javax.validation", ["Configuration", "ValidatorContext"]) and |
39 | | - m.getName() = "messageInterpolator" |
40 | | - or |
41 | | - t.hasQualifiedName("org.springframework.validation.beanvalidation", |
42 | | - ["CustomValidatorBean", "LocalValidatorFactoryBean"]) and |
43 | | - m.getName() = "setMessageInterpolator" |
44 | | - ) |
45 | | - ) |
46 | | - } |
47 | | - |
48 | | - /** |
49 | | - * The message interpolator is likely to be safe, because it does not process Java Expression Language expressions. |
50 | | - */ |
51 | | - predicate isSafe() { not this.getAnArgument().getType() instanceof ELMessageInterpolatorType } |
52 | | -} |
53 | | - |
54 | | -/** |
55 | | - * Taint tracking BeanValidationConfiguration describing the flow of data from user input |
56 | | - * to the argument of a method that builds constraint error messages. |
57 | | - */ |
58 | | -module BeanValidationConfig implements DataFlow::ConfigSig { |
59 | | - predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } |
60 | | - |
61 | | - predicate isSink(DataFlow::Node sink) { sink instanceof BeanValidationSink } |
62 | | -} |
63 | | - |
64 | | -module BeanValidationFlow = TaintTracking::Global<BeanValidationConfig>; |
65 | | - |
| 14 | +import semmle.code.java.security.InsecureBeanValidationQuery |
66 | 15 | import BeanValidationFlow::PathGraph |
67 | 16 |
|
68 | | -/** |
69 | | - * A bean validation sink, such as method `buildConstraintViolationWithTemplate` |
70 | | - * declared on a subtype of `javax.validation.ConstraintValidatorContext`. |
71 | | - */ |
72 | | -private class BeanValidationSink extends DataFlow::Node { |
73 | | - BeanValidationSink() { sinkNode(this, "bean-validation") } |
74 | | -} |
75 | | - |
76 | 17 | from BeanValidationFlow::PathNode source, BeanValidationFlow::PathNode sink |
77 | 18 | where |
78 | 19 | ( |
|
0 commit comments