-
Notifications
You must be signed in to change notification settings - Fork 84
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
Solving EasyRFI via new EasyRFINotice severity #69
Comments
@ScreamingDev Interesting idea, I've just been looking at that sniff for other reasons.
For the example you've posted, I still wouldn't consider that safe in any imaginable way - think: $foo = 'http://example.com/.htaccess';
require parse_url( $foo, PHP_URL_PATH );
However, path constants defined within the application could well be safe and it would be a nice option for the sniff to allow for a whitelist of such safe application path constants. These whitelists could possibly be predefined for the supported frameworks and enhanced by the ruleset used via setting a sniff property in a custom What do you think ? |
I neither consider this a very safe method. I would say (in general):
RFI is an example because dynamic includes are in almost any code out there and anyone using it would get:
Now a developer is empowered to exclude this severity from his sniffs:
After the developer (hopefully) understood that this is just hardening because: $foo = 'http://example.com/bring/me/to/document_root/.git';
echo parse_url( $foo, PHP_URL_PATH ); // "/bring/me/to/document_root/.git" would shift the RFI problem to an exploit problem. |
That's not an option. PHPCS only has The only thing which could be done here is to play with the If that road would be taken, it could (should) probably replace the
This is already possible and unrelated to the Every individual sniff errorcode can be excluded for a complete project by using a custom ruleset with an For individual issues inline ignore comments can be used to whitelist certain code |
This is correct - I am well aware about it:
But I would not use one of these methods to exclude
because I want to be aware that something is missing there.
So a third way in between could be a solution. However this may work for you - as I don't know the code of phpcs-security-audit so well. But now I know that a notice-like level is no option so I hope someone comes up with a good and simple solution for the severity . Thanks for talking about this. Fingers crossed :) |
A little bit of history of how things work in this tool. First of all, it clearly says on the README that it is a generator of false positive 😅. It's very verbose by default. ParanoiaMode is turned on by default for that reason. From that point of view, all WARNINGs are essentially NOTICEs that should be quickly dismissed by anyone doing a review. Think of is as an assistant for secure code review that helps you pointing to line of codes you want to see. It's effectively a tool to point to risky functions. If you see an ERROR, then it means that this is most certainty a problem and you should review that first. If you want to use it so that it's not that verbose, and only return issues that the certainty is high, you have to set ParanoiaMode to off. Now, fast forward 10 years later. People are actually running this in continuous environment, and thus I'm seeing a bigger need for suppression and false positive diminution than before. Their goal is not to run it one time to assist a review, but rather get the amount of warning/error to 0 at some point, showing that they considered all risks. Back to the issue at hand. I believe that what @ScreamingDev is asking is about reducing false positives in a way that the end user can signify to the tool that this code is actually "safe". In the tool, a function that serve to add some security control value (either explicitly in the function or by a side effect) is a called a mitigation. Having the tool know about those mitigations facilitate the reduction of false positive. Right now the tool only supports built-in mitigations as you can see in
The "EasyRFINotice" and it's exclusion proposed above is effectively a WARNING that disappear when a mitigation function is present. The proper solution for that would be to have user defined mitigation function per rule. We would also need to extend mitigation to not just a function but also parameters. In your config it would look like this:
And of course, if you want to actually have
Hope this clarify a bit. |
oh and phpcs-security-audit is a line by line scanner.
is as bad as any T_VARIABLE passed to Exclude this at your own risk. |
Thanks for that idea and all the background @jmarcil . I loved it! My first impression is: For the RFI example here the mitigation functions would be a thing. On second thought I knew that it is a line-by-line- or toker-by-token-parser which makes it hard to understand the context and react to it. So the mitigation may allow small mistakes like Anyway I hope to see some workaround for that some day. Until then using
solves it and (in addition) shows that someone actually reviewed this part. |
RFI would be:
After a short search I found no solution but what about this?
It would be great if the EasyRFISniff has some kind of "EasyRFINotice" severity when the dynamic includes seem to be escaped like this.
The text was updated successfully, but these errors were encountered: