|
13 | 13 |
|
14 | 14 | import cpp
|
15 | 15 | import semmle.code.cpp.security.BufferWrite
|
16 |
| -import semmle.code.cpp.security.TaintTracking |
17 | 16 | import semmle.code.cpp.security.SensitiveExprs
|
18 |
| -import TaintedWithPath |
| 17 | +import semmle.code.cpp.security.Security |
| 18 | +import semmle.code.cpp.dataflow.TaintTracking |
| 19 | +import DataFlow::PathGraph |
19 | 20 |
|
20 |
| -class Configuration extends TaintTrackingConfiguration { |
21 |
| - override predicate isSink(Element tainted) { exists(BufferWrite w | w.getASource() = tainted) } |
| 21 | +/** |
| 22 | + * Taint flow from user input to a buffer write. |
| 23 | + */ |
| 24 | +class ToBufferConfiguration extends TaintTracking::Configuration { |
| 25 | + ToBufferConfiguration() { this = "ToBufferConfiguration" } |
| 26 | + |
| 27 | + override predicate isSource(DataFlow::Node source) { isUserInput(source.asExpr(), _) } |
| 28 | + |
| 29 | + override predicate isSink(DataFlow::Node sink) { |
| 30 | + exists(BufferWrite w | w.getASource() = sink.asExpr()) |
| 31 | + } |
22 | 32 | }
|
23 | 33 |
|
24 | 34 | from
|
25 |
| - BufferWrite w, Expr taintedArg, Expr taintSource, PathNode sourceNode, PathNode sinkNode, |
26 |
| - string taintCause, SensitiveExpr dest |
| 35 | + ToBufferConfiguration config, BufferWrite w, Expr taintSource, DataFlow::PathNode sourceNode, |
| 36 | + DataFlow::PathNode sinkNode, string taintCause, SensitiveExpr dest |
27 | 37 | where
|
28 |
| - taintedWithPath(taintSource, taintedArg, sourceNode, sinkNode) and |
| 38 | + config.hasFlowPath(sourceNode, sinkNode) and |
| 39 | + taintSource = sourceNode.getNode().asExpr() and |
| 40 | + w.getASource() = sinkNode.getNode().asExpr() and |
29 | 41 | isUserInput(taintSource, taintCause) and
|
30 |
| - w.getASource() = taintedArg and |
31 | 42 | dest = w.getDest()
|
32 | 43 | select w, sourceNode, sinkNode,
|
33 | 44 | "This write into buffer '" + dest.toString() + "' may contain unencrypted data from $@",
|
|
0 commit comments