2024-12-21 00:30:30 +00:00
|
|
|
# Nginx WAF rules for ENFORCEMENT
|
|
|
|
|
location / {
|
|
|
|
|
set $attack_detected 0;
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@validateByteRange 32,34,38,42-59,61,65-90,95,97-122") {
|
2025-01-07 00:27:08 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@gt %{tx.max_num_args}") {
|
2025-01-07 00:27:08 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@gt %{tx.combined_file_sizes}") {
|
2025-01-07 00:27:08 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* ".([^.]+)$") {
|
2025-01-07 00:27:08 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "(?:^|[^x5c])x5c[cdeghijklmpqwxyz123456789]") {
|
2025-01-07 00:27:08 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@ge 1") {
|
2025-01-07 00:27:08 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@endsWith .pdf") {
|
2025-01-07 00:27:08 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@gt %{tx.max_file_size}") {
|
2025-01-07 00:27:08 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@validateByteRange 38,44-46,48-58,61,65-90,95,97-122") {
|
2025-01-07 00:27:08 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "['\";=]") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-09 00:26:35 +00:00
|
|
|
if ($request_uri ~* "!@rx ^d+$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "!@rx ^OPTIONS$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "charset.*?charset") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "!@pm AppleWebKit Android Business Enterprise Entreprise") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "!@pm AppleWebKit Android") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@validateByteRange 1-255") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "%u[fF]{2}[0-9a-fA-F]{2}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "^.*$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "^bytes=(?:(?:d+)?-(?:d+)?s*,?s*){63}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@gt %{tx.total_arg_length}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "%[0-9a-fA-F]{2}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "!@streq JSON") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "(?i)x5cu[0-9a-f]{4}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@eq 0") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@validateByteRange 9,10,13,32-126,128-255") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "b(?:keep-alive|close),s?(?:keep-alive|close)b") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "(?:^([d.]+|[[da-f:]+]|[da-f:]+)(:[d]+)?$)") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "^(?:GET|HEAD)$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "!@endsWith .pdf") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "(d+)-(d+)") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@within %{tx.restricted_extensions}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@gt 1") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@validateByteRange 32-36,38-126") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@gt %{tx.arg_length}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "!@rx ^[w/.+*-]+(?:s?;s?(?:action|boundary|charset|component|start(?:-info)?|type|version)s?=s?['\"w.()+,/:=?<>@#*-]+)*$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@streq POST") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@eq 1") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@validateUtf8Encoding") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* ".[^.~]+~(?:/.*|)$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@gt 50") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@validateUrlEncoding") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "^[^;s]+") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "!@rx ^0?$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@within %{tx.restricted_headers_basic}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "x25") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@contains #") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@gt 0") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "^$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "charsets*=s*[\"']?([^;\"'s]+)") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "!@rx ^0$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "!@rx ^(?:OPTIONS|CONNECT)$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@within %{tx.restricted_headers_extended}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "!@rx ^(?:(?:max-age=[0-9]+|min-fresh=[0-9]+|no-cache|no-store|no-transform|only-if-cached|max-stale(?:=[0-9]+)?)(?:s*,s*|$)){1,7}$") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "^bytes=(?:(?:d+)?-(?:d+)?s*,?s*){6}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 00:27:14 +00:00
|
|
|
if ($request_uri ~* "@gt %{tx.arg_name_length}") {
|
2024-12-21 00:30:30 +00:00
|
|
|
set $attack_detected 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($attack_detected = 1) {
|
|
|
|
|
return 403;
|
|
|
|
|
}
|
|
|
|
|
}
|