Skip to content
hostcomplex

What Is ModSecurity?

Maarten Soetens 2 min read

How the ModSecurity Engine Works

What is ModSecurity? It is an open-source web application firewall engine. It examines HTTP requests and responses, applies a set of rules, and decides whether to allow, log or block each transaction. The engine itself is generic; the protection comes from the rules loaded into it.

It is commonly run as a module inside a web server. Apache and NGINX are among the most widespread hosts for it, and LiteSpeed servers also support it. Because it runs inside the web server, it sees requests after the connection has been decrypted. The general role of a web application firewall is explained in its own topic.

The OWASP Core Rule Set and Anomaly Scoring

The OWASP Core Rule Set (CRS) is a free, community-maintained collection of rules for ModSecurity. OWASP, the Open Worldwide Application Security Project, is a nonprofit that publishes security guidance for web applications. The CRS covers common attack families, including SQL injection, cross-site scripting, local file inclusion and remote code execution.

The CRS uses anomaly scoring. Instead of blocking on the first suspicious match, each rule adds points to a request's score. When the total passes a threshold, the request is blocked. This lowers the chance that one weak signal causes a block, but it also means the threshold needs careful tuning.

The CRS also offers paranoia levels. Higher levels enable more rules, catching more attacks but raising the number of false positives. Lower levels are quieter and more forgiving. Detection without blocking is covered in intrusion detection.

A Legitimate Form Blocked by Mistake

A small business uses a contact form on its site. A visitor writes a message quoting a line of SQL while asking about a database course. The rule set spots the SQL keywords, adds enough points to pass the threshold, and the form submission is blocked.

The site owner sees the block in the log, confirms the request was harmless, and adds a narrow exception for that form field only. The rule stays active for everything else. This is typical tuning work: the goal is to keep the protection while letting genuine traffic through.

Frequently asked questions

Is ModSecurity free to use?

The ModSecurity engine and the OWASP Core Rule Set are open source and free to use. Hosts and security vendors may package them with support, monitoring or commercial rule sets, and those services can carry fees. Check what your provider includes before assuming a particular feature is available.

Why does ModSecurity block pages on my own website?

Usually because a legitimate request matches an attack pattern, such as a search for code terms or a rich text editor submitting HTML. This is a false positive. The log shows which rule fired, and a targeted exception is safer than switching off the whole rule set. Other server-level protections are covered in server hardening.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.