Skip to content

Commit 968ddc6

Browse files
authored
Merge pull request github#3137 from jbj/DefaultTaintTracking-argv
C++: Never track flow out of an argv argument
2 parents 782f2b5 + 2801941 commit 968ddc6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ private DataFlow::Node getNodeForSource(Expr source) {
6060
(
6161
result = DataFlow::exprNode(source)
6262
or
63-
result = DataFlow::definitionByReferenceNode(source)
63+
// Some of the sources in `isUserInput` are intended to match the value of
64+
// an expression, while others (those modeled below) are intended to match
65+
// the taint that propagates out of an argument, like the `char *` argument
66+
// to `gets`. It's impossible here to tell which is which, but the "access
67+
// to argv" source is definitely not intended to match an output argument,
68+
// and it causes false positives if we let it.
69+
result = DataFlow::definitionByReferenceNode(source) and
70+
not argv(source.(VariableAccess).getTarget())
6471
)
6572
}
6673

0 commit comments

Comments
 (0)