跳至正文

ModSecurity WAF Integration

Overview

ModSecurity is an open-source web application firewall engine compatible with Apache, Nginx, and IIS. KYRA MDR collects ModSecurity audit logs for web application threat detection. Supports ModSecurity v2 and v3.

Prerequisites

  • A KYRA MDR Collector installed and running
  • ModSecurity installed on Apache or Nginx
  • OWASP Core Rule Set (CRS) or custom rules
  • Network connectivity from the web server to the collector

Configuration

Configure ModSecurity audit logging:

modsecurity.conf
SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus "^(?:5|4(?!04))"
SecAuditLogType Serial
SecAuditLog /var/log/modsec_audit.log
SecAuditLogParts ABCFHZ

Forward logs via rsyslog:

/etc/rsyslog.d/modsecurity.conf
module(load="imfile")
input(type="imfile" File="/var/log/modsec_audit.log" Tag="modsecurity")
if $syslogtag == 'modsecurity' then @@<collector-ip>:514

For ModSecurity v3 with JSON:

SecAuditLogFormat JSON
SecAuditLog /var/log/modsec_audit.json

Collected Log Types

Log TypeDescriptionSecurity Use
AlertsRule match and block eventsWeb attack detection
SQL InjectionSQLi attempt detectionsDatabase attack prevention
XSSCross-site scripting detectionsClient-side attack prevention
File InclusionLFI/RFI attempt detectionsServer-side attack prevention
Request AnomalyAnomaly score threshold eventsBehavioral detection
Scanner DetectionAutomated scanner detectionsReconnaissance detection

Troubleshooting

No audit logs: Verify SecAuditEngine is set to On or RelevantOnly.

Incomplete log data: Use SecAuditLogParts ABCFHZ to include all relevant sections.

High false positives: Tune the OWASP CRS paranoia level. Start with level 1.

Contact kyra@seekerslab.com for support.