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

Commit b8ce5e4

Browse files
authored
Merge pull request #1620 from NullIsNot0/v3.3/dev
Rule: 920480. Make rx recognize charset with quotes
2 parents 8047a03 + 6db01d9 commit b8ce5e4

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ SecRule REQUEST_HEADERS:Content-Type "@rx ^[^;\s]+" \
949949
#
950950
# Restrict charset parameter within the content-type header
951951
#
952-
SecRule REQUEST_HEADERS:Content-Type "@rx charset\s*=\s*([^;\s]+)" \
952+
SecRule REQUEST_HEADERS:Content-Type "@rx charset\s*=\s*[\"']?([^;\"'\s]+)" \
953953
"id:920480,\
954954
phase:1,\
955955
block,\

util/regression-tests/tests/REQUEST-920-PROTOCOL-ENFORCEMENT/920480.yaml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,46 @@
191191
# Content-Type: "application/x-www-form-urlencoded;charset=ibm037;charset=UTF-8" #double charset may cause evasion
192192
# data: "test=value"
193193
# output:
194-
# log_contains: "id \"920480\""
194+
# log_contains: "id \"920480\""
195+
- test_title: 920480-14
196+
stages:
197+
- stage:
198+
input:
199+
dest_addr: "127.0.0.1"
200+
port: 80
201+
method: "POST"
202+
headers:
203+
User-Agent: "ModSecurity CRS 3 Tests"
204+
Host: "localhost"
205+
Content-Type: "application/x-www-form-urlencoded; charset=\"utf-8\"" # random other IBM charset
206+
data: "test=value"
207+
output:
208+
no_log_contains: "id \"920480\""
209+
- test_title: 920480-15
210+
stages:
211+
- stage:
212+
input:
213+
dest_addr: "127.0.0.1"
214+
port: 80
215+
method: "POST"
216+
headers:
217+
User-Agent: "ModSecurity CRS 3 Tests"
218+
Host: "localhost"
219+
Content-Type: "application/x-www-form-urlencoded; charset='utf-8'" # random other IBM charset
220+
data: "test=value"
221+
output:
222+
no_log_contains: "id \"920480\""
223+
- test_title: 920480-16
224+
stages:
225+
- stage:
226+
input:
227+
dest_addr: "127.0.0.1"
228+
port: 80
229+
method: "POST"
230+
headers:
231+
User-Agent: "ModSecurity CRS 3 Tests"
232+
Host: "localhost"
233+
Content-Type: "application/x-www-form-urlencoded; charset=\"garbage\"" # random other IBM charset
234+
data: "test=value"
235+
output:
236+
log_contains: "id \"920480\""

0 commit comments

Comments
 (0)