@@ -3,13 +3,6 @@ private import experimental.dataflow.DataFlow
33private import experimental.dataflow.internal.DataFlowPrivate
44private import experimental.dataflow.internal.TaintTrackingPublic
55
6- /**
7- * Holds if taint can flow in one local step from `nodeFrom` to `nodeTo` excluding
8- * local data flow steps. That is, `nodeFrom` and `nodeTo` are likely to represent
9- * different objects.
10- */
11- predicate localAdditionalTaintStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) { none ( ) }
12-
136/**
147 * Holds if `node` should be a barrier in all global taint flow configurations
158 * but not in local taint.
@@ -25,3 +18,39 @@ predicate defaultAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nod
2518 or
2619 any ( AdditionalTaintStep a ) .step ( nodeFrom , nodeTo )
2720}
21+
22+ /**
23+ * Holds if taint can flow in one local step from `nodeFrom` to `nodeTo` excluding
24+ * local data flow steps. That is, `nodeFrom` and `nodeTo` are likely to represent
25+ * different objects.
26+ */
27+ predicate localAdditionalTaintStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
28+ concatStep ( nodeFrom , nodeTo )
29+ or
30+ subscriptStep ( nodeFrom , nodeTo )
31+ }
32+
33+ /**
34+ * Holds if taint can flow from `nodeFrom` to `nodeTo` with a step related to concatenation.
35+ *
36+ * Note that since we cannot easily distinguish interesting types (like string, list, tuple), so
37+ * we consider any `+` operation to propagate taint. After consulting with the JS team, this
38+ * should doesn't sound like it is a big problem in practice.
39+ */
40+ predicate concatStep ( DataFlow:: CfgNode nodeFrom , DataFlow:: CfgNode nodeTo ) {
41+ exists ( BinaryExprNode add | add = nodeTo .getNode ( ) |
42+ add .getOp ( ) instanceof Add and
43+ (
44+ add .getLeft ( ) = nodeFrom .getNode ( )
45+ or
46+ add .getRight ( ) = nodeFrom .getNode ( )
47+ )
48+ )
49+ }
50+
51+ /**
52+ * Holds if taint can flow from `nodeFrom` to `nodeTo` with a step related to subscripting.
53+ */
54+ predicate subscriptStep ( DataFlow:: CfgNode nodeFrom , DataFlow:: CfgNode nodeTo ) {
55+ nodeTo .getNode ( ) .( SubscriptNode ) .getObject ( ) = nodeFrom .getNode ( )
56+ }
0 commit comments