Blame modsecurity.conf-recommended

Packit 284210
# -- Rule engine initialization ----------------------------------------------
Packit 284210
Packit 284210
# Enable ModSecurity, attaching it to every transaction. Use detection
Packit 284210
# only to start with, because that minimises the chances of post-installation
Packit 284210
# disruption.
Packit 284210
#
Packit 284210
SecRuleEngine DetectionOnly
Packit 284210
Packit 284210
Packit 284210
# -- Request body handling ---------------------------------------------------
Packit 284210
Packit 284210
# Allow ModSecurity to access request bodies. If you don't, ModSecurity
Packit 284210
# won't be able to see any POST parameters, which opens a large security
Packit 284210
# hole for attackers to exploit.
Packit 284210
#
Packit 284210
SecRequestBodyAccess On
Packit 284210
Packit 284210
Packit 284210
# Enable XML request body parser.
Packit 284210
# Initiate XML Processor in case of xml content-type
Packit 284210
#
Packit 284210
SecRule REQUEST_HEADERS:Content-Type "(?:application(?:/soap\+|/)|text/)xml" \
Packit 284210
     "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
Packit 284210
Packit 284210
# Enable JSON request body parser.
Packit 284210
# Initiate JSON Processor in case of JSON content-type; change accordingly
Packit 284210
# if your application does not use 'application/json'
Packit 284210
#
Packit 284210
SecRule REQUEST_HEADERS:Content-Type "application/json" \
Packit 284210
     "id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
Packit 284210
Packit 284210
# Maximum request body size we will accept for buffering. If you support
Packit 284210
# file uploads then the value given on the first line has to be as large
Packit 284210
# as the largest file you are willing to accept. The second value refers
Packit 284210
# to the size of data, with files excluded. You want to keep that value as
Packit 284210
# low as practical.
Packit 284210
#
Packit 284210
SecRequestBodyLimit 13107200
Packit 284210
SecRequestBodyNoFilesLimit 131072
Packit 284210
Packit 284210
# Store up to 128 KB of request body data in memory. When the multipart
Packit 284210
# parser reachers this limit, it will start using your hard disk for
Packit 284210
# storage. That is slow, but unavoidable.
Packit 284210
#
Packit 284210
SecRequestBodyInMemoryLimit 131072
Packit 284210
Packit 284210
# What do do if the request body size is above our configured limit.
Packit 284210
# Keep in mind that this setting will automatically be set to ProcessPartial
Packit 284210
# when SecRuleEngine is set to DetectionOnly mode in order to minimize
Packit 284210
# disruptions when initially deploying ModSecurity.
Packit 284210
#
Packit 284210
SecRequestBodyLimitAction Reject
Packit 284210
Packit 284210
# Verify that we've correctly processed the request body.
Packit 284210
# As a rule of thumb, when failing to process a request body
Packit 284210
# you should reject the request (when deployed in blocking mode)
Packit 284210
# or log a high-severity alert (when deployed in detection-only mode).
Packit 284210
#
Packit 284210
SecRule REQBODY_ERROR "!@eq 0" \
Packit 284210
"id:'200002', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
Packit 284210
Packit 284210
# By default be strict with what we accept in the multipart/form-data
Packit 284210
# request body. If the rule below proves to be too strict for your
Packit 284210
# environment consider changing it to detection-only. You are encouraged
Packit 284210
# _not_ to remove it altogether.
Packit 284210
#
Packit 284210
SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
Packit 284210
"id:'200003',phase:2,t:none,log,deny,status:400, \
Packit 284210
msg:'Multipart request body failed strict validation: \
Packit 284210
PE %{REQBODY_PROCESSOR_ERROR}, \
Packit 284210
BQ %{MULTIPART_BOUNDARY_QUOTED}, \
Packit 284210
BW %{MULTIPART_BOUNDARY_WHITESPACE}, \
Packit 284210
DB %{MULTIPART_DATA_BEFORE}, \
Packit 284210
DA %{MULTIPART_DATA_AFTER}, \
Packit 284210
HF %{MULTIPART_HEADER_FOLDING}, \
Packit 284210
LF %{MULTIPART_LF_LINE}, \
Packit 284210
SM %{MULTIPART_MISSING_SEMICOLON}, \
Packit 284210
IQ %{MULTIPART_INVALID_QUOTING}, \
Packit 284210
IP %{MULTIPART_INVALID_PART}, \
Packit 284210
IH %{MULTIPART_INVALID_HEADER_FOLDING}, \
Packit 284210
FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
Packit 284210
Packit 284210
# Did we see anything that might be a boundary?
Packit 284210
#
Packit 284210
SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \
Packit 284210
"id:'200004',phase:2,t:none,log,deny,msg:'Multipart parser detected a possible unmatched boundary.'"
Packit 284210
Packit 284210
# PCRE Tuning
Packit 284210
# We want to avoid a potential RegEx DoS condition
Packit 284210
#
Packit 284210
SecPcreMatchLimit 1000
Packit 284210
SecPcreMatchLimitRecursion 1000
Packit 284210
Packit 284210
# Some internal errors will set flags in TX and we will need to look for these.
Packit 284210
# All of these are prefixed with "MSC_".  The following flags currently exist:
Packit 284210
#
Packit 284210
# MSC_PCRE_LIMITS_EXCEEDED: PCRE match limits were exceeded.
Packit 284210
#
Packit 284210
SecRule TX:/^MSC_/ "!@streq 0" \
Packit 284210
        "id:'200005',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"
