@@ -49,38 +49,43 @@ class WorkerThreads extends DataFlow::Node {
49
49
}
50
50
}
51
51
52
- class UrlConstructorLabel extends DataFlow :: FlowLabel {
53
- UrlConstructorLabel ( ) { this = "UrlConstructorLabel" }
54
- }
52
+ newtype TFlowState =
53
+ TTaint ( ) or
54
+ TUrlConstructor ( )
55
55
56
56
/**
57
57
* A taint-tracking configuration for reasoning about code injection vulnerabilities.
58
58
*/
59
59
module CodeInjectionConfig implements DataFlow:: StateConfigSig {
60
- class FlowState = DataFlow:: FlowLabel ;
60
+ class FlowState extends TFlowState {
61
+ string toString ( ) {
62
+ this = TTaint ( ) and result = "taint"
63
+ or
64
+ this = TUrlConstructor ( ) and result = "url-constructor"
65
+ }
66
+ }
61
67
62
- predicate isSource ( DataFlow:: Node source , DataFlow :: FlowLabel label ) {
63
- source instanceof ActiveThreatModelSource and label . isTaint ( )
68
+ predicate isSource ( DataFlow:: Node source , FlowState label ) {
69
+ source instanceof ActiveThreatModelSource and label = TTaint ( )
64
70
}
65
71
66
72
predicate isSink ( DataFlow:: Node sink ) { sink instanceof DynamicImport }
67
73
68
- predicate isSink ( DataFlow:: Node sink , DataFlow :: FlowLabel label ) {
69
- sink instanceof WorkerThreads and label instanceof UrlConstructorLabel
74
+ predicate isSink ( DataFlow:: Node sink , FlowState label ) {
75
+ sink instanceof WorkerThreads and label = TUrlConstructor ( )
70
76
}
71
77
72
78
predicate isBarrier ( DataFlow:: Node node ) { node instanceof Barrier }
73
79
74
80
predicate isAdditionalFlowStep (
75
- DataFlow:: Node pred , DataFlow:: FlowLabel predlbl , DataFlow:: Node succ ,
76
- DataFlow:: FlowLabel succlbl
81
+ DataFlow:: Node pred , FlowState predlbl , DataFlow:: Node succ , FlowState succlbl
77
82
) {
78
83
exists ( DataFlow:: NewNode newUrl | succ = newUrl |
79
84
newUrl = DataFlow:: globalVarRef ( "URL" ) .getAnInstantiation ( ) and
80
85
pred = newUrl .getArgument ( 0 )
81
86
) and
82
- predlbl . isDataOrTaint ( ) and
83
- succlbl instanceof UrlConstructorLabel
87
+ predlbl = TTaint ( ) and
88
+ succlbl = TUrlConstructor ( )
84
89
}
85
90
}
86
91
0 commit comments