@@ -49,11 +49,17 @@ predicate interestingConcatenation(DataFlow::Node incoming, DataFlow::Node outgo
49
49
call .getTarget ( ) = op and
50
50
op .hasQualifiedName ( "std" , "operator+" ) and
51
51
op .getType ( ) .( UserType ) .hasQualifiedName ( "std" , "basic_string" ) and
52
- incoming .asIndirectArgument ( ) = call .getArgument ( 1 ) and // left operand
52
+ incoming .asIndirectArgument ( ) = call .getArgument ( 1 ) and // right operand
53
53
call = outgoing .asInstruction ( ) .getUnconvertedResultExpression ( )
54
54
)
55
55
}
56
56
57
+ /**
58
+ * A state will represent the most recent concatenation that occurred in the data flow.
59
+ * - `TConcatState` if the concetenation has not yet occurred.
60
+ * - `TExecState(incoming, outgoing)`, representing the concatenation of data from `incoming`
61
+ * into result `outgoing`.
62
+ */
57
63
newtype TState =
58
64
TConcatState ( ) or
59
65
TExecState ( DataFlow:: Node incoming , DataFlow:: Node outgoing ) {
@@ -74,7 +80,9 @@ class ExecState extends TExecState {
74
80
75
81
DataFlow:: Node getOutgoingNode ( ) { result = outgoing }
76
82
77
- /** Holds if this is a possible `ExecState` for `sink`. */
83
+ /**
84
+ * Holds if this is a possible `ExecState` at `sink`, that is, if `outgoing` flows to `sink`.
85
+ */
78
86
predicate isFeasibleForSink ( DataFlow:: Node sink ) { ExecState:: flow ( outgoing , sink ) }
79
87
80
88
string toString ( ) { result = "ExecState" }
@@ -110,6 +118,12 @@ module ExecStateConfig implements DataFlow::ConfigSig {
110
118
111
119
module ExecState = TaintTracking:: Global< ExecStateConfig > ;
112
120
121
+ /**
122
+ * A full `TaintTracking` configuration from source to concatenation to sink, using a flow
123
+ * state to remember the concatenation. It's important that we track flow to the sink even though
124
+ * as soon as we reach the concatenation we know it will get there (due to the check of
125
+ * `isFeasibleForSink`), because this way we get a complete flow path.
126
+ */
113
127
module ExecTaintConfig implements DataFlow:: StateConfigSig {
114
128
class FlowState = TState ;
115
129
0 commit comments