Packit 284210
Packit 284210
Packit 284210
# -- Response body handling --------------------------------------------------
Packit 284210
Packit 284210
# Allow ModSecurity to access response bodies. 
Packit 284210
# You should have this directive enabled in order to identify errors
Packit 284210
# and data leakage issues.
Packit 284210
# 
Packit 284210
# Do keep in mind that enabling this directive does increases both
Packit 284210
# memory consumption and response latency.
Packit 284210
#
Packit 284210
SecResponseBodyAccess On
Packit 284210
Packit 284210
# Which response MIME types do you want to inspect? You should adjust the
Packit 284210
# configuration below to catch documents but avoid static files
Packit 284210
# (e.g., images and archives).
Packit 284210
#
Packit 284210
SecResponseBodyMimeType text/plain text/html text/xml
Packit 284210
Packit 284210
# Buffer response bodies of up to 512 KB in length.
Packit 284210
SecResponseBodyLimit 524288
Packit 284210
Packit 284210
# What happens when we encounter a response body larger than the configured
Packit 284210
# limit? By default, we process what we have and let the rest through.
Packit 284210
# That's somewhat less secure, but does not break any legitimate pages.
Packit 284210
#
Packit 284210
SecResponseBodyLimitAction ProcessPartial
Packit 284210
Packit 284210
Packit 284210
# -- Filesystem configuration ------------------------------------------------
Packit 284210
Packit 284210
# The location where ModSecurity stores temporary files (for example, when
Packit 284210
# it needs to handle a file upload that is larger than the configured limit).
Packit 284210
# 
Packit 284210
# This default setting is chosen due to all systems have /tmp available however, 
Packit 284210
# this is less than ideal. It is recommended that you specify a location that's private.
Packit 284210
#
Packit 284210
SecTmpDir /tmp/
Packit 284210
Packit 284210
# The location where ModSecurity will keep its persistent data.  This default setting 
Packit 284210
# is chosen due to all systems have /tmp available however, it
Packit 284210
# too should be updated to a place that other users can't access.
Packit 284210
#
Packit 284210
SecDataDir /tmp/
Packit 284210
Packit 284210
Packit 284210
# -- File uploads handling configuration -------------------------------------
Packit 284210
Packit 284210
# The location where ModSecurity stores intercepted uploaded files. This
Packit 284210
# location must be private to ModSecurity. You don't want other users on
Packit 284210
# the server to access the files, do you?
Packit 284210
#
Packit 284210
#SecUploadDir /opt/modsecurity/var/upload/
Packit 284210
Packit 284210
# By default, only keep the files that were determined to be unusual
Packit 284210
# in some way (by an external inspection script). For this to work you
Packit 284210
# will also need at least one file inspection rule.
Packit 284210
#
Packit 284210
#SecUploadKeepFiles RelevantOnly
Packit 284210
Packit 284210
# Uploaded files are by default created with permissions that do not allow
Packit 284210
# any other user to access them. You may need to relax that if you want to
Packit 284210
# interface ModSecurity to an external program (e.g., an anti-virus).
Packit 284210
#
Packit 284210
#SecUploadFileMode 0600
Packit 284210
Packit 284210
Packit 284210
# -- Debug log configuration -------------------------------------------------
Packit 284210
Packit 284210
# The default debug log configuration is to duplicate the error, warning
Packit 284210
# and notice messages from the error log.
Packit 284210
#
Packit 284210
#SecDebugLog /opt/modsecurity/var/log/debug.log
Packit 284210
#SecDebugLogLevel 3
Packit 284210
Packit 284210
Packit 284210
# -- Audit log configuration -------------------------------------------------
Packit 284210
Packit 284210
# Log the transactions that are marked by a rule, as well as those that
Packit 284210
# trigger a server error (determined by a 5xx or 4xx, excluding 404,  
Packit 284210
# level response status codes).
Packit 284210
#
Packit 284210
SecAuditEngine RelevantOnly
Packit 284210
SecAuditLogRelevantStatus "^(?:5|4(?!04))"
Packit 284210
Packit 284210
# Log everything we know about a transaction.
Packit 284210
SecAuditLogParts ABIJDEFHZ
Packit 284210
Packit 284210
# Use a single file for logging. This is much easier to look at, but
Packit 284210
# assumes that you will use the audit log only ocassionally.
Packit 284210
#
Packit 284210
SecAuditLogType Serial
Packit 284210
SecAuditLog /var/log/modsec_audit.log
Packit 284210
Packit 284210
# Specify the path for concurrent audit logging.
Packit 284210
#SecAuditLogStorageDir /opt/modsecurity/var/audit/
Packit 284210
Packit 284210
Packit 284210
# -- Miscellaneous -----------------------------------------------------------
Packit 284210
Packit 284210
# Use the most commonly used application/x-www-form-urlencoded parameter
Packit 284210
# separator. There's probably only one application somewhere that uses
Packit 284210
# something else so don't expect to change this value.
Packit 284210
#
Packit 284210
SecArgumentSeparator &
Packit 284210
Packit 284210
# Settle on version 0 (zero) cookies, as that is what most applications
Packit 284210
# use. Using an incorrect cookie version may open your installation to
Packit 284210
# evasion attacks (against the rules that examine named cookies).
Packit 284210
#
Packit 284210
SecCookieFormat 0
Packit 284210
Packit 284210
# Specify your Unicode Code Point.
Packit 284210
# This mapping is used by the t:urlDecodeUni transformation function
Packit 284210
# to properly map encoded data to your language. Properly setting
Packit 284210
# these directives helps to reduce false positives and negatives.
Packit 284210
#
Packit 284210
SecUnicodeMapFile unicode.mapping 20127
Packit 284210
Packit 284210
# Improve the quality of ModSecurity by sharing information about your
Packit 284210
# current ModSecurity version and dependencies versions.
Packit 284210
# The following information will be shared: ModSecurity version,
Packit 284210
# Web Server version, APR version, PCRE version, Lua version, Libxml2
Packit 284210
# version, Anonymous unique id for host.
Packit 284210
SecStatusEngine On
Packit 284210