Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update CRS to v4.1 #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 76 additions & 38 deletions appsec/crs/REQUEST-901-INITIALIZATION.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ------------------------------------------------------------------------
# OWASP ModSecurity Core Rule Set ver.4.0.0-rc1
# OWASP CRS ver.4.1.0
# Copyright (c) 2006-2020 Trustwave and contributors. All rights reserved.
# Copyright (c) 2021-2022 Core Rule Set project. All rights reserved.
# Copyright (c) 2021-2024 CRS project. All rights reserved.
#
# The OWASP ModSecurity Core Rule Set is distributed under
# The OWASP CRS is distributed under
# Apache Software License (ASL) version 2
# Please see the enclosed LICENSE file for full details.
# ------------------------------------------------------------------------
Expand All @@ -24,9 +24,9 @@
#
# - Producer: ModSecurity for Apache/2.9.1 (http://www.modsecurity.org/); OWASP_CRS/3.1.0.
#
# Ref: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#wiki-SecComponentSignature
# Ref: https://github.com/owasp-modsecurity/ModSecurity/wiki/Reference-Manual-(v2.x)#seccomponentsignature
#
SecComponentSignature "OWASP_CRS/4.0.0-rc1"
SecComponentSignature "OWASP_CRS/4.1.0"

#
# -=[ Default setup values ]=-
Expand Down Expand Up @@ -58,8 +58,9 @@ SecRule &TX:crs_setup_version "@eq 0" \
status:500,\
log,\
auditlog,\
msg:'ModSecurity Core Rule Set is deployed without configuration! Please copy the crs-setup.conf.example template to crs-setup.conf, and include the crs-setup.conf file in your webserver configuration before including the CRS rules. See the INSTALL file in the CRS directory for detailed instructions',\
ver:'OWASP_CRS/4.0.0-rc1',\
msg:'ModSecurity CRS is deployed without configuration! Please copy the crs-setup.conf.example template to crs-setup.conf, and include the crs-setup.conf file in your webserver configuration before including the CRS rules. See the INSTALL file in the CRS directory for detailed instructions',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
severity:'CRITICAL'"


Expand All @@ -77,7 +78,8 @@ SecRule &TX:inbound_anomaly_score_threshold "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.inbound_anomaly_score_threshold=5'"

# Default Outbound Anomaly Threshold Level (rule 900110 in crs-setup.conf)
Expand All @@ -86,7 +88,8 @@ SecRule &TX:outbound_anomaly_score_threshold "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.outbound_anomaly_score_threshold=4'"

# Default Reporting Level (rule 900115 in crs-setup.conf)
Expand All @@ -95,7 +98,8 @@ SecRule &TX:reporting_level "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.reporting_level=4'"

# Default Early Blocking (rule 900120 in crs-setup.conf)
Expand All @@ -104,7 +108,8 @@ SecRule &TX:early_blocking "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.early_blocking=0'"

# Default Blocking Paranoia Level (rule 900000 in crs-setup.conf)
Expand All @@ -113,7 +118,8 @@ SecRule &TX:blocking_paranoia_level "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.blocking_paranoia_level=1'"

# Default Detection Paranoia Level (rule 900001 in crs-setup.conf)
Expand All @@ -122,7 +128,8 @@ SecRule &TX:detection_paranoia_level "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.detection_paranoia_level=%{TX.blocking_paranoia_level}'"

# Default Sampling Percentage (rule 900400 in crs-setup.conf)
Expand All @@ -131,7 +138,8 @@ SecRule &TX:sampling_percentage "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.sampling_percentage=100'"

# Default Anomaly Scores (rule 900100 in crs-setup.conf)
Expand All @@ -140,31 +148,35 @@ SecRule &TX:critical_anomaly_score "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.critical_anomaly_score=5'"

SecRule &TX:error_anomaly_score "@eq 0" \
"id:901141,\
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.error_anomaly_score=4'"

SecRule &TX:warning_anomaly_score "@eq 0" \
"id:901142,\
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.warning_anomaly_score=3'"

