Open
Description
Describe the bug
In libmodsecurity3, SecAction can't be disabled via a ctl action like with SecRules. This issue isn't present in ModSecurity2.
Logs and dumps
N/A
To Reproduce
Steps to reproduce the behavior:
- Have a fresh Ubuntu 22.04 server setup, this bug was a bit tricky to reproduce when I was opening this issue.
- ModSecurity was tested and installed using digitalwave's ModSecurity repository and
apt install nginx-extras libnginx-mod-http-modsecurity
- I installed this version of CRSv4 RC-2 and ModSecurity.conf with the
SecRuleEngine
directive set to on, but it shouldn't matter what rulesets are used. - Create this test conf file, but make sure to load it before any blocking rules (i.e
Include /etc/nginx/modsecurity/coreruleset/rules/*.conf
)
SecRule REQUEST_HEADERS:Host "!@streq example.com" "id:1,phase:1,pass,t:none,nolog,ctl:ruleRemoveById=2"
SecAction \
"id:2,phase:1,pass,t:none,nolog,ctl:ruleRemoveByTag=OWASP_CRS"
- restart nginx then try to send an attack payload, rule 2 should be disabled yet it still disables OWASP_CRS
curl 127.0.0.1?exec/bin/bash
- If you modify the test file to this, then rule 2 is disabled and everything works as expected:
SecRule REQUEST_HEADERS:Host "!@streq example.com" "id:1,phase:1,pass,t:none,nolog,ctl:ruleRemoveById=2"
SecRule REQUEST_FILENAME "@unconditionalMatch" \
"id:2,phase:1,pass,t:none,nolog,ctl:ruleRemoveByTag=OWASP_CRS"
Expected behavior
SecActions rules should be disableable via a ctl action, just like SecRules.
Server:
- ModSecurity version (and connector): libmodsecurity 3.0.12 and ModSec-Nginx 1.0.3
- WebServer: Nginx 1.18.0
- OS: Ubuntu 22.04
Rule Set:
Additional context
This issue currently affects some CRS plugins such as Nextcloud or WordPress, if you wish to use them in a reverse proxy and want to selectively enable/disable the plugins for certain domains.