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

Commit e546c51

Browse files
committed
Rearange characters and add positive and negative test cases.
Moved the dash to the end of the character set to avoid escaping it. Added test with all the new characters and a test for multiple whitespaces. Allowed a previously blocked charset.
1 parent abfb3b3 commit e546c51

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ SecRule &TX:COMBINED_FILE_SIZES "@eq 1" \
867867
# - text/plain; charset="UTF-8"
868868
# - multipart/form-data; boundary=----WebKitFormBoundary12345
869869
#
870-
SecRule REQUEST_HEADERS:Content-Type "!@rx ^[\w/.\-+]+(?:\s?;\s?(?:boundary|charset)\s?=\s?['\"\w.\-()+,/:=?]+)?$" \
870+
SecRule REQUEST_HEADERS:Content-Type "!@rx ^[\w/.+-]+(?:\s?;\s?(?:boundary|charset)\s?=\s?['\"\w.()+,/:=?-]+)?$" \
871871
"id:920470,\
872872
phase:1,\
873873
block,\

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

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
Content-Type: 'text/plain; charset=/gar/bage'
4444
Content-Length: 0
4545
output:
46-
log_contains: "id \"920470\""
46+
no_log_contains: "id \"920470\""
4747
- test_title: 920470-4
4848
stages:
4949
- stage:
@@ -126,4 +126,46 @@
126126
Content-Type: 'multipart/form-data; boundary=----formdata-polyfill-0.40616634299_704013'
127127
Content-Length: 0
128128
output:
129-
no_log_contains: "id \"920470\""
129+
no_log_contains: "id \"920470\""
130+
- test_title: 920470-10
131+
stages:
132+
- stage:
133+
input:
134+
dest_addr: 127.0.0.1
135+
port: 80
136+
method: POST
137+
headers:
138+
User-Agent: "ModSecurity CRS 3 Tests"
139+
Host: "localhost"
140+
Content-Type: 'multipart/mixed; boundary=-----boundary_data:55780(123,45:667)+part'
141+
Content-Length: 0
142+
output:
143+
no_log_contains: "id \"920470\""
144+
- test_title: 920470-11
145+
stages:
146+
- stage:
147+
input:
148+
dest_addr: 127.0.0.1
149+
port: 80
150+
method: POST
151+
headers:
152+
User-Agent: "ModSecurity CRS 3 Tests"
153+
Host: "localhost"
154+
Content-Type: 'multipart/mixed; boundary= gc0p4Jq0M2Yt,08/jU534c0p?==:test'
155+
Content-Length: 0
156+
output:
157+
no_log_contains: "id \"920470\""
158+
- test_title: 920470-12
159+
stages:
160+
- stage:
161+
input:
162+
dest_addr: 127.0.0.1
163+
port: 80
164+
method: POST
165+
headers:
166+
User-Agent: "ModSecurity CRS 3 Tests"
167+
Host: "localhost"
168+
Content-Type: 'multipart/form-data; boundary= test_data_123456'
169+
Content-Length: 0
170+
output:
171+
log_contains: "id \"920470\""

0 commit comments

Comments
 (0)