@@ -60,14 +60,13 @@ private predicate accessesVariable(CopyInstruction copy, Variable var) {
60
60
/**
61
61
* A variable that has any kind of upper-bound check anywhere in the program
62
62
*/
63
+ // TODO: This coarse overapproximation, ported from the old taint tracking
64
+ // library, could be replaced with an actual semantic check that a particular
65
+ // variable _access_ is guarded by an upper-bound check. We probably don't want
66
+ // to do this right away since it could expose a lot of FPs that were
67
+ // previously suppressed by this predicate by coincidence.
63
68
private predicate hasUpperBoundsCheck ( Variable var ) {
64
- exists ( BinaryOperation oper , VariableAccess access |
65
- (
66
- oper .getOperator ( ) = "<" or
67
- oper .getOperator ( ) = "<=" or
68
- oper .getOperator ( ) = ">" or
69
- oper .getOperator ( ) = ">="
70
- ) and
69
+ exists ( RelationalOperation oper , VariableAccess access |
71
70
oper .getLeftOperand ( ) = access and
72
71
access .getTarget ( ) = var and
73
72
// Comparing to 0 is not an upper bound check
@@ -101,19 +100,26 @@ private predicate instructionTaintStep(Instruction i1, Instruction i2) {
101
100
// through `LoadInstruction`.
102
101
//
103
102
// TODO: Flow from argument to return of known functions: Port missing parts
104
- // of `returnArgument` to the `interfaces.Taint` library.
103
+ // of `returnArgument` to the `interfaces.Taint` and `interfaces.DataFlow`
104
+ // libraries.
105
105
//
106
106
// TODO: Flow from input argument to output argument of known functions: Port
107
- // missing parts of `copyValueBetweenArguments` to the `interfaces.Taint`
108
- // library and implement call side-effect nodes. This will help with the test
109
- // for `ExecTainted.ql`. The test for `TaintedPath.ql` is more tricky because
110
- // the output arg is a pointer addition expression.
107
+ // missing parts of `copyValueBetweenArguments` to the `interfaces.Taint` and
108
+ // `interfaces.DataFlow` libraries and implement call side-effect nodes. This
109
+ // will help with the test for `ExecTainted.ql`. The test for
110
+ // `TaintedPath.ql` is more tricky because the output arg is a pointer
111
+ // addition expression.
111
112
}
112
113
113
114
predicate tainted ( Expr source , Element tainted ) {
114
115
exists ( DefaultTaintTrackingCfg cfg , DataFlow:: Node sink |
115
116
cfg .hasFlow ( DataFlow:: exprNode ( source ) , sink )
116
117
|
118
+ // TODO: is it more appropriate to use asConvertedExpr here and avoid
119
+ // `getConversion*`? Or will that cause us to miss some cases where there's
120
+ // flow to a conversion (like a `ReferenceDereferenceExpr`) and we want to
121
+ // pretend there was flow to the converted `Expr` for the sake of
122
+ // compatibility.
117
123
sink .asExpr ( ) .getConversion * ( ) = tainted
118
124
or
119
125
// For compatibility, send flow from arguments to parameters, even for
0 commit comments