@@ -14,7 +14,57 @@ import NosqlInjectionCustomizations::NosqlInjection
1414/**
1515 * A taint-tracking configuration for reasoning about SQL-injection vulnerabilities.
1616 */
17- class Configuration extends TaintTracking:: Configuration {
17+ module NosqlInjectionConfig implements DataFlow:: StateConfigSig {
18+ class FlowState = DataFlow:: FlowLabel ;
19+
20+ predicate isSource ( DataFlow:: Node source , DataFlow:: FlowLabel state ) {
21+ source instanceof Source and state .isTaint ( )
22+ or
23+ TaintedObject:: isSource ( source , state )
24+ }
25+
26+ predicate isSink ( DataFlow:: Node sink , DataFlow:: FlowLabel state ) {
27+ sink .( Sink ) .getAFlowLabel ( ) = state
28+ }
29+
30+ predicate isBarrier ( DataFlow:: Node node , DataFlow:: FlowLabel state ) {
31+ node instanceof Sanitizer and state .isTaint ( )
32+ or
33+ TaintTracking:: defaultSanitizer ( node ) and state .isTaint ( )
34+ or
35+ node = TaintedObject:: SanitizerGuard:: getABarrierNode ( state )
36+ }
37+
38+ predicate isAdditionalFlowStep (
39+ DataFlow:: Node node1 , DataFlow:: FlowLabel state1 , DataFlow:: Node node2 ,
40+ DataFlow:: FlowLabel state2
41+ ) {
42+ TaintedObject:: step ( node1 , node2 , state1 , state2 )
43+ or
44+ // additional flow step to track taint through NoSQL query objects
45+ state1 = TaintedObject:: label ( ) and
46+ state2 = TaintedObject:: label ( ) and
47+ exists ( NoSql:: Query query , DataFlow:: SourceNode queryObj |
48+ queryObj .flowsTo ( query ) and
49+ queryObj .flowsTo ( node2 ) and
50+ node1 = queryObj .getAPropertyWrite ( ) .getRhs ( )
51+ )
52+ or
53+ TaintTracking:: defaultTaintStep ( node1 , node2 ) and
54+ state1 .isTaint ( ) and
55+ state2 = state1
56+ }
57+ }
58+
59+ /**
60+ * Taint-tracking for reasoning about SQL-injection vulnerabilities.
61+ */
62+ module NosqlInjectionFlow = DataFlow:: GlobalWithState< NosqlInjectionConfig > ;
63+
64+ /**
65+ * DEPRECATED. Use the `NosqlInjectionFlow` module instead.
66+ */
67+ deprecated class Configuration extends TaintTracking:: Configuration {
1868 Configuration ( ) { this = "NosqlInjection" }
1969
2070 override predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
@@ -37,17 +87,9 @@ class Configuration extends TaintTracking::Configuration {
3787 }
3888
3989 override predicate isAdditionalFlowStep (
40- DataFlow:: Node src , DataFlow:: Node trg , DataFlow:: FlowLabel inlbl , DataFlow:: FlowLabel outlbl
90+ DataFlow:: Node node1 , DataFlow:: Node node2 , DataFlow:: FlowLabel state1 ,
91+ DataFlow:: FlowLabel state2
4192 ) {
42- TaintedObject:: step ( src , trg , inlbl , outlbl )
43- or
44- // additional flow step to track taint through NoSQL query objects
45- inlbl = TaintedObject:: label ( ) and
46- outlbl = TaintedObject:: label ( ) and
47- exists ( NoSql:: Query query , DataFlow:: SourceNode queryObj |
48- queryObj .flowsTo ( query ) and
49- queryObj .flowsTo ( trg ) and
50- src = queryObj .getAPropertyWrite ( ) .getRhs ( )
51- )
93+ NosqlInjectionConfig:: isAdditionalFlowStep ( node1 , state1 , node2 , state2 )
5294 }
5395}
0 commit comments