Skip to content

Commit 2463024

Browse files
committed
C++: Add CleartextTransmission query.
1 parent dccdc3b commit 2463024

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

cpp/ql/src/Security/CWE/CWE-311/CleartextStorage.inc.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ storage.</p>
99
</overview>
1010
<recommendation>
1111

12-
<p>Ensure that sensitive information is always encrypted before being stored, especially before writing to a file.
12+
<p>Ensure that sensitive information is always encrypted before being stored or transmitted, especially before writing to a file.
1313
It may be wise to encrypt information before it is put into a buffer that may be readable in memory.</p>
1414

1515
<p>In general, decrypt sensitive information only at the point where it is necessary for it to be used in
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!DOCTYPE qhelp PUBLIC
2+
"-//Semmle//qhelp//EN"
3+
"qhelp.dtd">
4+
<qhelp>
5+
<include src="CleartextStorage.inc.qhelp" /></qhelp>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @name Cleartext transmission of sensitive information
3+
* @description Transmitting sensitive information across a network in
4+
* cleartext can expose it to an attacker.
5+
* @kind problem
6+
* @problem.severity warning
7+
* @security-severity 7.5 TODO
8+
* @precision high
9+
* @id cpp/cleartext-transmission
10+
* @tags security
11+
* external/cwe/cwe-319
12+
*/
13+
14+
import cpp
15+
import semmle.code.cpp.security.SensitiveExprs
16+
import semmle.code.cpp.security.FileWrite
17+
import semmle.code.cpp.dataflow.DataFlow
18+
import semmle.code.cpp.valuenumbering.GlobalValueNumbering
19+
20+
// TODO: network send?
21+
22+
/**
23+
* TODO
24+
*/
25+
class NetworkRecv extends FunctionCall {
26+
NetworkRecv() { this.getTarget().hasGlobalName("recv") }
27+
28+
Expr getData() { result = this.getArgument(1) }
29+
}
30+
31+
from NetworkRecv recv, SensitiveExpr e
32+
where DataFlow::localFlow(DataFlow::exprNode(e), DataFlow::exprNode(recv.(NetworkRecv).getData()))
33+
select recv, e

0 commit comments

Comments
 (0)