GrepBoard/Manuals
605 manuals ·

AlmaLinux 10.3 ModSecurity: check before moving to CRS 4

·Tested on AlmaLinux 10.3 AppStream repository queried from an AlmaLinux 9.9 container · mod_security 2.9.14 · mod_security_crs 4.22.0·Test scope ↓·7 steps

ModSecurity is back in AlmaLinux 10.3 and the rules jump from CRS 3.3.5 to 4.22.0. Check versions and how rules load, then trial detection-only mode first.

The AlmaLinux 10.3 release notes say "AlmaLinux 9 carries ModSecurity 2.9.6 with CRS 3.3.5, while 10.3 ships 2.9.14 with CRS 4.22.0", then warn: "CRS 4 is a rework of the rule set rather than a routine update, so rules and tuning carried over from the CRS 3.3 series will need reviewing." Before moving a setup from 9, check the following in order.

[1] Write down the installed versions on the current server (8 or 9). They are your baseline.

console
$ rpm -q mod_security mod_security_crs

[2] See which versions the repository carries. No 10.3 host was available, so the query points an AlmaLinux 9.9 container at the 10.3 repository. On a 10.3 host, dnf repoquery mod_security mod_security_crs is enough.

console
$ dnf -q --disablerepo='*' --repofrompath=a10,https://repo.almalinux.org/almalinux/10.3/AppStream/x86_64/os/ --setopt=a10.gpgcheck=0 repoquery --qf '%{name} %{evr}' mod_security mod_security_crsmod_security 2.9.14-1.el10mod_security_crs 4.22.0-1.el10

The 2.9.6 and 3.3.5 on the 9 side are the release notes' own wording.

[3] Download and unpack both packages without installing them. The rule files live in /usr/share/mod_modsecurity_crs/rules/, the configuration under /etc/httpd/.

console
$ mkdir -p /w && cd /w$ dnf -q --disablerepo='*' --repofrompath=a10,https://repo.almalinux.org/almalinux/10.3/AppStream/x86_64/os/ --setopt=a10.gpgcheck=0 download mod_security mod_security_crs >/dev/null 2>&1$ for f in *.rpm; do rpm2cpio $f | cpio -idm 2>/dev/null; done$ ls -l etc/httpd/modsecurity.d/activated_rules/ | tail -n +2-rw-r--r-- 1 root root 8998 Jan  5  2026 REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf-rw-r--r-- 1 root root 3018 Jan  5  2026 RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf

The file list holds only two exclusion files, which makes the rule folder look empty, but the package's post-install script links the files from rules/ into this folder.

console
$ rpm -qp --nosignature --scripts mod_security_crs-4.22.0-1.el10.noarch.rpmpostinstall scriptlet (using /bin/sh):if [ $1 == 1 ]; then     # activate base_rules…

The links are made only on if [ $1 == 1 ], the first install. On an upgraded server, check in step 7 that the rules are actually loaded.

[4] See how the configuration turns the engine on. The default is On (blocking), and only three folders are included.

console
$ grep -nE "^[[:space:]]*(SecRuleEngine|SecAuditLog) " etc/httpd/conf.d/mod_security.conf3:    SecRuleEngine On45:    SecAuditLog /var/log/httpd/modsec_audit.log$ grep -rnE '^\s*Include' etc/httpdetc/httpd/conf.d/mod_security.conf:52:	IncludeOptional modsecurity.d/*.confetc/httpd/conf.d/mod_security.conf:53:	IncludeOptional modsecurity.d/activated_rules/*.confetc/httpd/conf.d/mod_security.conf:54:	IncludeOptional modsecurity.d/local_rules/*.conf

No line includes /usr/share/mod_modsecurity_crs/rules/ directly, so rules load only through the links in activated_rules/.

[5] What not to carry over from CRS 3 is in the CRS installation docs and part 1 of the migration series, which opens with "CRS 4 is not a drop-in replacement for CRS 3."

What changedOfficial wordingWhat to do
crs-setup.conf"…new variables, renamed variables, and removed variables."Do not copy the file from 9; configure it afresh
Per-application exclusions"…removal of application exclusion packages in favor of a plugin system."If you used exclusion packages, get the plugins
Rule IDs"Rule IDs have changed or been removed."Check each ID your own exclusions point to still exists

[6] Run without blocking first. The ModSecurity 2 reference manual-Configuration-Directives) gives SecRuleEngine On|Off|DetectionOnly and describes DetectionOnly as "process rules but never executes any disruptive actions (block, deny, drop, allow, proxy and redirect)". Save the current file first.

console
# cp -p /etc/httpd/conf.d/mod_security.conf /root/mod_security.conf.orig

Replace the SecRuleEngine On line with this one.

/etc/httpd/conf.d/mod_security.conf
   SecRuleEngine DetectionOnly
console
# httpd -t && systemctl reload httpd

To roll back, restore the saved file instead of editing the line back by hand.

console
# cp -p /root/mod_security.conf.orig /etc/httpd/conf.d/mod_security.conf# httpd -t && systemctl reload httpd

[7] An empty log does not mean the traffic is clean: it looks the same when no rules are loaded. First check that the links exist (ls -l /etc/httpd/modsecurity.d/activated_rules/ should show REQUEST-9xx-… links besides the two files from step 3), then send the check request from the CRS installation docs to your own test server only. The docs give curl 'https://www.example.com/?foo=/etc/passwd&bar=/bin/sh', which depending on thresholds should be detected as malicious and logged to the audit log (here the /var/log/httpd/modsec_audit.log from step 4). Only once that detection works, collect the rules that fire on legitimate requests, add exclusions on the REQUEST-900-… side from step 3, and restore the saved file to turn On back on.

#almalinux#modsecurity#owasp-crs#httpd