|
12 | 12 | */ |
13 | 13 |
|
14 | 14 | import cpp |
15 | | -import semmle.code.cpp.security.BufferWrite |
| 15 | +import semmle.code.cpp.security.BufferWrite as BufferWrite |
16 | 16 | import semmle.code.cpp.security.SensitiveExprs |
17 | 17 | import semmle.code.cpp.security.Security |
18 | | -import semmle.code.cpp.dataflow.TaintTracking |
| 18 | +import semmle.code.cpp.ir.dataflow.TaintTracking |
19 | 19 | import DataFlow::PathGraph |
20 | 20 |
|
| 21 | +Expr exprForNode(DataFlow::Node n) { |
| 22 | + n = DataFlow::exprNode(result) |
| 23 | + or |
| 24 | + // (similar to DefaultTaintTracking's `getNodeForExpr`) |
| 25 | + n = DataFlow::definitionByReferenceNodeFromArgument(result) and |
| 26 | + not argv(result.(VariableAccess).getTarget()) |
| 27 | +} |
| 28 | + |
21 | 29 | /** |
22 | 30 | * Taint flow from user input to a buffer write. |
23 | 31 | */ |
24 | 32 | class ToBufferConfiguration extends TaintTracking::Configuration { |
25 | 33 | ToBufferConfiguration() { this = "ToBufferConfiguration" } |
26 | 34 |
|
27 | | - override predicate isSource(DataFlow::Node source) { isUserInput(source.asExpr(), _) } |
| 35 | + override predicate isSource(DataFlow::Node source) { isUserInput(exprForNode(source), _) } |
28 | 36 |
|
29 | 37 | override predicate isSink(DataFlow::Node sink) { |
30 | | - exists(BufferWrite w | w.getASource() = sink.asExpr()) |
| 38 | + exists(BufferWrite::BufferWrite w | w.getASource() = sink.asExpr()) |
31 | 39 | } |
32 | 40 | } |
33 | 41 |
|
34 | 42 | from |
35 | | - ToBufferConfiguration config, BufferWrite w, Expr taintSource, DataFlow::PathNode sourceNode, |
| 43 | + ToBufferConfiguration config, BufferWrite::BufferWrite w, Expr taintSource, DataFlow::PathNode sourceNode, |
36 | 44 | DataFlow::PathNode sinkNode, string taintCause, SensitiveExpr dest |
37 | 45 | where |
38 | 46 | config.hasFlowPath(sourceNode, sinkNode) and |
39 | | - taintSource = sourceNode.getNode().asExpr() and |
| 47 | + taintSource = exprForNode(sourceNode.getNode()) and |
40 | 48 | w.getASource() = sinkNode.getNode().asExpr() and |
41 | 49 | isUserInput(taintSource, taintCause) and |
42 | 50 | dest = w.getDest() |
|
0 commit comments