Skip to content
Merged
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
65 changes: 65 additions & 0 deletions regex-assembly/941190.ra
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
##! Please refer to the documentation at
##! https://coreruleset.org/docs/development/regex_assembly/.

##! IE XSS Filters - detects XSS within <style> tags.
##! Matches a style tag followed by either:
##! - a CSS at-rule (@i or @\)
##! - a colon/equals (or HTML entity equivalent) followed by
##! a paren/backslash (or HTML entity equivalent)

##!+ i

##! HTML entity codes for colon (:) and equals (=)
##! 58 = ':' decimal, 3A = ':' hex, 61 = '=' decimal, 3D = '=' hex
##!> assemble
58
3A
61
3D
##!=< colon-equals-entity-codes
##!<

##! HTML entity codes for open paren and backslash
##! 40 = '(' decimal, 28 = '(' hex, 92 = '\' decimal, 5C = '\' hex
##!> assemble
40
28
92
5C
##!=< paren-backslash-entity-codes
##!<

##! colon or equals, literal or as HTML entity
##!> assemble
[:=]
##!> assemble
&#x?0*
##!=> colon-equals-entity-codes
;?
##!<
##!=< colon-or-equals
##!<

##! open paren or backslash, literal or as HTML entity
##!> assemble
[(\x5c]
##!> assemble
&#x?0*
##!=> paren-backslash-entity-codes
;?
##!<
##!=< paren-or-backslash
##!<

##! CSS at-rule pattern: @i or @\
##!> assemble
<style.*?>.*?@[i\x5c]
##!<

##! assignment pattern: colon/equals ... paren/backslash
##!> assemble
<style.*?>.*?
##!=> colon-or-equals
.*?
##!=> paren-or-backslash
##!<
7 changes: 6 additions & 1 deletion rules/REQUEST-941-APPLICATION-ATTACK-XSS.conf
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,12 @@ SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|REQUEST_FILENAME|X
# Ref: http://blogs.technet.com/srd/archive/2008/08/18/ie-8-xss-filter-architecture-implementation.aspx
# Ref: http://xss.cx/examples/ie/internet-exploror-ie9-xss-filter-rules-example-regexp-mshtmldll.txt
#
SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|REQUEST_FILENAME|XML:/* "@rx (?i:<style.*?>.*?(?:@[i\x5c]|(?:[:=]|&#x?0*(?:58|3A|61|3D);?).*?(?:[(\x5c]|&#x?0*(?:40|28|92|5C);?)))" \
# Regular expression generated from regex-assembly/941190.ra.
# To update the regular expression run the following shell script
# (consult https://coreruleset.org/docs/development/regex_assembly/ for details):
# crs-toolchain regex update 941190
#
SecRule REQUEST_COOKIES|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|REQUEST_FILENAME|XML:/* "@rx (?i)<style.*?>.*?(?:@[\x5ci]|(?:[:=]|&#x?0*(?:58|3[AD]|61);?).*?(?:[\(\x5c]|&#x?0*(?:40|28|92|5C);?))" \
"id:941190,\
phase:2,\
block,\
Expand Down
Loading