Skip to content

Commit 4396e66

Browse files
committed
C++: Fix FP by providing an implementation of 'hasSocketInput'.
1 parent eda33ad commit 4396e66

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

cpp/ql/lib/semmle/code/cpp/models/implementations/Scanf.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ private class FscanfModel extends ScanfFunctionModel, RemoteFlowSourceFunction i
8787
output.isParameterDeref(any(int i | i >= this.getArgsStartPosition())) and
8888
description = "value read by " + this.getName()
8989
}
90+
91+
override predicate hasSocketInput(FunctionInput input) {
92+
input.isParameterDeref(super.getInputParameterIndex())
93+
}
9094
}
9195

9296
/**

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ nodes
138138
| test3.cpp:577:2:577:25 | ... = ... | semmle.label | ... = ... |
139139
| test3.cpp:577:8:577:23 | call to get_home_address | semmle.label | call to get_home_address |
140140
| test3.cpp:578:14:578:16 | str | semmle.label | str |
141-
| test3.cpp:585:25:585:32 | password | semmle.label | password |
142141
subpaths
143142
| test3.cpp:138:24:138:32 | password1 | test3.cpp:117:28:117:33 | buffer | test3.cpp:117:13:117:14 | *id | test3.cpp:138:21:138:22 | call to id |
144143
#select
@@ -182,4 +181,3 @@ subpaths
182181
| test3.cpp:559:3:559:6 | call to send | test3.cpp:556:19:556:30 | salaryString | test3.cpp:559:15:559:20 | *buffer | This operation transmits '*buffer', which may contain unencrypted sensitive data from $@. | test3.cpp:556:19:556:30 | salaryString | salaryString |
183182
| test3.cpp:572:2:572:5 | call to send | test3.cpp:571:8:571:21 | call to get_home_phone | test3.cpp:572:14:572:16 | str | This operation transmits 'str', which may contain unencrypted sensitive data from $@. | test3.cpp:571:8:571:21 | call to get_home_phone | call to get_home_phone |
184183
| test3.cpp:578:2:578:5 | call to send | test3.cpp:577:8:577:23 | call to get_home_address | test3.cpp:578:14:578:16 | str | This operation transmits 'str', which may contain unencrypted sensitive data from $@. | test3.cpp:577:8:577:23 | call to get_home_address | call to get_home_address |
185-
| test3.cpp:585:2:585:7 | call to fscanf | test3.cpp:585:25:585:32 | password | test3.cpp:585:25:585:32 | password | This operation receives into 'password', which may put unencrypted sensitive data into $@. | test3.cpp:585:25:585:32 | 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
@@ -582,5 +582,5 @@ int fscanf(FILE* stream, const char* format, ... );
582582

583583
void test_scanf() {
584584
char password[256];
585-
fscanf(stdin, "%255s", password); // GOOD [FALSE POSITIVE]: this is not a remote source
585+
fscanf(stdin, "%255s", password); // GOOD: this is not a remote source
586586
}

0 commit comments

Comments
 (0)