-
Notifications
You must be signed in to change notification settings - Fork 1.9k
CPP: Add query for CWE-191 into experimental this reveals a dangerous comparison #4745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
into experimental this reveals a dangerous comparison
|
Thanks for the contribution! I'm curious to see the results of this query in practice. Our contribution guidelines for To get you started, I've set the query running on 97 real-world projects: https://lgtm.com/query/240395435018513940/. You can use that URL to see the results and to modify the query and re-run it on those same projects. I've made one change to your query already, replacing Please look through the results, revise the query as necessary, and report on how many good and bad results there are. A good result is one that the project maintainers are likely to fix. As you look over the results, I recommend that you consider whether the query and/or its results are applicable for a bounty from GitHub Security Lab: https://securitylab.github.com/bounties. |
|
This is an interesting query. A quick sample of results looks promising. There are some of the form @jbj spotted: where the cast is 'too late' in that the subtraction has already been performed on unsigned numbers, but both unsigned overflows and the conversion back to signed are well defined and probably produce the correct result in the end. We should exclude these cases. For the For the I ran some statistics comparing this query to |
|
I'm sorry I'm probably too worried. |
|
again sorry for accidentally closing.
thanks for your recommendations, I'm working on them now.
I want to draw your attention to the fact that I have one positive experience with this error. openssl/openssl#13515.
I also plan to select some of the triggers from https://lgtm.com/query/240395435018513940/ and suggest a fix for them, but it will take time.
thanks for the hint. I ask you to clarify whether I should wait for the acceptance of PR or can I send an application now. |
thanks.
I agree that this code will work correctly. I will think about how to exclude it.
absolutely right. but I suggested that this exception be included in the description. since in my opinion, the use of ranges does not guarantee the elimination of false detection.
I will definitely watch it. |
If this is detected by the query, that's good enough for
It's excluded by the
If you're going for The Bug Slayer (discover a new vulnerability), my understanding is that you need to go through the CVE process for a specific bug first and then open an issue. If you're going for All for one, one for all (add a new query), you should open an issue now. |
|
analyzing project data, I created 7 PRs in different projects. I hope to demonstrate their result soon. I would like to separately note the situation in which PR will probably not be accepted. it is the use of macros for comparison. like in the project radareorg / cutter #define R_MAX (x, y) (((x)> (y))? (x) :( y)). I would not call it a false detection. |
|
It's a pattern we often see that seemingly nonsensical code comes out of macro expansions. Here's an example of how to exclude it:
|
|
good afternoon.
the following projects still haven't responded.
at the end I ask you to consider that this is my first experience working with you. and I would be grateful for a hint in my next steps. |
|
Thanks, @ihsinme! The next step is to get this PR merged. All that's formally required is that you autoformat the QL code: in VSCode, press Ctrl+Shift+P and type Format Document<Enter>. I also strongly encourage you to incorporate the changes discussed on this PR: exclude macros and replace You've opened github/securitylab#208 to get a bounty for getting the query merged, and the ambition level there is up to you. You can create follow-up PRs to make the query more production-ready, following the steps in https://github.com/github/codeql/blob/main/docs/supported-queries.md. The query in its current state might already be eligible for a bounty (that's up to Security Lab, not me), but a more production-ready query would be eligible for a higher bounty. You can indicate on github/securitylab#208 that you're done improving the query. Until then, we'll continue to review any PRs you make to improve the query. |
|
First of all, I am grateful to you for your benevolent attitude towards the newcomer. it really matters to me. |
jbj
left a comment
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.
👍
The formatting looks good to me, so I've triggered the CI tests. When they pass, I'm happy for this PR to be merged.
Tweak whitespace, also in the alert message.
|
The autoformatter can also be run via the cli: |
Good afternoon.
This is my first query. Therefore, I am ready for criticism and correction. Hope for hints.
This error occurs quite often and can have consequences when working with memory, when the size of a piece is calculated as a difference.