Skip to content

Commit 704bfe7

Browse files
committed
CPP: Support taint flow from qualifiers.
1 parent e6daf3b commit 704bfe7

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

cpp/ql/src/semmle/code/cpp/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ private predicate exprToExprStep(Expr exprIn, Expr exprOut) {
152152
or
153153
inModel.isParameter(argInIndex) and
154154
exprIn = call.getArgument(argInIndex)
155-
)
155+
) or
156+
inModel.isQualifierObject() and
157+
exprIn = call.getQualifier()
156158
)
157159
)
158160
}
@@ -185,7 +187,9 @@ private predicate exprToDefinitionByReferenceStep(Expr exprIn, Expr argOut) {
185187
or
186188
inModel.isParameter(argInIndex) and
187189
exprIn = call.getArgument(argInIndex)
188-
)
190+
) or
191+
inModel.isQualifierObject() and
192+
exprIn = call.getQualifier()
189193
)
190194
)
191195
}

cpp/ql/test/library-tests/dataflow/taint-tests/taint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,5 +444,5 @@ void test_qualifiers()
444444
sink(d.getString());
445445
d.setString(strings::source());
446446
sink(d); // tainted
447-
sink(d.getString()); // tainted [NOT DETECTED]
447+
sink(d.getString()); // tainted
448448
}

cpp/ql/test/library-tests/dataflow/taint-tests/taint.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@
4343
| taint.cpp:430:9:430:14 | member | taint.cpp:428:13:428:18 | call to source |
4444
| taint.cpp:438:7:438:7 | c | taint.cpp:437:15:437:20 | call to source |
4545
| taint.cpp:446:7:446:7 | d | taint.cpp:445:14:445:28 | call to source |
46+
| taint.cpp:447:9:447:17 | call to getString | taint.cpp:445:14:445:28 | call to source |

cpp/ql/test/library-tests/dataflow/taint-tests/test_diff.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
| taint.cpp:430:9:430:14 | taint.cpp:428:13:428:18 | AST only |
3232
| taint.cpp:438:7:438:7 | taint.cpp:437:15:437:20 | AST only |
3333
| taint.cpp:446:7:446:7 | taint.cpp:445:14:445:28 | AST only |
34+
| taint.cpp:447:9:447:17 | taint.cpp:445:14:445:28 | AST only |

0 commit comments

Comments
 (0)