-
Notifications
You must be signed in to change notification settings - Fork 62
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
Ruleset rumor reduction & Undefined behavior rule #3
Comments
Hi @zi0Black, Thank you for your kind feedback. Indeed, the issue you report is real: there's some overlap between different rules in my ruleset, the prime example being the interesting-api-calls rule that sort of overlaps with most other rules. This is a wanted feature, because in my bug hunting workflow I'd rather get some false positives than miss a single true positive. That said, in my ruleset you have some rules that are aimed to direct the auditor's focus on "code smells" and some other rules that try to detect a specific bug or bug class. I believe this is the source of the confusion: I'll leave this issue open and I'll think about how I could solve it (perhaps by classifying the rules in different categories?). Regarding your Your second example I hope my reply makes sense! Thanks again for taking the time to test my ruleset and report this issue. PS. I always read your posts on Shielder's blog with pleasure, so keep up the great work! |
Hi @0xdea, Regarding the For the undefined behavior rules, it's clear to me your point. |
First of all, @0xdea, you have done great work there with the coverage, also if the support offered by semgrep is still limited.
I found that some C/CPP functions are flagged as vulnerable code in multiple rules, I will go through the one I faced and propose a fix to reduce the rumor produced by the ruleset.
Take the following call
vsnprintf(NULL, 0, fmt, string);
, this call has a deterministic behavior. Since an amount of 0 bytes is copied to the destination buffer, the first argument of thevsnprintf
can be a NULL pointer. The length of the potentially copied data (in the destination buffer if it was big enough) is returned and can be used for other purses (e.g., allocating an appropriate buffer).I think that the rule
format-string-bugs.yaml
should not match this case since it's eventually caught by the ruleunsafe-ret-snprintf-vsnprintf.yaml
.Suggested change to the "format-string-bugs" rule (I can make the PR if I receive positive feedback):
I don't know if eventually could be interesting to have a rule for undefined behavior e.g.,
vsnprintf(NULL, 100, fmt, string)
, since this will result in writing some data to a NULL pointer, I didn't investigate it but someone can delight me regarding this 😄. More generally speaking, catch some undefined behavior could be interesting from a security perspective IMHO.References:
The text was updated successfully, but these errors were encountered: