CPP: Add query for CWE-754: Improper Check for Unusual or Exceptional Conditions when using functions scanf #8246
Merged
jketema merged 22 commits intogithub:mainfrom Mar 11, 2022
ihsinme:ihsinme-patch-82
Merged
CPP: Add query for CWE-754: Improper Check for Unusual or Exceptional Conditions when using functions scanf #8246jketema merged 22 commits intogithub:mainfrom ihsinme:ihsinme-patch-82
jketema merged 22 commits intogithub:mainfrom
ihsinme:ihsinme-patch-82
Conversation
jketema
reviewed
Feb 28, 2022
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.qhelp
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.qhelp
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Outdated
Show resolved
Hide resolved
Contributor
Author
|
thanks for the comments. |
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
jketema
reviewed
Mar 2, 2022
Contributor
jketema
left a comment
There was a problem hiding this comment.
Thanks for the updates, especially making the tests cover more cases.
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp
Show resolved
Hide resolved
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp
Show resolved
Hide resolved
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
jketema
reviewed
Mar 4, 2022
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.qhelp
Show resolved
Hide resolved
jketema
reviewed
Mar 4, 2022
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Outdated
Show resolved
Hide resolved
jketema
reviewed
Mar 4, 2022
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Outdated
Show resolved
Hide resolved
jketema
reviewed
Mar 4, 2022
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Outdated
Show resolved
Hide resolved
jketema
reviewed
Mar 4, 2022
cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql
Show resolved
Hide resolved
jketema
reviewed
Mar 4, 2022
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
Contributor
Author
|
I want to thank you for your corrections. |
Contributor
Author
|
I want to thank you for your corrections. |
jketema
approved these changes
Mar 11, 2022
Contributor
There was a problem hiding this comment.
Thanks for the contribution and addressing my comments.
Not for this PR, but you might want to have a look at the data flow library https://codeql.github.com/docs/codeql-language-guides/analyzing-data-flow-in-cpp/. I think that a rewrite based on that library might help to improve the quality of the analysis of what happens after a scanf call.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
the query looks for situations of working with
scanffunctions in situations where the developer has not left the possibility of controlling the correctness of work. There is no check of the returned value, the filled variable is not initialized and its value is not evaluated after the function has run. this leads to a situation where, continuing to work with a filled variable, the developer runs the risk of working with a randomly filled value at the declaration stage.CVE-2019-15900
I'm working on a real fix for this issue.