SecRule &TX:notice_anomaly_score "@eq 0" \
"id:901143,\
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.notice_anomaly_score=2'"

# Default HTTP policy: allowed_methods (rule 900200 in crs-setup.conf)
Expand All @@ -173,7 +185,8 @@ SecRule &TX:allowed_methods "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.allowed_methods=GET HEAD POST OPTIONS'"

# Default HTTP policy: allowed_request_content_type (rule 900220 in crs-setup.conf)
Expand All @@ -182,7 +195,8 @@ SecRule &TX:allowed_request_content_type "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.allowed_request_content_type=|application/x-www-form-urlencoded| |multipart/form-data| |multipart/related| |text/xml| |application/xml| |application/soap+xml| |application/json| |application/cloudevents+json| |application/cloudevents-batch+json|'"

# Default HTTP policy: allowed_request_content_type_charset (rule 900280 in crs-setup.conf)
Expand All @@ -191,7 +205,8 @@ SecRule &TX:allowed_request_content_type_charset "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.allowed_request_content_type_charset=|utf-8| |iso-8859-1| |iso-8859-15| |windows-1252|'"

# Default HTTP policy: allowed_http_versions (rule 900230 in crs-setup.conf)
Expand All @@ -200,34 +215,48 @@ SecRule &TX:allowed_http_versions "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
setvar:'tx.allowed_http_versions=HTTP/1.0 HTTP/1.1 HTTP/2 HTTP/2.0'"
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.allowed_http_versions=HTTP/1.0 HTTP/1.1 HTTP/2 HTTP/2.0 HTTP/3 HTTP/3.0'"

# Default HTTP policy: restricted_extensions (rule 900240 in crs-setup.conf)
SecRule &TX:restricted_extensions "@eq 0" \
"id:901164,\
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.restricted_extensions=.asa/ .asax/ .ascx/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .rdb/ .resources/ .resx/ .sql/ .swp/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/'"

# Default HTTP policy: restricted_headers (rule 900250 in crs-setup.conf)
SecRule &TX:restricted_headers "@eq 0" \
# Default HTTP policy: restricted_headers_basic (rule 900250 in crs-setup.conf)
SecRule &TX:restricted_headers_basic "@eq 0" \
"id:901165,\
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
setvar:'tx.restricted_headers=/accept-charset/ /content-encoding/ /proxy/ /lock-token/ /content-range/ /if/ /x-http-method-override/ /x-http-method/ /x-method-override/'"
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.restricted_headers_basic=/content-encoding/ /proxy/ /lock-token/ /content-range/ /if/ /x-http-method-override/ /x-http-method/ /x-method-override/'"

# Default HTTP policy: restricted_headers_extended (rule 900255 in crs-setup.conf)
SecRule &TX:restricted_headers_extended "@eq 0" \
"id:901171,\
phase:1,\
pass,\
nolog,\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.restricted_headers_extended=/accept-charset/'"

# Default enforcing of body processor URLENCODED (rule 900010 in crs-setup.conf)
SecRule &TX:enforce_bodyproc_urlencoded "@eq 0" \
"id:901167,\
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.enforce_bodyproc_urlencoded=0'"

# Default check for UTF8 encoding validation (rule 900950 in crs-setup.conf)
Expand All @@ -236,7 +265,8 @@ SecRule &TX:crs_validate_utf8_encoding "@eq 0" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.crs_validate_utf8_encoding=0'"

#
Expand All @@ -253,7 +283,8 @@ SecAction \
pass,\
t:none,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'tx.blocking_inbound_anomaly_score=0',\
setvar:'tx.detection_inbound_anomaly_score=0',\
setvar:'tx.inbound_anomaly_score_pl1=0',\
Expand Down Expand Up @@ -291,7 +322,8 @@ SecRule TX:ENABLE_DEFAULT_COLLECTIONS "@eq 1" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
chain"
SecRule REQUEST_HEADERS:User-Agent "@rx ^.*$" \
"t:none,t:sha1,t:hexEncode,\
Expand All @@ -312,8 +344,9 @@ SecRule REQBODY_PROCESSOR "!@rx (?:URLENCODED|MULTIPART|XML|JSON)" \
nolog,\
noauditlog,\
msg:'Enabling body inspection',\
tag:'OWASP_CRS',\
ctl:forceRequestBodyVariable=On,\
ver:'OWASP_CRS/4.0.0-rc1'"
ver:'OWASP_CRS/4.1.0'"

