ModSecurity

Operators

A number of operators can be used in rules, as documented below.

eq

Numerical comparison.

ge

Numerical comparison.

gt

Numerical comparison.

inspectFile

Executes the external script/binary given as parameter to the operator against every file extracted from the request.

SecRule FILES_TMPNAMES "@inspectFile /opt/apache/bin/inspect_script.pl"

le

Numerical comparison.

lt

Numerical comparison.

rbl

Look up the parameter in the RBL given as parameter. Parameter can be an IPv4 address, or a hostname.

SecRule REMOTE_ADDR "@rbl sc.surbl.org"

rx

Regular expression operator. Regular expressions are handled by the PCRE library (http://www.pcre.org). ModSecurity compiles its regular expressions with the following settings:

  1. The entire input is treated as a single line, even when there are newline characters present.

  2. All matches are case-sensitive. If you do not care about case sensitivity you either need to implement the lowercase transformational function, or use the per-pattern (?s) modificator, as allowed by PCRE.

  3. The PCRE_DOTALL flag is set during compilation, meaning a single dot will match any character, including the newlines.

validateByteRange

Validates the byte range used in the variable falls into the specified range:

SecRule ARG:text "@validateByteRange 10, 13, 32-126"

validateDTD

SecRule XML "@validateDTD /path/to/file.dtd"

This operator requires request body to be processed as XML.

validateSchema

SecRule XML "@validateSchema /path/to/file.xsd"

This operator requires request body to be processed as XML.

validateUrlEncoding

Verifies the encodings used in the variable (if any) are valid.

validateUtf8Encoding

Verifies the variable is a valid UTF-8 encoded string.