Skip to content

Commit 67c6b35

Browse files
committed
C++: We get many more real world results using taint tracking.
1 parent 0e8064d commit 67c6b35

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

cpp/ql/src/Security/CWE/CWE-311/CleartextTransmission.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import cpp
1515
import semmle.code.cpp.security.SensitiveExprs
16-
import semmle.code.cpp.dataflow.DataFlow
16+
import semmle.code.cpp.dataflow.TaintTracking
1717
import DataFlow::PathGraph
1818

1919
/**
@@ -68,7 +68,7 @@ class NetworkRecv extends NetworkSendRecv {
6868
* Taint flow from a sensitive expression to a network operation with data
6969
* tainted by that expression.
7070
*/
71-
class SensitiveSendRecvConfiguration extends DataFlow::Configuration {
71+
class SensitiveSendRecvConfiguration extends TaintTracking::Configuration {
7272
SensitiveSendRecvConfiguration() { this = "SensitiveSendRecvConfiguration" }
7373

7474
override predicate isSource(DataFlow::Node source) { source.asExpr() instanceof SensitiveExpr }

cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests/CleartextTransmission.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edges
77
| test3.cpp:132:21:132:22 | call to id | test3.cpp:134:15:134:17 | ptr |
88
| test3.cpp:132:24:132:32 | password1 | test3.cpp:132:21:132:22 | call to id |
99
| test3.cpp:138:16:138:29 | call to get_global_str | test3.cpp:140:15:140:18 | data |
10+
| test3.cpp:151:19:151:26 | password | test3.cpp:153:15:153:20 | buffer |
1011
nodes
1112
| test3.cpp:20:15:20:23 | password1 | semmle.label | password1 |
1213
| test3.cpp:24:15:24:23 | password2 | semmle.label | password2 |
@@ -26,6 +27,8 @@ nodes
2627
| test3.cpp:134:15:134:17 | ptr | semmle.label | ptr |
2728
| test3.cpp:138:16:138:29 | call to get_global_str | semmle.label | call to get_global_str |
2829
| test3.cpp:140:15:140:18 | data | semmle.label | data |
30+
| test3.cpp:151:19:151:26 | password | semmle.label | password |
31+
| test3.cpp:153:15:153:20 | buffer | semmle.label | buffer |
2932
#select
3033
| test3.cpp:20:3:20:6 | call to send | test3.cpp:20:15:20:23 | password1 | test3.cpp:20:15:20:23 | password1 | This operation transmits 'password1', which may contain unencrypted sensitive data from $@ | test3.cpp:20:15:20:23 | password1 | password1 |
3134
| test3.cpp:24:3:24:6 | call to send | test3.cpp:24:15:24:23 | password2 | test3.cpp:24:15:24:23 | password2 | This operation transmits 'password2', which may contain unencrypted sensitive data from $@ | test3.cpp:24:15:24:23 | password2 | password2 |
@@ -37,3 +40,4 @@ nodes
3740
| test3.cpp:108:2:108:5 | call to recv | test3.cpp:128:11:128:18 | password | test3.cpp:108:14:108:19 | buffer | This operation receives into 'buffer', which may put unencrypted sensitive data into $@ | test3.cpp:128:11:128:18 | password | password |
3841
| test3.cpp:134:3:134:6 | call to send | test3.cpp:132:24:132:32 | password1 | test3.cpp:134:15:134:17 | ptr | This operation transmits 'ptr', which may contain unencrypted sensitive data from $@ | test3.cpp:132:24:132:32 | password1 | password1 |
3942
| test3.cpp:140:3:140:6 | call to send | test3.cpp:120:9:120:23 | global_password | test3.cpp:140:15:140:18 | data | This operation transmits 'data', which may contain unencrypted sensitive data from $@ | test3.cpp:120:9:120:23 | global_password | global_password |
43+
| test3.cpp:153:3:153:6 | call to send | test3.cpp:151:19:151:26 | password | test3.cpp:153:15:153:20 | buffer | This operation transmits 'buffer', which may contain unencrypted sensitive data from $@ | test3.cpp:151:19:151:26 | password | password |

cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests/test3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,6 @@ void test_taint(const char *password)
150150

151151
strncpy(buffer, password, 16);
152152
buffer[15] = 0;
153-
send(val(), buffer, 16, val()); // BAD: `password` is (partially) sent plaintext [NOT DETECTED]
153+
send(val(), buffer, 16, val()); // BAD: `password` is (partially) sent plaintext
154154
}
155155
}

0 commit comments

Comments
 (0)