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

Commit

Permalink
Rule to check if both C-L and T-E are present
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsch committed Sep 27, 2019
1 parent 021eaef commit b4f53c7
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
27 changes: 27 additions & 0 deletions rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,33 @@ SecRule REQUEST_METHOD "@rx ^POST$" \
"setvar:'tx.anomaly_score_pl1=+%{tx.notice_anomaly_score}'"


#
# As per RFC7230 3.3.2: A sender MUST NOT send a Content-Length
# header field in any message that contains a Transfer-Encoding header
# field.
#
# Related to 920170, 920171 and 920180.
#
SecRule &REQUEST_HEADERS:Transfer-Encoding "!@eq 0" \
"id:920181,\
phase:2,\
block,\
t:none,\
msg:'Content-Length and Transfer-Encoding headers present.',\
tag:'application-multi',\
tag:'language-multi',\
tag:'platform-multi',\
tag:'attack-protocol',\
tag:'OWASP_CRS/PROTOCOL_VIOLATION/INVALID_HREQ',\
tag:'CAPEC-272',\
ver:'OWASP_CRS/3.3.0',\
severity:'CRITICAL',\
chain"
SecRule &REQUEST_HEADERS:Content-Length "!@eq 0" \
"t:none,\
setvar:'tx.anomaly_score_pl1=+%{tx.critical_anomaly_score}'"


#
# Range Header Checks
#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
meta:
author: "fgsch"
enabled: true
name: "920181.yaml"
description: "Description"
tests:
-
test_title: 920181-1
stages:
-
stage:
input:
dest_addr: "127.0.0.1"
port: 80
method: "POST"
uri: "/"
headers:
Host: "localhost"
Accept: "*/*"
Content-Length: 7
Content-Type: "application/x-www-form-urlencoded"
Transfer-Encoding: "chunked"
User-Agent: "ModSecurity CRS 3 Tests"
data:
- "7"
- "foo=bar"
- "0"
- ""
- ""
stop_magic: true
output:
# Apache unsets the Content-Length header if
# Transfer-Encoding is found!
no_log_contains: id "920181"

0 comments on commit b4f53c7

Please sign in to comment.