-
Notifications
You must be signed in to change notification settings - Fork 290
Match rule transform POST in GET #258
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
Hello @cello86 , I'm not sure I understand the use case that you are describing. Note that ModSecurity (including the nginx connector) is the "engine". CRS is a generic rule set that is often used with ModSecurity. From what have included, however, what you are seeing sounds like it might be expected behaviour related to error redirects. You may wish to have a look at the following for more detail: #152 (comment) If you think what you are experiencing is unrelated to that, please provide additional detail. |
Hi @cello86,
Marcello |
Hello @cello86 , Perhaps I've misunderstood something but how does that configuration result in 'without mod_security enabled'? You explicitly have 'modsecurity on' within the outside server block. So it will still be 'on' inside the 'location ^~ /error' -- which it seems you understand because you include an extra modsecurity_rules entry there. That extra rule includes an action 'ctl:ruleEngine=DetectionOnly', so rules that are impacted by that will, of course, use Detection Only. However even for rule detections after that point, you will still see the effect of the GET requests that were originally POSTs (e.g. in logging). Note also that your "id:1" rule will run later than at least some other rules (you have it as a phase:2 rule), you could have a look at the DebugLog output to confirm which rules are being run in which order. If none of the above clarifies things for you, I think you're going to have to describe in more detail, what effects exactly you are seeing and how you expect them to be different. |
Was there anything further on this? |
Nginx handles `error_page` via `ngx_http_internal_redirect`, and audit log in `ModSecurity-nginx` is trigged in the next handler. In nginx's code, it's harded to `GET` for non-`HEAD`, refers https://github.com/nginx/nginx/blob/master/src/http/ngx_http_special_response.c#L618-L621: ```c if (r->method != NGX_HTTP_HEAD) { r->method = NGX_HTTP_GET; r->method_name = ngx_http_core_get_method; } ``` This patch use `method_name` from `request_line` to fix this issue. This should fix method name in owasp-modsecurity#182, and solve owasp-modsecurity#258.
Nginx handles `error_page` via `ngx_http_internal_redirect`, and audit log in `ModSecurity-nginx` is trigged in the next handler. In nginx's code, it's harded to `GET` for non-`HEAD`, refers https://github.com/nginx/nginx/blob/master/src/http/ngx_http_special_response.c#L618-L621: ```c if (r->method != NGX_HTTP_HEAD) { r->method = NGX_HTTP_GET; r->method_name = ngx_http_core_get_method; } ``` This patch use `method_name` from `request_line` to fix this issue. This should fix method name in owasp-modsecurity#182, and solve owasp-modsecurity#258.
Hi All,
we noticed on modsecurity for Nginx connector a strange behavior. If a rule is matched before the normal CRS rules engine the HTTP method is noticed like GET instead the original POST.
We already had some issues with the internal redirects but the matching on different phases can generate this type of error?
Thanks,
Marcello
The text was updated successfully, but these errors were encountered: