C++: Query for multiplications used in allocations.#4810
C++: Query for multiplications used in allocations.#4810MathiasVP merged 6 commits intogithub:mainfrom
Conversation
cpp/ql/src/experimental/Security/CWE/CWE-190/AllocMultiplicationOverflow.ql
Show resolved
Hide resolved
|
Looking at a small sample of results on LGTM, I think there are quite a lot of false positives where the numbers come from things that are probably known to be small. I've set the |
|
Added qhelp and changed this from a draft PR to 'ready for review'. I plan to create a |
|
@hubwriter please could I have a quick documentation review. For context, this is only being merged into 'experimental' (which has lower standards than other queries) for now, but it may be moved out in future so I'd prefer the qhelp be up to scratch. |
|
I believe this PR can be merged. |
MathiasVP
left a comment
There was a problem hiding this comment.
Indeed, this query (as is) has demonstrated its value in the hackathon. Let's investigate the changes needed to bring it out of experimental in another PR.
|
Created an issue for further improvements: https://github.com/github/codeql-c-analysis-team/issues/203 |
I assume this was an internal hackathon? |
Yep. (Sorry for not making that clear in my comment.) |
Experimental and rather quickly put together query for (non-constant) multiplication results that are used as the size for an allocation. This is a practically motivated query intended to be a fast way to find a common pattern for potential vulnerabilities - e.g. it showed some promise on VLC.
Related:
TODO now:
TODO later (i.e. not required for merging into experimental):
memset. In the long run, perhaps 'allocation' could be generalized to something like 'size of any buffer operation'?@jbj I'm interested in your thoughts on this. Note that the target is only experimental, at least for now.