-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
pmFromFile and matching problems #1167
Comments
I'll start with the thing I first noticed and maybe it will help. This is in Phase 1, too my understanding it shouldn't be since your inspecting file data. https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#phase-request-body |
Thanks for your help @csanders-git From my understanding, modsecurity has the filenames at phase 1. It should or I don't understand how it can know what to process. Maybe not all arguments as the manual says, but the filename requested yes. The fact that my first example works in phase 1 shows that. The difference with my second example is the use of the action pmFromFile instead of putting all extensions directly in the rule. And if I put the complete filename in the file, it works too. The problem seems that modsecurity doesn't take each line from the file and check if it can find that pattern in the filename but only do a string comparison. But from the manual and the section about false positives, putting 'png' on a line should trigger a 'return 1' for filenames like 'anything.png' or 'png.blabla'. |
i'm thinking (but not entirely sure) that you are thinking about this backwards. For example. if the INPUT from modsecurity was 1.2.3.1 (REMOTE_ADDR for instance) and we did a pmf such as: |
I see your point.
For me, "the phrase 1.2.3.4" means 1.2.3.4 in the file. What gives me some certainty is the the § explains boundaries with the 1.2.3.4 ip address. So /1.2.3.4/ can only be in the file Then... 1.2.3.4 -> triggered by request ip address 1.2.3.4 & 1.2.3.40
As I said, all of this is a bit confusing. |
I did several tests to see where the problem is. The rule:
In my file, I tried this:
And here are the results:
These results are very very confusing. |
I was just wondering if there were any news on this. Despite the wording of the Reference Manual, I have likewise noted that, when using @pmFromFile, an entry of 'aaa' in the file will not match 'aaabbb' in input. Indeed, CRS3.0 seems to assume that phrases in a file will be subject to exact match rather than substring. For example, REQUEST-933-APPLICATION-ATTACK-PHP.conf uses php-function-names-933151.data which has numerous examples of successive phrases where one is a substring of the others, for example: If the @pmFromFile actually worked the way the Manual suggests (not checking for boundaries and thus acting like a substring checker) then there would be no point to having both lines (the first of the two would be sufficient). |
I couldn't reproduce this on the latest code in v2.9 branch master:
Same for v3.x:
Please let us know if the issue persist on the current versions and we can investigate further. Thanks! |
Server: Debian Wheezy
libapache2-mod-security2: v2.8.0-2~bpo70+1
modsec rules: last from git
A simple test.php file including this code:
I have a rule to catch all static files and for them skip my next custom rules.
This one works:
This one doesn't:
Well, it works only when I put the complete filename in it (screenshot.png), but doesn't work when I try to put only file extensions:
From what I read in the reference manual (https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#pmFromFile -> point 4), it should be able to match all files finishing by png.. or am I mistaken.
Thanks
The text was updated successfully, but these errors were encountered: