-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Semantic of MATCHED_VARS / MATCHED_VARS_NAMES #3382
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
thanks for this detailed report. Just a side note before the relevant part:
I think we have to investigate this more, because as I remember, there is a problem with this variable in case of chained rules too. I have to look up that issue.
Yes, I think too. Especially if we take a look at the previous variable in (both) documentation: There is an explanation: I think the relevant part here is this: "this variable holds data for the last operator match". If we agree that these variables are similar, then the variable
I think this is not intentional, but a bug that we have to fix. But let others to explain their opinions - I mean what others say if we change a variable's behavior after N+1 years... |
I can't find the exact issue, but as I remember CRS does this trick because |
Hi @airween Another observation and why this is a little bit more relevant:
Consider this simplified version of chain rules similar to how they are used in core ruleset
What should The first rule contributes 1. If you disable the second rule, you get 1. But when both rules are there, the second rule contributes 2(!) to the score. So the final score is 3. It usually works in practice "by accident" because when you add a rule between 1 and 2 which is not matching anything, then MATCHED_VARS get cleaned. In my opinion, this is very brittle behavior. So the current semantic seems to be: "MATCHED_VARS is cleared on every non-matching SecRule" |
Agree. I can make a fix next week. |
Hi,
I have a question about the exact intended semantic of MATCHED_VARS / MATCHED_VARS_NAMES
The documentation is a little bit vague with
And all the examples and also the CoreRuleset always have this form: The second rule in the chain is accessing the matches from the first rule. So far, so good.
But what should happen if we have multiple rules (without chain)
From the documentation and my intuition, I would assume that the request
GET /?foo=1&bar=2&baz=2
against these ruleswould not block in rule 3, because
MATCHED_VARS_NAMES
should only contain the matches from rule 2:ARGS:bar
andARGS:baz
at this point in time.My assumption is:
After execution of rule 1:
After execution of rule 2:
So the 3rd rule should not match.
But when I add this as a regression test
and run it with the latest build
the test is failing with
I would consider this as a bug because apparently the collection MATCH_VARS_NAMES is never cleaned and collect all the data from all the previous rules.
If this is intended, I think at least a documentation update is needed and maybe the CoreRuleset rules should be adapted (other project, I know)
The text was updated successfully, but these errors were encountered: