Skills Development ModSecurity Web Logging

ModSecurity Web Logging

v20260317
implementing-web-application-logging-with-modsecurity
Configure ModSecurity and OWASP CRS to log web application traffic, tune false positives, switch from detection to blocking, and ship audit data to SIEM for threat monitoring.
Get Skill
413 downloads
Overview

Implementing Web Application Logging with ModSecurity

Overview

ModSecurity is an open-source WAF engine that works with Apache, Nginx, and IIS. The OWASP Core Rule Set (CRS) provides generic attack detection rules covering SQL injection, XSS, RCE, LFI, and other OWASP Top 10 attacks. ModSecurity logs full request/response data in audit logs for forensic analysis and generates alerts that feed into SIEM platforms.

Prerequisites

  • Web server (Apache 2.4+ or Nginx) with ModSecurity v3 module
  • OWASP CRS v4.x installed
  • Log aggregation infrastructure (ELK, Splunk, or Wazuh)

Steps

  1. Install ModSecurity and configure SecRuleEngine in DetectionOnly mode
  2. Deploy OWASP CRS v4 and set paranoia level (PL1-PL4)
  3. Configure SecAuditEngine for relevant-only logging
  4. Tune false positives with SecRuleRemoveById and rule exclusions
  5. Switch to blocking mode (SecRuleEngine On) after tuning period
  6. Forward audit logs to SIEM for correlation and alerting

Expected Output

ModSecurity: Warning. Pattern match "(?:union\s+select)" [file "/etc/modsecurity/crs/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"] [line "45"] [id "942100"] [msg "SQL Injection Attack Detected via libinjection"] [severity "CRITICAL"]
Info
Category Development
Name implementing-web-application-logging-with-modsecurity
Version v20260317
Size 9.33KB
Updated At 2026-03-18
Language