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

Variable names are always lowercased in collections #946

Closed
blotus opened this issue Dec 21, 2023 · 2 comments
Closed

Variable names are always lowercased in collections #946

blotus opened this issue Dec 21, 2023 · 2 comments
Labels

Comments

@blotus
Copy link
Contributor

blotus commented Dec 21, 2023

When coraza parses incoming requests to build the various collections, it automatically lowercases every variable name. While it is desirable in many situations, it poses limitations in scenarios where exact, case-sensitive matching is necessary (and according to the HTTP RFC, parameter names are case-sensitive, and most applications will process them as such).

Use case

We are adding WAF capabilities in crowdsec, and we are currently focusing on the virtual patching aspect (as it's something that's, in theory, less prone to false positives, in contrast to using the CRS on any moderately complex website, at the cost of having more rules to maintain).

When writing a rule for CVE-2023-50164 (you can check this Trend Micro blog post for more information, we realized that's it's not possible to write a rule that matches exactly on the case of a variable:

  • in this case, to make the rule as precise as possible and avoid false positive, we want to match on any variable that ends with FileName and contains ../, but because the variables are always lowercased in the collections, it's not possible to write something like ARGS:/.+FileName$/

For reference, the rules we use are:

SecRule REQUEST_METHOD "@streq POST" "id:1432913253,phase:2,deny,log,msg:'crowdsecurity/test-rule',tag:'crowdsec-crowdsecurity/test-rule',chain"
SecRule ARGS_POST:/.+FileName$/|ARGS_GET:/.+FileName$/ "@contains ../" "id:3576701872,phase:2,deny,log,msg:'crowdsecurity/test-rule',tag:'crowdsec-crowdsecurity/test-rule'"

(It's autogenerated from our own DSL, so ignore the weird ids)

@jptosso jptosso mentioned this issue Dec 27, 2023
16 tasks
@M4tteoP
Copy link
Member

M4tteoP commented May 27, 2024

Related issue #1041 and PR #1059.

@M4tteoP
Copy link
Member

M4tteoP commented May 28, 2024

Implemented in #1059, and tracked in #945 to make it the default behavior in the next major version. Right now is under coraza.rule.case_sensitive_args_keys build tag. Please, feel free to raise any concerns or feedback if you give it a shot :)

@M4tteoP M4tteoP closed this as completed May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants