Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Commit aa2794a

Browse files
fgschdune73
authored andcommitted
Correct rule 941310 to use single-byte variants and fix FPs (#1596)
* Fix test to use the single byte characters Add a test that uses utf-8 as well. * Change pattern to use the single-byte variants Patterns in ModSecurity are not treated as UTF strings. Fixes #1595. * Add negative tests and update descriptions * Improve pattern Change it to avoid FPs for \xbc\xbc and \xbe\xbe (i.e. << and >>). Use negated classes for better performance.
1 parent d58ecba commit aa2794a

File tree

2 files changed

+58
-7
lines changed

2 files changed

+58
-7
lines changed

rules/REQUEST-941-APPLICATION-ATTACK-XSS.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAME
619619
# Reported by Mazin Ahmed
620620
#
621621

622-
SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?:¾|¼).*(?:¾|¼|>)|(?:¾|¼|<).*(?:¾|¼)" \
622+
SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx \xbc[^\xbe>]*[\xbe>]|<[^\xbe]*\xbe" \
623623
"id:941310,\
624624
phase:2,\
625625
block,\
Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,75 @@
11
---
22
meta:
3-
author: "Christian S.J. Peron"
4-
description: None
3+
author: Christian S.J. Peron, Federico G. Schwindt
4+
description: US-ASCII Malformed Encoding XSS Filter
55
enabled: true
66
name: 941310.yaml
77
tests:
88
-
99
test_title: 941310-1
10-
desc: "US-ASCII Malformed Encoding XSS Filter"
10+
desc: Positive test using single byte
1111
stages:
1212
-
1313
stage:
1414
input:
1515
dest_addr: 127.0.0.1
1616
headers:
1717
Host: localhost
18-
Content-type: "iso-8859-15"
18+
Content-type: us-ascii
1919
method: POST
2020
port: 80
21-
uri: "/"
22-
data: "var=.*¾.*¼.*"
21+
uri: /
22+
data: var=\xbcscript\xbealert(\xa2XSS\xa2)\xbc/script\xbe
2323
output:
2424
log_contains: id "941310"
25+
-
26+
test_title: 941310-2
27+
desc: Positive test using utf-8
28+
stages:
29+
-
30+
stage:
31+
input:
32+
dest_addr: 127.0.0.1
33+
headers:
34+
Host: localhost
35+
Content-type: us-ascii
36+
method: POST
37+
port: 80
38+
uri: /
39+
data: var=\xc2\xbcscript\xc2\xbealert(\xc2\xa2XSS\xc2\xa2)\xc2\xbc/script\xc2\xbe
40+
output:
41+
log_contains: id "941310"
42+
-
43+
test_title: 941310-3
44+
desc: Negative test for opening tag
45+
stages:
46+
-
47+
stage:
48+
input:
49+
dest_addr: 127.0.0.1
50+
headers:
51+
Host: localhost
52+
Content-type: us-ascii
53+
method: POST
54+
port: 80
55+
uri: /
56+
data: var=\xbc\xbc
57+
output:
58+
no_log_contains: id "941310"
59+
-
60+
test_title: 941310-4
61+
desc: Negative test for closing tag
62+
stages:
63+
-
64+
stage:
65+
input:
66+
dest_addr: 127.0.0.1
67+
headers:
68+
Host: localhost
69+
Content-type: us-ascii
70+
method: POST
71+
port: 80
72+
uri: /
73+
data: var=\xbe\xbe
74+
output:
75+
no_log_contains: id "941310"

0 commit comments

Comments
 (0)