-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
ModSecurity does not block request, only logs, while SecRuleEngine is set to On #4385
Comments
Nginx accepts the config and it not rejecting it and remaining on previous version of nginx.conf: to be sure I check the logs for the ingress controller pods and added an extra response header through a configuration snippet. Nginx.conf: https://www.dropbox.com/s/2rj9r53ftbowl0o/nginx.conf?dl=0 |
Can also verify that this is a issue. Logs are being created but no block action being done. |
I also have the same issue with nginx 0.25.0.
With |
The issue is still seen with 0.25.1
Warnings are being logged in modsec_audit.log but no blocking actions are being made. |
Please clarify if ModSecurity integration will get attention. If not, discontinue the feature, because currently it feels like we're waisting our time with it. |
What do you mean? We updated the configuration in the last update of the nginx image here efc6645#diff-4a5113d28634e29f2ab0bca34da7a3e5R333 (not released yet). Please use |
Just tried with :dev , this time it didn't even log anything to the /var/log/modsec_audit.log file when trying an command and just passes an 404 Snips from the nginx.conf modsecurity on; modsecurity_rules ' nginx version: openresty/1.15.8.2 |
To those affected by this issue, please check the gist test-modsecurity.sh Use it:
This script:
|
Checked the code and reapplied the ingress on our test env, with the same issues i.e no blocking is being made. In fact, with the :dev release no detection is seen in the modsec_audit.log |
I ran into this issue. Even with SecRuleEngine ON I only get logs and no blocks (403) when testing. I see the logs correctly catching the attacks but not blocking them.
Upon further review, I noticed the
Deploy nginx with the following additional configurations:
Modsecurity is now successfully blocking the requests
|
Closing. Please update to 0.26.0. The release contains fixes for modsecurity. Please reopen if the issue persists. |
This issue still seems to persist in 0.26.0 with even more strange behaviour. I've tried with:
Without any success. What's even more strange is that controller now seems to log everything to /var/log/modsec_audit.log, we can for an example see: |
I was getting crazy because of this bug, was in 0.25.1 with this problem, then updated to 0.26.1 and still the same behavior, looked at @mhauer71 post, downgraded to 0.24.1 and finally after 1 day and a half messing with this, now works as expected! Please reopen this issue, it's annoying until you realize that could be a bug @kwaazaar @aledbf |
I cannot reopen the issue, since a repo collaborator closed it. It's sad that ModSecurity support seems to be ignored by the team. |
I can confirm that it does not work for 0.28.0 either like @celamb4 said the files are not correct. Files are only saying "pass" if it will detect something. I have following in ingress configuration:
and when I do request for instance |
When I check generated nginx.conf (version 0.28.0) it looks following:
And when I check When I compare this to 0.24.1 which is working (returning 403).
So the difference in newer versions is that |
@zetaab reverting this could reintroduce #3585 Maybe we could enable |
I've got it working like this (with 0.27.1): ConfigMap: enable-modsecurity: "true" Ingress Annotation: nginx.ingress.kubernetes.io/modsecurity-snippet: |
SecRuleEngine On
Include /etc/nginx/owasp-modsecurity-crs/nginx-modsecurity.conf Now it blocks requests (403 Forbidden) like expected... Hope this helps |
Also got it working in 0.27.1 ConfigMap:
I had to add the SecRuleRemoveById 920350 to the ConfigMap to not have the /var/log/modsec_audit.log filled with entries for internal request. |
I can confirm that @pcallewaert works. However, my use-case is that I would like to have following:
I have not found way to do this. It is only possible to turn on in global way currently? tl;dr all ingresses are reporting secaudit things, but selected should have forced policy edit: Cool I got it working: configmap:
and then in ingress only this:
|
This work for me! |
I'am not working like this (with 0.30): #5343 |
Yes, I have same problem when I updated to 0.30 not working in 0.27.1 working fine, this is a problem because I can't update to latest version. |
Can confirm as well, not working in v 0.30, is anyone looking into this? Update: the file /etc/nginx/modsecurity/modsecurity.conf has SecRuleEngine set to DetectionOnly. I edited the file to On and it now works. Is there an easy way to just override this setting since it does not seem us setting this in the Ingress is making any difference. Update 2: I can confirm that this "DOES" work. After more investigations I found my team changed the configmap for my ingress so I was updating the wrong file. For anyone that lands here, if you 'kubectl edit configmap {name}' the correct configmap and save the changes you will see it working properly. |
I can confirm Its working on "0.32.0", here is my config -
Ingress Annotation:
|
Yes, I also confirm Its working on "0.32.0", problem solved! Thanks!!!! |
Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG
NGINX Ingress controller version: 0.25.0 (installed through helm chart nginx-ingress-1.10.1)
Kubernetes version (use
kubectl version
):v1.12.7
Environment:
uname -a
): 4.15.0-1052-azureWhat happened:
Request is not blocked by ModSecurity, only logged. Debug log says:
[4] Not running disruptive action: pass. SecRuleEngine is not On.
What you expected to happen:
Blocked request by returning HTTP 403, because SecRuleEngine is specified as on.
How to reproduce it (as minimally and precisely as possible):
controller:
config:
enable-modsecurity: "true"
enable-owasp-modsecurity-crs: "true"
nginx.ingress.kubernetes.io/modsecurity-snippet: |
SecRule REQUEST_HEADERS_NAMES "^x-waf-test" "log,deny,id:48,status:403,t:lowercase,msg:WAFWAFWAF"
SecRequestBodyAccess On
SecDebugLog /tmp/modsec_debug.log
SecDebugLogLevel 9
SecRuleEngine On
HTTP GET to /?test=%271%20OR%201=1&x=%3Cscript%3Ealert%28%27hello%27%29;%3C/script%3E
[156458238464.652956] [/?test=%271%20OR%201=1&x=%3Cscript%3Ealert%28%27hello%27%29;%3C/script%3E] [4] Not running disruptive action: pass. SecRuleEngine is not On.
Anything else we need to know:
I check logs with: kubectl -n kube-system exec -it internal-ingresscontroller-nginx-ingress-controller-7f8c6774w84 -- tail -f /tmp/modsec_debug.log
The text was updated successfully, but these errors were encountered: