GrepBoard/매뉴얼
605 편 ·

AlmaLinux 10.3 ModSecurity CRS 4 전환 전 확인

·시험 환경 AlmaLinux 10.3 AppStream 저장소 조회 (AlmaLinux 9.9 컨테이너에서) · mod_security 2.9.14 · mod_security_crs 4.22.0·시험 범위 ↓·6 단계

AlmaLinux 10.3 에 mod_security 가 돌아왔고 규칙은 CRS 3.3.5 에서 4.22.0 으로 건너뜁니다. 패키지 판과 규칙이 실리는 방식을 확인하고 탐지 전용 모드로 먼저 시험합니다.

AlmaLinux 10.3 릴리스 노트는 "AlmaLinux 9 carries ModSecurity 2.9.6 with CRS 3.3.5, while 10.3 ships 2.9.14 with CRS 4.22.0" 라고 적고, 이어서 "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." 라고 경고합니다. [1] 지금 서버(8·9)의 설치 판을 적어 둡니다.

console
$ rpm -q mod_security mod_security_crs

[2] 저장소의 판을 봅니다. 아래는 AlmaLinux 9.9 컨테이너에서 저장소 주소를 직접 지정해 조회한 것입니다. 10.3 서버에서는 dnf repoquery 만 쓰면 됩니다.

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

[3] 두 패키지를 설치하지 않고 받아서 풀어 봅니다. 규칙 본체는 /usr/share/mod_modsecurity_crs/rules/ 에 있습니다.

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

패키지 파일 목록에는 제외 규칙 둘뿐이지만, 설치 후 스크립트가 rules/ 의 파일을 이 폴더에 링크로 겁니다.

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…

링크는 if [ $1 == 1 ], 곧 처음 설치할 때만 만들어지니 업그레이드한 서버는 7단계에서 확인합니다.

[4] 규칙 엔진 기본값은 On(차단)이고, 포함하는 폴더는 세 곳뿐입니다.

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

rules/ 를 직접 포함하는 줄은 없어 규칙은 activated_rules/ 의 링크로만 실립니다.

[5] CRS 3 에서 가져가면 안 되는 것은 CRS 설치 문서와 이전 안내 1부에 있습니다. 1부의 첫 문장은 "CRS 4 is not a drop-in replacement for CRS 3." 입니다.

  • crs-setup.conf 는 "new variables, renamed variables, and removed variables" 가 있으니 9 의 파일을 복사하지 않습니다.
  • 응용별 제외 패키지는 플러그인으로 바뀌었습니다("a plugin system").
  • "Rule IDs have changed or been removed." 직접 쓴 제외 규칙의 번호가 남아 있는지 봅니다.

[6] 막지 않는 모드로 먼저 돌립니다. ModSecurity 2 참조 매뉴얼-Configuration-Directives)은 DetectionOnly 를 "process rules but never executes any disruptive actions (block, deny, drop, allow, proxy and redirect)" 라고 설명합니다. 고치기 전에 현재 파일을 보관합니다.

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

SecRuleEngine On 줄을 아래 줄로 바꿉니다.

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

되돌릴 때는 보관본을 그대로 복원합니다.

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

[7] 기록이 비어도 안전한 것은 아닙니다. 규칙이 실리지 않아도 똑같이 비기 때문입니다. 먼저 ls -l /etc/httpd/modsecurity.d/activated_rules/ 에 REQUEST-9xx-… 링크가 있는지 보고, CRS 문서의 확인 요청을 자기 시험 서버로만 보냅니다. 문서는 "curl 'https://www.example.com/?foo=/etc/passwd&bar=/bin/sh'" 가 임계값에 따라 악성 요청으로 탐지되어 감사 로그(여기서는 4단계의 /var/log/httpd/modsec_audit.log)에 남아야 한다고 적습니다. 탐지를 확인한 뒤에야 정상 요청에 걸리는 규칙에 REQUEST-900-… 쪽 제외 규칙을 넣고, 정리되면 보관본을 되돌려 On 을 켭니다.

#almalinux#modsecurity#owasp-crs#httpd