Skip to content
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 matches for empty commented line #1645

Closed
LeeShan87 opened this issue Jan 4, 2018 · 6 comments
Closed

@pmFromFile matches for empty commented line #1645

LeeShan87 opened this issue Jan 4, 2018 · 6 comments
Assignees
Labels
3.x Related to ModSecurity version 3.x enhancement RIP - libmodsecurity

Comments

@LeeShan87
Copy link

Hi,

We experienced a strange bug when testing libmodsecurity with crs.
The Chinese search engine ( spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07); ) always got caught by the crs's 913100 rule which looks for suspicious user agent from a file https://github.com/SpiderLabs/owasp-modsecurity-crs/blob/v3.0/master/rules/scanners-user-agents.data

After looking in the the list of user agents we haven't found anything close which could trigger this rule.

With PostMan I played with this user agent string and found that the problematic character was: "#"
spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07); -> trigger 913100
spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm07); -> not trigger 913100

After removing every empty comment line and reloading ModSecurity it worked as it accepted.

Empty and commented lines should be ignored as the reference manual says: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#pmFromFile

@dune73
Copy link
Member

dune73 commented Nov 6, 2018

I can confirm this issue. Surfaced with CRS.

See SpiderLabs/owasp-modsecurity-crs#1215

@lifeforms
Copy link

lifeforms commented Nov 6, 2018

We have included a workaround for this problem in CRS 3 development branch by removing lonely # lines in pmf data files.

SpiderLabs/owasp-modsecurity-crs#1230

We plan to issue a release candidate 3.1-RC2 around Nov 11th. Those suffering from this issue please testdrive it if you can.

For those who hit this problem in the future, upgrading your CRS to 3.1 or later will resolve the issue.

@victorhora
Copy link
Contributor

victorhora commented Mar 10, 2019

@tdoubley provided a possible solution here: fb020c5

My suggestion would be having isComment() as a more "global" solution for all features that loads content from a file and needs to ignore comments (#). Might be the case for ipMatchFromFile and a few others.
isComment() should maybe reside at utils:: namespace, at string.cc.

What do you think @zimmerle ? :)

@zimmerle zimmerle removed this from the v3.1.0 milestone Nov 21, 2019
@zimmerle
Copy link
Contributor

zimmerle commented Nov 22, 2019

v2.x empty lines and # are ignored -
https://github.com/SpiderLabs/ModSecurity/blob/v2/master/apache2/re_operators.c#L1321

Testing fb020c5 here -
https://github.com/SpiderLabs/ModSecurity/tree/v3/dev/issue_1645

zimmerle added a commit that referenced this issue Nov 22, 2019
@zimmerle
Copy link
Contributor

Fixed as of: 42a16c7

@zimmerle
Copy link
Contributor

@tdoubley provided a possible solution here: fb020c5

My suggestion would be having isComment() as a more "global" solution for all features that loads content from a file and needs to ignore comments (#). Might be the case for ipMatchFromFile and a few others.
isComment() should maybe reside at utils:: namespace, at string.cc.

What do you think @zimmerle ? :)

Let's make it part of pmf for now, as it is already ready. Later on, we move it towards a more global thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Related to ModSecurity version 3.x enhancement RIP - libmodsecurity
Projects
None yet
Development

No branches or pull requests

5 participants