4 - Mod Security Rules Packages

Starting version 1.6.2 stable you can now enable OWASP and Comodo Mod Security rules via one click.

Navigate to → https://:8090/firewall/modSecRulesPacks

Click the switch and it will turn on OWASP Rules, to verify if OWASP rules are installed successfully, open:

http://example.com/?a=b AND 1=1

You should get 403 Forbidden error, you can also see your ModSecurity Audit logs:

ModSecurity: Warning. detected SQLi using libinjection. [file "/usr/local/lsws/conf/modsec/owasp/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"] [line "17"] [id "942100"] [rev "1"] [msg "SQL Injection Attack Detected via libinjection"] [data "Matched Data:  found within ARGS:a: b AND 1=1"] [severity "2"] [ver "OWASP_CRS/3.0.0"] [maturity "1"] [accuracy "8"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-sqli"] [tag "OWASP_CRS/WEB_ATTACK/SQL_INJECTION"] [tag "WASCTC/WASC-19"] [tag "OWASP_TOP_10/A1"] [tag "OWASP_AppSensor/CIE1"] [tag "PCI/6.5.2"] [hostname "dev.cyberpanel.net"] [uri "/"] [unique_id "152317238285.808317"] [ref "v8,9t:utf8toUnicode,t:urlDecodeUni,t:removeNulls,t:removeComments"]
ModSecurity: Access denied with code 403 (phase 2). Matched "Operator `Ge' with parameter `5' against variable `TX:ANOMALY_SCORE' (Value: `5' ) [file "/usr/local/lsws/conf/modsec/owasp/rules/REQUEST-949-BLOCKING-EVALUATION.conf"] [line "36"] [id "949110"] [rev ""] [msg "Inbound Anomaly Score Exceeded (Total Score: 5)"] [data ""] [severity "2"] [ver ""] [maturity "0"] [accuracy "0"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-generic"] [hostname "dev.cyberpanel.net"] [uri "/"] [unique_id "152317238285.808317"] [ref ""]
ModSecurity: Warning. Matched "Operator `Ge' with parameter `5' against variable `TX:INBOUND_ANOMALY_SCORE' (Value: `5' ) [file "/usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-980-CORRELATION.conf"] [line "61"] [id "980130"] [rev ""] [msg "Inbound Anomaly Score Exceeded (Total Inbound Score: 5 - SQLI=5,XSS=0,RFI=0,LFI=0,RCE=0,PHPI=0,HTTP=0,SESS=0): SQL Injection Attack Detected via libinjection'"] [data ""] [severity "0"] [ver ""] [maturity "0"] [accuracy "0"] [tag "event-correlation"] [hostname "dev.cyberpanel.net"] [uri "/"] [unique_id "152317238285.808317"] [ref ""]

You can notice that rule from REQUEST-949-BLOCKING-EVALUATION.conf is triggered if you disable this file, you will not be getting 403 error.


Disable Rule Files

Once OWASP or Comodo rules are enabled you can also enable or disable individual rule files.

I have installed the security mod, but when i try to configure i get this page:

anything i could do?

1 Like


same issue mod security not working

1 Like

Same issue here, at a brand new installation of version 2.4.4 at Almalinux 9.

/home/cyberpanel/error-logs.txt does not report anything, even with debug mode enabled.

How can we resolve the issue and enable the owasp rules?

The same thing happens to me, it stays like that indefinitely and doesn’t load.

I also can agree, its not working. When toggling the OWASP, it looks like its turned on, but nothing happens. When the page is refreshed, its turned off again.

I detected that owasp directory doesn’t exist..This is a fresh install of CyberPanel..

ubuntu@host:~$ sudo ls -l /usr/local/lsws/conf/modsec total 4 -rw-r–r-- 1 root root 100 Nov 23 17:54 rules.conf ubuntu@host:~$ ubuntu@host:~$ sudo ls -l /usr/local/lsws/conf/modsec/owasp-crs ls: cannot access ‘/usr/local/lsws/conf/modsec/owasp-crs’: No such file or directory ubuntu@host:~$

Alright, I managed to get OWASP CRS working properly and confirmed it’s just a CyberPanel UI bug.

Fresh CyberPanel installs don’t ship with the owasp-crs folder at all, so the toggle will never stay enabled. You have to create it manually.

Here’s what I did:

sudo mkdir -p /usr/local/lsws/conf/modsec/owasp-crs
cd /usr/local/lsws/conf/modsec/owasp-crs

sudo wget https://github.com/coreruleset/coreruleset/archive/refs/heads/v3.3/master.zip -O crs.zip
sudo apt install unzip
sudo unzip crs.zip
sudo mv coreruleset-*/ rules

# Fix permissions so LSWS can read it
sudo chown -R lsadm:lsadm /usr/local/lsws/conf/modsec/owasp-crs

# Add CRS include lines
sudo nano /usr/local/lsws/conf/modsec/rules.conf

Add these at the bottom if they aren’t already there:

Include /usr/local/lsws/conf/modsec/owasp-crs/crs-setup.conf
Include /usr/local/lsws/conf/modsec/owasp-crs/rules/*.conf

Then restart:
sudo systemctl restart lsws

OWASP CRS loads fine after that (confirmed in the logs), even though the CyberPanel toggle still flips back to OFF. That part is definitely a UI bug and should be fixed by CP team.

Quick test (you should get blocked if CRS is working):
Visit something like:
https://your-domain.com/?test=<script>alert(1)</script>

OWASP will block it even though the toggle still turns OFF.
So CRS works, the UI toggle is the bug.

2 Likes

Above the guide you given was useful and I used it on many servers to fix the same now after the latest build 2.4.5 its not working.

I tried to apply it on my server after update it not works even the the default not works right now. In 2.4.5 ui toggle works fine but its not blocking the request like you given in the sample.

If you install fresh cyberpanel and install and activate ModSecurity WAF
Then you activate the OWASP ModSecurity Core Rules.
It does not block the requests

See this I also have reported the issue their is another user who reported it 4 days before me.

See if you can help with it. Currently Ui toggle is active and it shows packs but it does not block or ban ips.

Is this an actively maintained product?

I find this very strange, that something as old and unchanging as modsecurity isn’t functional from a baseline install.
I’m concerned about using workarounds to patch something like this.

I might as well skip the panel and just go back to my nginx self compiled approach.
Cause with fatal issues like this, I have to tell my staff “don’t click on this, oh yea that’s broken, use the “v2” of this and “regular” version of that in left-nav, and yes the purple popup at the top will not go away deal with it”.
All of which is really really concerning to me.

is this product maintained?
Even the documentation on official website has broken images throughout, and all the SEO links from outside link to an old docs page that was moved, so they didn’t even properly put 301’s in place or a dynamic rule for it.

It’s just literally everything about this product is screaming for me to run away.

A new CyberPanel install and I’ve followed your instructions, but just like @iabdulrehman, dodgy URLs aren’t being blocked.

@usmannasir it’s almost six months on from @shahz sharing his findings - given this issue is security related shouldn’t this be a high priority item to fix? Appreciate you letting us know when it’ll be fixed.