Blame modsecurity.conf-recommended

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