-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Behavior change in regex macro expansion from 2.9.7 to 2.9.8 affecting CRS 3.2.x and 3.3.x #3380
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
Comments
Hi @dune73, thanks for reporting this. You mentioned issue #2357, but I think the behavior was changed in #2912, where the title explains: "Do not escape special chars in regex pattern with macro". In the "expected behavior" block you wrote:
We can fix this only if we rolling back that change. Anyway, I believe it's hard to decide what is the correct behavior. I think arguments from @marcstern are valid (and I guess the fix was created to solve those). A plus argument beside this behavior that libmodsecurity3 also uses the non-escaped form (based on this comment). So I'm curious about other users' opinion, what do they think about this. |
Adding another opinion: As OWASP CRS v3.3.x is currently the only release that has been supported long term it still has lots of users, as we know. If this change breaks a PL1 rule for all ModSec v2 users that seems like a big problem. Do we know what Coraza does? Were v2 and Coraza in alignment before the change? Or are v2 and v3 and Coraza all now in alignment after the change? |
Thank for your considered positions here. It's indeed hard to tell what the correct behavior is. It's unfortunate this was pushed without noticing the consequences for CRS. And now a lot of time has passed and a rollback is equally discomforting. If only ModSec had a proper test suite... What beats me is that nobody reported this before. |
Agree.
Yes, definitely it is.
Good question - let's ask Coraza devs, so CC @fzipi, @M4tteoP, @jptosso, @jcchavezs - how Coraza handles this situation? Also please consider the next step: if we decide to revoke that PR, then we should align libmodsecurity3 too. |
~~@airween and @RedXanadu
Edit: look at Matteo's message |
So if I write a rule that carries a regex pattern in a variable, there is no macro expansion in Coraza (or no option to write my own rules)? |
Hey, based on the following quick try, Coraza is performing macro expansion only for some operators, not for regexes.
Sending
Sending
|
Thanks @M4tteoP for the explanation. Honestly, now I'm a bit confused, because @jptosso wrote that "Coraza used libmodsecurity as a reference", and now you wrote that "Coraza is performing macro expansion only for some operators, not for regexes". But as I see libmodsecurity3 does macro expansion. (Btw the original question was that the Here are the results of your test cases (used same rules): Nginx:
Both operator matched.
None of them were matched. Apache
As we can see here both engines follows the same way. To solve this issue: I can imagine that we add a compilation flag (to |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
The way macros are expanded to regex patterns in rules changed from ModSecurity 2.9.7 to 2.9.8.
This affects CRS 3.2.x (920420, 920480) and CRS 3.3.x (920480) that both use the feature. CRS 4.x no longer uses this features and is thus not affected.
Logs and dumps
ModSecurity 2.9.7 debug log
ModSecurity 2.9.8 debug log
To Reproduce
The content type
application/soap+xml
is in the list of allowed content-types for CRS 3.2.3 by default. With ModSecurity 2.9.8 it is suddenly no longer accepted and rule920420 PL1 Request content type is not allowed by policy
is being triggered by this Content-Type.Expected behavior
Regex macro expansion behavior is the same between 2.9.7 and 2.9.8. The curl call above should not trigger CRS 920420 in version 3.2.3.
Server (please complete the following information):
Rule Set (please complete the following information):
Additional context
PR #2357 might be a candidate for the introduction of this bug.
The text was updated successfully, but these errors were encountered: