# Nginx WAF rules for XSS location / { set $attack_detected 0; if ($request_uri ~* "@lt 1") { set $attack_detected 1; } if ($request_uri ~* "@lt 1") { set $attack_detected 1; } if ($request_uri ~* "!@validateByteRange 20, 45-47, 48-57, 65-90, 95, 97-122") { set $attack_detected 1; } if ($request_uri ~* "@detectXSS") { set $attack_detected 1; } if ($request_uri ~* "@rx (?i)]*>[sS]*?") { set $attack_detected 1; } if ($request_uri ~* "@rx (?i).(?:b(?:x(?:link:href|html|mlns)|data:text/html|formaction|patternb.*?=)|!ENTITY[sx0b]+(?:%[sx0b]+)?[^sx0b]+[sx0b]+(?:SYSTEM|PUBLIC)|@import|;base64)b") { set $attack_detected 1; } if ($request_uri ~* "@rx (?i)[a-z]+=(?:[^:=]+:.+;)*?[^:=]+:url(javascript") { set $attack_detected 1; } if ($request_uri ~* "@rx (?i)<[^0-9<>A-Z_a-z]*(?:[^sx0b") { set $attack_detected 1; } if ($request_uri ~* "@rx (?i)(?:W|^)(?:javascript:(?:[sS]+[=x5c([.<]|[sS]*?(?:bnameb|x5c[ux]d))|data:(?:(?:[a-z]w+/w[w+-]+w)?[;,]|[sS]*?;[sS]*?b(?:base64|charset=)|[sS]*?,[sS]*?<[sS]*?w[sS]*?>))|@W*?iW*?mW*?pW*?oW*?rW*?tW*?(?:/*[sS]*?)?(?:[") { set $attack_detected 1; } if ($request_uri ~* "@pm document.cookie document.domain document.write .parentnode .innerhtml window.location -moz-binding ") { set $attack_detected 1; } if ($request_uri ~* "@rx <(?:a|abbr|acronym|address|applet|area|audioscope|b|base|basefront|bdo|bgsound|big|blackface|blink|blockquote|body|bq|br|button|caption|center|cite|code|col|colgroup|comment|dd|del|dfn|dir|div|dl|dt|em|embed|fieldset|fn|font|form|frame|frameset|h1|head|hr|html|i|iframe|ilayer|img|input|ins|isindex|kdb|keygen|label|layer|legend|li|limittext|link|listing|map|marquee|menu|meta|multicol|nobr|noembed|noframes|noscript|nosmartquotes|object|ol|optgroup|option|p|param|plaintext|pre|q|rt|ruby|s|samp|script|select|server|shadow|sidebar|small|spacer|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt|u|ul|var|wbr|xml|xmp)W") { set $attack_detected 1; } if ($request_uri ~* "@rx (?i:[") { set $attack_detected 1; } if ($request_uri ~* "@rx (?i)[") { set $attack_detected 1; } if ($request_uri ~* "@rx {{.*?}}") { set $attack_detected 1; } if ($request_uri ~* "@lt 3") { set $attack_detected 1; } if ($request_uri ~* "@lt 3") { set $attack_detected 1; } if ($request_uri ~* "@lt 4") { set $attack_detected 1; } if ($request_uri ~* "@lt 4") { set $attack_detected 1; } if ($attack_detected = 1) { return 403; } }