@@ -7,10 +7,12 @@ private import semmle.code.java.frameworks.spring.SpringExpression
7
7
private import semmle.code.java.security.SpelInjection
8
8
9
9
/**
10
+ * DEPRECATED: Use `SpelInjectionFlow` instead.
11
+ *
10
12
* A taint-tracking configuration for unsafe user input
11
13
* that is used to construct and evaluate a SpEL expression.
12
14
*/
13
- class SpelInjectionConfig extends TaintTracking:: Configuration {
15
+ deprecated class SpelInjectionConfig extends TaintTracking:: Configuration {
14
16
SpelInjectionConfig ( ) { this = "SpelInjectionConfig" }
15
17
16
18
override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
@@ -22,37 +24,52 @@ class SpelInjectionConfig extends TaintTracking::Configuration {
22
24
}
23
25
}
24
26
27
+ /**
28
+ * A taint-tracking configuration for unsafe user input
29
+ * that is used to construct and evaluate a SpEL expression.
30
+ */
31
+ private module SpelInjectionConfig implements DataFlow:: ConfigSig {
32
+ predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
33
+
34
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof SpelExpressionEvaluationSink }
35
+
36
+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
37
+ any ( SpelExpressionInjectionAdditionalTaintStep c ) .step ( node1 , node2 )
38
+ }
39
+ }
40
+
41
+ /** Tracks flow of unsafe user input that is used to construct and evaluate a SpEL expression. */
42
+ module SpelInjectionFlow = TaintTracking:: Make< SpelInjectionConfig > ;
43
+
25
44
/** Default sink for SpEL injection vulnerabilities. */
26
45
private class DefaultSpelExpressionEvaluationSink extends SpelExpressionEvaluationSink {
27
46
DefaultSpelExpressionEvaluationSink ( ) {
28
47
exists ( MethodAccess ma |
29
48
ma .getMethod ( ) instanceof ExpressionEvaluationMethod and
30
49
ma .getQualifier ( ) = this .asExpr ( ) and
31
- not exists ( SafeEvaluationContextFlowConfig config |
32
- config .hasFlowTo ( DataFlow:: exprNode ( ma .getArgument ( 0 ) ) )
33
- )
50
+ not SafeEvaluationContextFlow:: hasFlowToExpr ( ma .getArgument ( 0 ) )
34
51
)
35
52
}
36
53
}
37
54
38
55
/**
39
56
* A configuration for safe evaluation context that may be used in expression evaluation.
40
57
*/
41
- private class SafeEvaluationContextFlowConfig extends DataFlow2:: Configuration {
42
- SafeEvaluationContextFlowConfig ( ) { this = "SpelInjection::SafeEvaluationContextFlowConfig" }
43
-
44
- override predicate isSource ( DataFlow:: Node source ) { source instanceof SafeContextSource }
58
+ private module SafeEvaluationContextFlowConfig implements DataFlow:: ConfigSig {
59
+ predicate isSource ( DataFlow:: Node source ) { source instanceof SafeContextSource }
45
60
46
- override predicate isSink ( DataFlow:: Node sink ) {
61
+ predicate isSink ( DataFlow:: Node sink ) {
47
62
exists ( MethodAccess ma |
48
63
ma .getMethod ( ) instanceof ExpressionEvaluationMethod and
49
64
ma .getArgument ( 0 ) = sink .asExpr ( )
50
65
)
51
66
}
52
67
53
- override int fieldFlowBranchLimit ( ) { result = 0 }
68
+ int fieldFlowBranchLimit ( ) { result = 0 }
54
69
}
55
70
71
+ private module SafeEvaluationContextFlow = DataFlow:: Make< SafeEvaluationContextFlowConfig > ;
72
+
56
73
/**
57
74
* A `ContextSource` that is safe from SpEL injection.
58
75
*/
0 commit comments