# Force body processor URLENCODED
SecRule TX:enforce_bodyproc_urlencoded "@eq 1" \
Expand All @@ -324,7 +357,8 @@ SecRule TX:enforce_bodyproc_urlencoded "@eq 1" \
nolog,\
noauditlog,\
msg:'Enabling forced body inspection for ASCII content',\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
chain"
SecRule REQBODY_PROCESSOR "!@rx (?:URLENCODED|MULTIPART|XML|JSON)" \
"ctl:requestBodyProcessor=URLENCODED"
Expand Down Expand Up @@ -363,7 +397,8 @@ SecRule TX:sampling_percentage "@eq 100" \
phase:1,\
pass,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
skipAfter:END-SAMPLING"

SecRule UNIQUE_ID "@rx ^[a-f]*([0-9])[a-f]*([0-9])" \
Expand All @@ -373,7 +408,8 @@ SecRule UNIQUE_ID "@rx ^[a-f]*([0-9])[a-f]*([0-9])" \
capture,\
t:sha1,t:hexEncode,\
nolog,\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
setvar:'TX.sampling_rnd100=%{TX.1}%{TX.2}'"

#
Expand All @@ -396,8 +432,9 @@ SecRule TX:sampling_rnd100 "!@lt %{tx.sampling_percentage}" \
log,\
noauditlog,\
msg:'Sampling: Disable the rule engine based on sampling_percentage %{TX.sampling_percentage} and random number %{TX.sampling_rnd100}',\
tag:'OWASP_CRS',\
ctl:ruleRemoveByTag=OWASP_CRS,\
ver:'OWASP_CRS/4.0.0-rc1'"
ver:'OWASP_CRS/4.1.0'"

SecMarker "END-SAMPLING"

Expand All @@ -415,4 +452,5 @@ SecRule TX:detection_paranoia_level "@lt %{tx.blocking_paranoia_level}" \
t:none,\
log,\
msg:'Detection paranoia level configured is lower than the paranoia level itself. This is illegal. Blocking request. Aborting',\
ver:'OWASP_CRS/4.0.0-rc1'"
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0'"
12 changes: 7 additions & 5 deletions appsec/crs/REQUEST-905-COMMON-EXCEPTIONS.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ------------------------------------------------------------------------
# OWASP ModSecurity Core Rule Set ver.4.0.0-rc1
# OWASP CRS ver.4.1.0
# Copyright (c) 2006-2020 Trustwave and contributors. All rights reserved.
# Copyright (c) 2021-2022 Core Rule Set project. All rights reserved.
# Copyright (c) 2021-2024 CRS project. All rights reserved.
#
# The OWASP ModSecurity Core Rule Set is distributed under
# The OWASP CRS is distributed under
# Apache Software License (ASL) version 2
# Please see the enclosed LICENSE file for full details.
# ------------------------------------------------------------------------
Expand All @@ -24,7 +24,8 @@ SecRule REQUEST_LINE "@streq GET /" \
tag:'language-multi',\
tag:'platform-apache',\
tag:'attack-generic',\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
chain"
SecRule REMOTE_ADDR "@ipMatch 127.0.0.1,::1" \
"t:none,\
Expand All @@ -44,7 +45,8 @@ SecRule REMOTE_ADDR "@ipMatch 127.0.0.1,::1" \
tag:'language-multi',\
tag:'platform-apache',\
tag:'attack-generic',\
ver:'OWASP_CRS/4.0.0-rc1',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.1.0',\
chain"
SecRule REQUEST_HEADERS:User-Agent "@endsWith (internal dummy connection)" \
"t:none,\
Expand Down
Loading