@@ -44,7 +44,7 @@ SecRule TX:PARANOIA_LEVEL "@lt 1" "phase:2,id:920012,nolog,pass,skipAfter:END-RE
4444# http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.1
4545# http://capec.mitre.org/data/definitions/272.html
4646#
47- SecRule REQUEST_LINE "!^(?i:(?:[a-z]{3,10}\s+(?:\w{3,7}?://[\w\-\./]*(?::\d+)?)?/[^?#]*(?:\?[^#\s]*)?(?:#[\S]*)?|connect (?:\d{1,3}\.){3}\d{1,3}\.?(?::\d+)?|options \*)\s+[\w\./]+|get /[^?#]*(?:\?[^#\s]*)?(?:#[\S]*)?)$" \
47+ SecRule REQUEST_LINE "!@rx ^(?i:(?:[a-z]{3,10}\s+(?:\w{3,7}?://[\w\-\./]*(?::\d+)?)?/[^?#]*(?:\?[^#\s]*)?(?:#[\S]*)?|connect (?:\d{1,3}\.){3}\d{1,3}\.?(?::\d+)?|options \*)\s+[\w\./]+|get /[^?#]*(?:\?[^#\s]*)?(?:#[\S]*)?)$" \
4848 "msg:'Invalid HTTP Request Line',\
4949 severity:'WARNING',\
5050 id:920100,\
@@ -95,7 +95,7 @@ SecRule REQUEST_LINE "!^(?i:(?:[a-z]{3,10}\s+(?:\w{3,7}?://[\w\-\./]*(?::\d+)?)?
9595# https://www.owasp.org/index.php/ModSecurity_CRS_RuleID-960000
9696# http://www.ietf.org/rfc/rfc2183.txt
9797#
98- SecRule FILES_NAMES|FILES "(?<!&(?:[aAoOuUyY]uml)|&(?:[aAeEiIoOuU]circ)|&(?:[eEiIoOuUyY]acute)|&(?:[aAeEiIoOuU]grave)|&(?:[cC]cedil)|&(?:[aAnNoO]tilde)|&(?:amp)|&(?:apos));|['\"=]" \
98+ SecRule FILES_NAMES|FILES "@rx (?<!&(?:[aAoOuUyY]uml)|&(?:[aAeEiIoOuU]circ)|&(?:[eEiIoOuUyY]acute)|&(?:[aAeEiIoOuU]grave)|&(?:[cC]cedil)|&(?:[aAnNoO]tilde)|&(?:amp)|&(?:apos));|['\"=]" \
9999 "msg:'Attempted multipart/form-data bypass',\
100100 severity:'CRITICAL',\
101101 id:920120,\
@@ -204,7 +204,7 @@ SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
204204# -=[ References ]=-
205205# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13
206206#
207- SecRule REQUEST_HEADERS:Content-Length "!^\d+$" \
207+ SecRule REQUEST_HEADERS:Content-Length "!@rx ^\d+$" \
208208 "msg:'Content-Length HTTP header is not numeric.',\
209209 severity:'CRITICAL',\
210210 id:920160,\
@@ -240,7 +240,7 @@ SecRule REQUEST_HEADERS:Content-Length "!^\d+$" \
240240# -=[ References ]=-
241241# http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
242242#
243- SecRule REQUEST_METHOD "^(?:GET|HEAD)$" \
243+ SecRule REQUEST_METHOD "@rx ^(?:GET|HEAD)$" \
244244 "msg:'GET or HEAD Request with Body Content.',\
245245 severity:'CRITICAL',\
246246 id:920170,\
@@ -257,7 +257,7 @@ SecRule REQUEST_METHOD "^(?:GET|HEAD)$" \
257257 tag:'OWASP_CRS/PROTOCOL_VIOLATION/INVALID_HREQ',\
258258 tag:'CAPEC-272',\
259259 chain"
260- SecRule REQUEST_HEADERS:Content-Length "!^0?$" \
260+ SecRule REQUEST_HEADERS:Content-Length "!@rx ^0?$" \
261261 "t:none,\
262262 setvar:'tx.msg=%{rule.msg}',\
263263 setvar:tx.anomaly_score=+%{tx.critical_anomaly_score},\
@@ -274,7 +274,7 @@ SecRule REQUEST_METHOD "^(?:GET|HEAD)$" \
274274# -=[ References ]=-
275275# http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5
276276#
277- SecRule REQUEST_METHOD "^POST$" \
277+ SecRule REQUEST_METHOD "@rx ^POST$" \
278278 "msg:'POST request missing Content-Length Header.',\
279279 severity:'WARNING',\
280280 id:920180,\
@@ -320,7 +320,7 @@ SecRule REQUEST_METHOD "^POST$" \
320320# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
321321# http://seclists.org/fulldisclosure/2011/Aug/175
322322#
323- SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "(\d+)\-(\d+)\," \
323+ SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx (\d+)\-(\d+)\," \
324324 "capture,\
325325 phase:2,\
326326 rev:'2',\
@@ -354,7 +354,7 @@ SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "(\d+)\-(\d+)\," \
354354# -=[ References ]=-
355355# http://www.bad-behavior.ioerror.us/documentation/how-it-works/
356356#
357- SecRule REQUEST_HEADERS:Connection "\b(keep-alive|close),\s?(keep-alive|close)\b" \
357+ SecRule REQUEST_HEADERS:Connection "@rx \b(keep-alive|close),\s?(keep-alive|close)\b" \
358358 "phase:2,\
359359 rev:'2',\
360360 ver:'OWASP_CRS/3.0.0',\
@@ -384,7 +384,7 @@ SecRule REQUEST_HEADERS:Connection "\b(keep-alive|close),\s?(keep-alive|close)\b
384384# -=[ References ]=-
385385# http://www.ietf.org/rfc/rfc1738.txt
386386#
387- SecRule REQUEST_URI "\%((?!$|\W)|[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})" \
387+ SecRule REQUEST_URI "@rx \%((?!$|\W)|[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})" \
388388 "phase:2,\
389389 rev:'2',\
390390 ver:'OWASP_CRS/3.0.0',\
@@ -404,7 +404,7 @@ SecRule REQUEST_URI "\%((?!$|\W)|[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})" \
404404 setvar:tx.anomaly_score=+%{tx.warning_anomaly_score},\
405405 setvar:tx.%{rule.id}-OWASP_CRS/PROTOCOL_VIOLATION/EVASION-%{matched_var_name}=%{matched_var}"
406406
407- SecRule REQUEST_HEADERS:Content-Type "^(application\/x-www-form-urlencoded|text\/xml)(?:;(?:\s?charset\s?=\s?[\w\d\-]{1,18})?)??$" \
407+ SecRule REQUEST_HEADERS:Content-Type "@rx ^(application\/x-www-form-urlencoded|text\/xml)(?:;(?:\s?charset\s?=\s?[\w\d\-]{1,18})?)??$" \
408408 "phase:2,\
409409 rev:'2',\
410410 ver:'OWASP_CRS/3.0.0',\
@@ -419,7 +419,8 @@ SecRule REQUEST_HEADERS:Content-Type "^(application\/x-www-form-urlencoded|text\
419419 tag:'OWASP_CRS/PROTOCOL_VIOLATION/EVASION',\
420420 severity:'WARNING',\
421421 chain"
422- SecRule REQUEST_BODY|XML:/* "\%((?!$|\W)|[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})" "chain"
422+ SecRule REQUEST_BODY|XML:/* "@rx \%((?!$|\W)|[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})" \
423+ "chain"
423424 SecRule REQUEST_BODY|XML:/* "@validateUrlEncoding" \
424425 "setvar:'tx.msg=%{rule.msg}',\
425426 setvar:tx.anomaly_score=+%{tx.warning_anomaly_score},\
@@ -473,7 +474,7 @@ SecRule TX:CRS_VALIDATE_UTF8_ENCODING "@eq 1" \
473474# https://www.checkpoint.com/defense/advisories/public/2007/cpai-2007-201.html
474475# https://github.com/SpiderLabs/owasp-modsecurity-crs/issues/719
475476#
476- SecRule REQUEST_URI|REQUEST_BODY "\%u[fF]{2}[0-9a-fA-F]{2}" \
477+ SecRule REQUEST_URI|REQUEST_BODY "@rx \%u[fF]{2}[0-9a-fA-F]{2}" \
477478 "msg:'Unicode Full/Half Width Abuse Attack Attempt',\
478479 id:920260,\
479480 severity:'WARNING',\
@@ -582,7 +583,7 @@ SecRule &REQUEST_HEADERS:Host "@eq 0" \
582583 skipAfter:END_HOST_CHECK"
583584
584585
585- SecRule REQUEST_HEADERS:Host "^$" \
586+ SecRule REQUEST_HEADERS:Host "@rx ^$" \
586587 "msg:'Empty Host Header',\
587588 severity:'WARNING',\
588589 phase:2,\
@@ -623,7 +624,7 @@ SecMarker END_HOST_CHECK
623624# https://github.com/SpiderLabs/owasp-modsecurity-crs/issues/366
624625#
625626
626- SecRule REQUEST_HEADERS:Accept "^$" \
627+ SecRule REQUEST_HEADERS:Accept "@rx ^$" \
627628 "msg:'Request Has an Empty Accept Header',\
628629 chain,\
629630 phase:2,\
@@ -638,7 +639,7 @@ SecRule REQUEST_HEADERS:Accept "^$" \
638639 tag:'platform-multi',\
639640 tag:'attack-protocol',\
640641 tag:'OWASP_CRS/PROTOCOL_VIOLATION/MISSING_HEADER_ACCEPT'"
641- SecRule REQUEST_METHOD "!^OPTIONS$" \
642+ SecRule REQUEST_METHOD "!@rx ^OPTIONS$" \
642643 "chain"
643644 SecRule REQUEST_HEADERS:User-Agent "!@pm AppleWebKit Android Business Enterprise Entreprise" \
644645 "t:none,\
@@ -649,7 +650,7 @@ SecRule REQUEST_HEADERS:Accept "^$" \
649650#
650651# This rule is a sibling of rule 920310.
651652#
652- SecRule REQUEST_HEADERS:Accept "^$" \
653+ SecRule REQUEST_HEADERS:Accept "@rx ^$" \
653654 "msg:'Request Has an Empty Accept Header',\
654655 chain,\
655656 phase:2,\
@@ -664,7 +665,7 @@ SecRule REQUEST_HEADERS:Accept "^$" \
664665 tag:'platform-multi',\
665666 tag:'attack-protocol',\
666667 tag:'OWASP_CRS/PROTOCOL_VIOLATION/MISSING_HEADER_ACCEPT'"
667- SecRule REQUEST_METHOD "!^OPTIONS$" \
668+ SecRule REQUEST_METHOD "!@rx ^OPTIONS$" \
668669 "chain"
669670 SecRule &REQUEST_HEADERS:User-Agent "@eq 0" \
670671 "t:none,\
@@ -683,7 +684,7 @@ SecRule REQUEST_HEADERS:Accept "^$" \
683684# the existence of the User-Agent header.
684685#
685686
686- SecRule REQUEST_HEADERS:User-Agent "^$" \
687+ SecRule REQUEST_HEADERS:User-Agent "@rx ^$" \
687688 "msg:'Empty User Agent Header',\
688689 severity:'NOTICE',\
689690 phase:2,\
@@ -714,7 +715,7 @@ SecRule REQUEST_HEADERS:User-Agent "^$" \
714715# -=[ References ]=-
715716# http://httpwg.org/specs/rfc7231.html#header.content-type
716717
717- SecRule REQUEST_HEADERS:Content-Length "!^0$" \
718+ SecRule REQUEST_HEADERS:Content-Length "!@rx ^0$" \
718719 "msg:'Request Containing Content, but Missing Content-Type header',\
719720 chain,\
720721 phase:2,\
@@ -745,7 +746,7 @@ SecRule REQUEST_HEADERS:Content-Length "!^0$" \
745746# http://technet.microsoft.com/en-us/magazine/2005.01.hackerbasher.aspx
746747#
747748
748- SecRule REQUEST_HEADERS:Host "^[\d.:]+$" \
749+ SecRule REQUEST_HEADERS:Host "@rx ^[\d.:]+$" \
749750 "msg:'Host header is a numeric IP address',\
750751 phase:2,\
751752 rev:'2',\
@@ -934,7 +935,7 @@ SecRule &TX:COMBINED_FILE_SIZES "@eq 1" \
934935#
935936# Restrict which content-types we accept.
936937#
937- SecRule REQUEST_METHOD "!^(?:GET|HEAD|PROPFIND|OPTIONS)$" \
938+ SecRule REQUEST_METHOD "!@rx ^(?:GET|HEAD|PROPFIND|OPTIONS)$" \
938939 "phase:2,\
939940 chain,\
940941 t:none,\
@@ -954,10 +955,10 @@ SecRule REQUEST_METHOD "!^(?:GET|HEAD|PROPFIND|OPTIONS)$" \
954955 tag:'OWASP_TOP_10/A1',\
955956 tag:'OWASP_AppSensor/EE2',\
956957 tag:'PCI/12.1'"
957- SecRule REQUEST_HEADERS:Content-Type "^([^;\s]+)" \
958+ SecRule REQUEST_HEADERS:Content-Type "@rx ^([^;\s]+)" \
958959 "chain,\
959960 capture"
960- SecRule TX:0 "!^%{tx.allowed_request_content_type}$" \
961+ SecRule TX:0 "!@rx ^%{tx.allowed_request_content_type}$" \
961962 "t:none,\
962963 ctl:forceRequestBodyVariable=On,\
963964 setvar:'tx.msg=%{rule.msg}',\
@@ -992,7 +993,7 @@ SecRule REQUEST_PROTOCOL "!@within %{tx.allowed_http_versions}" \
992993#
993994# Restrict file extension
994995#
995- SecRule REQUEST_BASENAME "\.(.*)$" \
996+ SecRule REQUEST_BASENAME "@rx \.(.*)$" \
996997 "chain,\
997998 capture,\
998999 phase:2,\
@@ -1100,7 +1101,7 @@ SecRule TX:PARANOIA_LEVEL "@lt 2" "phase:2,id:920014,nolog,pass,skipAfter:END-RE
11001101# -=[ References ]=-
11011102# https://httpd.apache.org/security/CVE-2011-3192.txt
11021103
1103- SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "^bytes=((\d+)?\-(\d+)?\s*,?\s*){6}" \
1104+ SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx ^bytes=((\d+)?\-(\d+)?\s*,?\s*){6}" \
11041105 "phase:2,\
11051106 capture,\
11061107 rev:'2',\
@@ -1145,13 +1146,13 @@ SecRule REQUEST_BASENAME "@endsWith .pdf" \
11451146 tag:'OWASP_CRS/PROTOCOL_VIOLATION/INVALID_HREQ',\
11461147 tag:'paranoia-level/2',\
11471148 chain"
1148- SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "^bytes=((\d+)?\-(\d+)?\s*,?\s*){63}" \
1149+ SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx ^bytes=((\d+)?\-(\d+)?\s*,?\s*){63}" \
11491150 "setvar:'tx.msg=%{rule.msg}',\
11501151 setvar:tx.anomaly_score=+%{tx.warning_anomaly_score},\
11511152 setvar:tx.%{rule.id}-OWASP_CRS/PROTOCOL_VIOLATION/INVALID_HREQ-%{matched_var_name}=%{matched_var}"
11521153
11531154
1154- SecRule ARGS "\%((?!$|\W)|[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})" \
1155+ SecRule ARGS "@rx \%((?!$|\W)|[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})" \
11551156 "phase:2,\
11561157 rev:'2',\
11571158 ver:'OWASP_CRS/3.0.0',\
@@ -1196,7 +1197,7 @@ SecRule &REQUEST_HEADERS:Accept "@eq 0" \
11961197 tag:'OWASP_TOP_10/A7',\
11971198 tag:'PCI/6.5.10',\
11981199 tag:'paranoia-level/2'"
1199- SecRule REQUEST_METHOD "!^OPTIONS$" \
1200+ SecRule REQUEST_METHOD "!@rx ^OPTIONS$" \
12001201 "chain"
12011202 SecRule REQUEST_HEADERS:User-Agent "!@pm AppleWebKit Android" \
12021203 "t:none,\
@@ -1260,7 +1261,7 @@ SecRule &REQUEST_HEADERS:User-Agent "@eq 0" \
12601261#
12611262# PL2: This is a stricter sibling of 920120.
12621263#
1263- SecRule FILES_NAMES|FILES "['\";=]" \
1264+ SecRule FILES_NAMES|FILES "@rx ['\";=]" \
12641265 "msg:'Attempted multipart/form-data bypass',\
12651266 severity:'CRITICAL',\
12661267 id:920121,\
@@ -1339,7 +1340,7 @@ SecRule REQUEST_BASENAME "@endsWith .pdf" \
13391340 tag:'OWASP_CRS/PROTOCOL_VIOLATION/INVALID_HREQ',\
13401341 tag:'paranoia-level/4',\
13411342 chain"
1342- SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "^bytes=((\d+)?\-(\d+)?\s*,?\s*){6}" \
1343+ SecRule REQUEST_HEADERS:Range|REQUEST_HEADERS:Request-Range "@rx ^bytes=((\d+)?\-(\d+)?\s*,?\s*){6}" \
13431344 "setvar:'tx.msg=%{rule.msg}',\
13441345 setvar:tx.anomaly_score=+%{tx.warning_anomaly_score},\
13451346 setvar:tx.%{rule.id}-OWASP_CRS/PROTOCOL_VIOLATION/INVALID_HREQ-%{matched_var_name}=%{matched_var}"
@@ -1417,7 +1418,7 @@ SecRule REQUEST_HEADERS|!REQUEST_HEADERS:User-Agent|!REQUEST_HEADERS:Referer|!RE
14171418# negative look-behind construct. If that is the case, the backslash character
14181419# is allowed.
14191420#
1420- SecRule REQUEST_URI|REQUEST_HEADERS|ARGS|ARGS_NAMES "(?<!\Q\\\E)\Q\\\E[cdeghijklmpqwxyz123456789]" \
1421+ SecRule REQUEST_URI|REQUEST_HEADERS|ARGS|ARGS_NAMES "@rx (?<!\Q\\\E)\Q\\\E[cdeghijklmpqwxyz123456789]" \
14211422 "phase:2,\
14221423 id:920460,\
14231424 rev:'1',\
0 commit comments