@@ -7,9 +7,11 @@ import semmle.code.java.security.XmlParsers
7
7
import semmle.code.java.security.XsltInjection
8
8
9
9
/**
10
+ * DEPRECATED: Use `XsltInjectionFlow` instead.
11
+ *
10
12
* A taint-tracking configuration for unvalidated user input that is used in XSLT transformation.
11
13
*/
12
- class XsltInjectionFlowConfig extends TaintTracking:: Configuration {
14
+ deprecated class XsltInjectionFlowConfig extends TaintTracking:: Configuration {
13
15
XsltInjectionFlowConfig ( ) { this = "XsltInjectionFlowConfig" }
14
16
15
17
override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
@@ -25,6 +27,28 @@ class XsltInjectionFlowConfig extends TaintTracking::Configuration {
25
27
}
26
28
}
27
29
30
+ /**
31
+ * A taint-tracking configuration for unvalidated user input that is used in XSLT transformation.
32
+ */
33
+ private module XsltInjectionFlowConfig implements DataFlow:: ConfigSig {
34
+ predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
35
+
36
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof XsltInjectionSink }
37
+
38
+ predicate isBarrier ( DataFlow:: Node node ) {
39
+ node .getType ( ) instanceof PrimitiveType or node .getType ( ) instanceof BoxedType
40
+ }
41
+
42
+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
43
+ any ( XsltInjectionAdditionalTaintStep c ) .step ( node1 , node2 )
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Tracks flow from unvalidated user input to XSLT transformation.
49
+ */
50
+ module XsltInjectionFlow = TaintTracking:: Make< XsltInjectionFlowConfig > ;
51
+
28
52
/**
29
53
* A set of additional taint steps to consider when taint tracking XSLT related data flows.
30
54
* These steps use data flow logic themselves.
@@ -46,39 +70,37 @@ private predicate newTransformerOrTemplatesStep(DataFlow::Node n1, DataFlow::Nod
46
70
n2 .asExpr ( ) = ma and
47
71
m .getDeclaringType ( ) instanceof TransformerFactory and
48
72
m .hasName ( [ "newTransformer" , "newTemplates" ] ) and
49
- not exists ( TransformerFactoryWithSecureProcessingFeatureFlowConfig conf |
50
- conf .hasFlowToExpr ( ma .getQualifier ( ) )
51
- )
73
+ not TransformerFactoryWithSecureProcessingFeatureFlow:: hasFlowToExpr ( ma .getQualifier ( ) )
52
74
)
53
75
}
54
76
55
77
/**
56
78
* A data flow configuration for secure processing feature that is enabled on `TransformerFactory`.
57
79
*/
58
- private class TransformerFactoryWithSecureProcessingFeatureFlowConfig extends DataFlow2:: Configuration
80
+ private module TransformerFactoryWithSecureProcessingFeatureFlowConfig implements
81
+ DataFlow:: ConfigSig
59
82
{
60
- TransformerFactoryWithSecureProcessingFeatureFlowConfig ( ) {
61
- this = "TransformerFactoryWithSecureProcessingFeatureFlowConfig"
62
- }
63
-
64
- override predicate isSource ( DataFlow:: Node src ) {
83
+ predicate isSource ( DataFlow:: Node src ) {
65
84
exists ( Variable v | v = src .asExpr ( ) .( VarAccess ) .getVariable ( ) |
66
85
exists ( TransformerFactoryFeatureConfig config | config .getQualifier ( ) = v .getAnAccess ( ) |
67
86
config .enables ( configSecureProcessing ( ) )
68
87
)
69
88
)
70
89
}
71
90
72
- override predicate isSink ( DataFlow:: Node sink ) {
91
+ predicate isSink ( DataFlow:: Node sink ) {
73
92
exists ( MethodAccess ma |
74
93
sink .asExpr ( ) = ma .getQualifier ( ) and
75
94
ma .getMethod ( ) .getDeclaringType ( ) instanceof TransformerFactory
76
95
)
77
96
}
78
97
79
- override int fieldFlowBranchLimit ( ) { result = 0 }
98
+ int fieldFlowBranchLimit ( ) { result = 0 }
80
99
}
81
100
101
+ private module TransformerFactoryWithSecureProcessingFeatureFlow =
102
+ DataFlow:: Make< TransformerFactoryWithSecureProcessingFeatureFlowConfig > ;
103
+
82
104
/** A `ParserConfig` specific to `TransformerFactory`. */
83
105
private class TransformerFactoryFeatureConfig extends ParserConfig {
84
106
TransformerFactoryFeatureConfig ( ) {
0 commit comments