GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CPP: Add query for CWE-754: Improper Check for Unusual or Exceptional Conditions when using functions scanf by ihsinme · Pull Request #8246 · github/codeql

Conversation

@ihsinme

@ihsinme ihsinme commented Feb 25, 2022

Copy link
Copy Markdown
Contributor

the query looks for situations of working with scanf functions 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ihsinme added 3 commits February 25, 2022 11:04
@ihsinme
Merge pull request #1 from github/main
3d1f4d5
up to head
@ihsinme
Add files via upload
bddb5fd
@ihsinme
Add files via upload
0c8a072
@ihsinme
ihsinme requested a review from a team as a code owner February 25, 2022 08:17
@github-actions github-actions Bot added C++ documentation labels Feb 25, 2022
@MathiasVP MathiasVP assigned jketema Feb 28, 2022
jketema
jketema reviewed Feb 28, 2022
View reviewed changes

@jketema jketema left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ihsinme. Thanks for your contribution. Some comments below.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ihsinme

ihsinme commented Mar 1, 2022

Copy link
Copy Markdown
Contributor Author

thanks for the comments.
I will try to fix everything as soon as possible.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ihsinme and others added 4 commits March 1, 2022 10:49
@ihsinme @jketema
Apply suggestions from code review
d772ea0
Co-authored-by: Jeroen Ketema <[email protected]>
@ihsinme
Update ImproperCheckReturnValueScanf.expected
bfec3c5
@ihsinme
Update test.cpp
e9fefab
@ihsinme
Update ImproperCheckReturnValueScanf.ql
a6654fc
jketema
jketema reviewed Mar 2, 2022
View reviewed changes

@jketema jketema left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates, especially making the tests cover more cases.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ihsinme reacted with laugh emoji
All reactions
  • 😄 1 reaction
Comment thread cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

ihsinme and others added 7 commits March 3, 2022 10:14
@ihsinme @jketema
Apply suggestions from code review
1a30b8d
Co-authored-by: Jeroen Ketema <[email protected]>
@ihsinme
Update test.cpp
547342c
@ihsinme
Update test.cpp
2dc85e1
@ihsinme
Update test.cpp
25b3aba
@ihsinme
Update test.cpp
8e0c0ad
@ihsinme
Update ImproperCheckReturnValueScanf.expected
bec4170
@ihsinme
Update test.cpp
01f9114
jketema
jketema reviewed Mar 4, 2022
View reviewed changes
Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

jketema
jketema reviewed Mar 4, 2022
View reviewed changes
Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

jketema
jketema reviewed Mar 4, 2022
View reviewed changes
Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

jketema
jketema reviewed Mar 4, 2022
View reviewed changes
Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

jketema
jketema reviewed Mar 4, 2022
View reviewed changes
Comment thread cpp/ql/src/experimental/Security/CWE/CWE-754/ImproperCheckReturnValueScanf.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

jketema
jketema reviewed Mar 4, 2022
View reviewed changes
Comment thread cpp/ql/test/experimental/query-tests/Security/CWE/CWE-754/semmle/tests/test.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

ihsinme and others added 2 commits March 8, 2022 07:42
@ihsinme @jketema
Apply suggestions from code review
c0c7748
Co-authored-by: Jeroen Ketema <[email protected]>
@ihsinme
Update ImproperCheckReturnValueScanf.qhelp
8335778
@ihsinme

ihsinme commented Mar 8, 2022

Copy link
Copy Markdown
Contributor Author

I want to thank you for your corrections.
especially the English text.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ihsinme added 6 commits March 10, 2022 10:12
@ihsinme
Update test.cpp
5e23615
@ihsinme
Update ImproperCheckReturnValueScanf.expected
4b451cf
@ihsinme
Update test.cpp
fa3ce61
@ihsinme
Update test.cpp
a094e6f
@ihsinme
Update test.cpp
623f3fb
@ihsinme
Update ImproperCheckReturnValueScanf.expected
ac8adea
jketema
jketema approved these changes Mar 11, 2022
View reviewed changes

@jketema jketema left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ihsinme reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@jketema
jketema merged commit a8b2805 into github:main Mar 11, 2022
@ihsinme ihsinme mentioned this pull request Mar 14, 2022
[CPP]: Add query for CWE-754: Improper Check for Unusual or Exceptional Conditions when using functions scanf github/securitylab#553
Closed
1 of 2 tasks
@d10c d10c mentioned this pull request Aug 24, 2022
C++: New Query: missing return-value check for scanf-like functions #10163
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jketema jketema jketema approved these changes
+1 more reviewer
@Sergo2106 Sergo2106 Sergo2106 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@jketema jketema

Labels

C++ documentation

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ihsinme @jketema @Sergo2106
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.