File tree Expand file tree Collapse file tree 3 files changed +10
-21
lines changed
semmle/code/java/security Expand file tree Collapse file tree 3 files changed +10
-21
lines changed Original file line number Diff line number Diff line change 12
12
13
13
import java
14
14
import semmle.code.java.security.SpelInjectionQuery
15
+ import semmle.code.java.dataflow.DataFlow
15
16
import DataFlow:: PathGraph
16
17
17
18
from DataFlow:: PathNode source , DataFlow:: PathNode sink , SpelInjectionConfig conf
Original file line number Diff line number Diff line change 1
1
/** Provides classes to reason about SpEL injection attacks. */
2
2
3
3
import java
4
- import semmle.code.java.dataflow.DataFlow
5
- import semmle.code.java.dataflow.ExternalFlow
6
- import semmle.code.java.frameworks.spring.SpringExpression
4
+ private import semmle.code.java.dataflow.DataFlow
5
+ private import semmle.code.java.dataflow.ExternalFlow
6
+ private import semmle.code.java.frameworks.spring.SpringExpression
7
7
8
8
/** A data flow sink for unvalidated user input that is used to construct SpEL expressions. */
9
9
abstract class SpelExpressionEvaluationSink extends DataFlow:: ExprNode { }
10
10
11
- private class SpelExpressionEvaluationModel extends SinkModelCsv {
12
- override predicate row ( string row ) {
13
- row =
14
- [
15
- "org.springframework.expression;Expression;true;getValue;;;Argument[-1];spel" ,
16
- "org.springframework.expression;Expression;true;getValueTypeDescriptor;;;Argument[-1];spel" ,
17
- "org.springframework.expression;Expression;true;getValueType;;;Argument[-1];spel" ,
18
- "org.springframework.expression;Expression;true;setValue;;;Argument[-1];spel"
19
- ]
20
- }
21
- }
22
-
23
11
/**
24
12
* A unit class for adding additional taint steps.
25
13
*
Original file line number Diff line number Diff line change 1
1
/** Provides taint tracking and dataflow configurations to be used in SpEL injection queries. */
2
2
3
3
import java
4
- import semmle.code.java.dataflow.DataFlow
5
- import semmle.code.java.dataflow.FlowSources
6
- import semmle.code.java.frameworks.spring.SpringExpression
7
- import semmle.code.java.security.SpelInjection
4
+ private import semmle.code.java.dataflow.FlowSources
5
+ private import semmle.code.java.dataflow.TaintTracking
6
+ private import semmle.code.java.frameworks.spring.SpringExpression
7
+ private import semmle.code.java.security.SpelInjection
8
8
9
9
/**
10
10
* A taint-tracking configuration for unsafe user input
@@ -26,8 +26,8 @@ class SpelInjectionConfig extends TaintTracking::Configuration {
26
26
private class DefaultSpelExpressionEvaluationSink extends SpelExpressionEvaluationSink {
27
27
DefaultSpelExpressionEvaluationSink ( ) {
28
28
exists ( MethodAccess ma |
29
- sinkNode ( this , "spel" ) and
30
- this . asExpr ( ) = ma . getQualifier ( ) and
29
+ ma . getMethod ( ) instanceof ExpressionEvaluationMethod and
30
+ ma . getQualifier ( ) = this . asExpr ( ) and
31
31
not exists ( SafeEvaluationContextFlowConfig config |
32
32
config .hasFlowTo ( DataFlow:: exprNode ( ma .getArgument ( 0 ) ) )
33
33
)
You can’t perform that action at this time.
0 commit comments