|
5 | 5 | * @kind problem |
6 | 6 | * @problem.severity warning |
7 | 7 | * @security-severity 7.5 TODO |
8 | | - * @precision high |
| 8 | + * @precision high TODO |
9 | 9 | * @id cpp/cleartext-transmission |
10 | 10 | * @tags security |
11 | 11 | * external/cwe/cwe-319 |
12 | 12 | */ |
13 | 13 |
|
14 | 14 | import cpp |
15 | 15 | import semmle.code.cpp.security.SensitiveExprs |
16 | | -import semmle.code.cpp.security.FileWrite |
17 | 16 | import semmle.code.cpp.dataflow.DataFlow |
18 | | -import semmle.code.cpp.valuenumbering.GlobalValueNumbering |
19 | 17 |
|
20 | 18 | /** |
21 | 19 | * A function call that sends or receives data over a network. |
@@ -65,10 +63,31 @@ class NetworkRecv extends NetworkSendRecv { |
65 | 63 | override Expr getDataExpr() { result = this.getArgument(1) } |
66 | 64 | } |
67 | 65 |
|
68 | | -from NetworkSendRecv transmission, SensitiveExpr e |
| 66 | +/** |
| 67 | + * Taint flow from a sensitive expression to a network operation with data |
| 68 | + * tainted by that expression. |
| 69 | + */ |
| 70 | +class SensitiveSendRecvConfiguration extends DataFlow::Configuration { |
| 71 | + SensitiveSendRecvConfiguration() { this = "SensitiveSendRecvConfiguration" } |
| 72 | + |
| 73 | + override predicate isSource(DataFlow::Node source) { source.asExpr() instanceof SensitiveExpr } |
| 74 | + |
| 75 | + override predicate isSink(DataFlow::Node sink) { |
| 76 | + exists(NetworkSendRecv transmission | |
| 77 | + sink.asExpr() = transmission.getDataExpr() and |
| 78 | + not exists(Zero zero | |
| 79 | + DataFlow::localFlow(DataFlow::exprNode(zero), |
| 80 | + DataFlow::exprNode(transmission.getSocketExpr())) |
| 81 | + ) |
| 82 | + ) |
| 83 | + } |
| 84 | +} |
| 85 | + |
| 86 | +from SensitiveSendRecvConfiguration config1, Expr source, Expr sink |
69 | 87 | where |
70 | | - DataFlow::localFlow(DataFlow::exprNode(e), DataFlow::exprNode(transmission.getDataExpr())) and |
71 | | - not exists(Zero zero | |
72 | | - DataFlow::localFlow(DataFlow::exprNode(zero), DataFlow::exprNode(transmission.getSocketExpr())) |
| 88 | + exists(DataFlow::PathNode sourceNode, DataFlow::PathNode sinkNode | |
| 89 | + config1.hasFlowPath(sourceNode, sinkNode) and |
| 90 | + source = sourceNode.getNode().asExpr() and |
| 91 | + sink = sinkNode.getNode().asExpr() |
73 | 92 | ) |
74 | | -select transmission, e |
| 93 | +select sink, source |
0 commit comments