Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* The `RemoteFlowSourceFunction` model for `fscanf` (and variants) now implements `hasSocketInput` to reflect that these functions may read from a socket.
4 changes: 4 additions & 0 deletions cpp/ql/lib/semmle/code/cpp/models/implementations/Scanf.qll
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ private class FscanfModel extends ScanfFunctionModel, RemoteFlowSourceFunction i
output.isParameterDeref(any(int i | i >= this.getArgsStartPosition())) and
description = "value read by " + this.getName()
}

override predicate hasSocketInput(FunctionInput input) {
input.isParameterDeref(super.getInputParameterIndex())
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* The 'Cleartext transmission of sensitive information' query (`cpp/cleartext-transmission`) no longer raises an alert on calls to `fscanf` (and variants) when the call reads from an "obviously local" `FILE` stream such as `stdin`.
Original file line number Diff line number Diff line change
Expand Up @@ -577,3 +577,10 @@ void tests3()
str = get_home_address();
send(val(), str, strlen(str), val()); // BAD
}

int fscanf(FILE* stream, const char* format, ... );

void test_scanf() {
char password[256];
fscanf(stdin, "%255s", password); // GOOD: this is not a remote source
}
Loading