例如,此 pdf 在启用该模式后停止工作,并生成 403 错误。
[Wed May 30 18:47:19 2012] [error] [client xxxxxxxxxxx] ModSecurity: Warning.
Match of "within %{tx.allowed_http_versions}" against "REQUEST_PROTOCOL"
required. [file "base_rules/modsecurity_crs_30_http_policy.conf"]
[line "78"] [id "960034"] [msg "HTTP protocol version is not allowed by policy"]
[data "HTTP/1.1"] [severity "CRITICAL"] [tag "POLICY/PROTOCOL_NOT_ALLOWED"]
[tag "WASCTC/WASC-21"] [tag "OWASP_TOP_10/A6"] [tag "PCI/6.5.10"] [hostname
"somedomain.net"] [uri "/guide.pdf"] [unique_id "T8ZPFwoAARkAAA3sIQkAAAAG"]
第 78 行,
SecRule REQUEST_PROTOCOL "!@within %{tx.allowed_http_versions}"
"phase:2,t:none,block,msg:'HTTP protocol version is not allowed by policy',
severity:'2',id:'960034',tag:'POLICY/PROTOCOL_NOT_ALLOWED',tag:'WASCTC/WASC-21',
tag:'OWASP_TOP_10/A6',tag:'PCI/6.5.10',logdata:'%{matched_var}',setvar:'tx.msg=%
{rule.msg}',setvar:tx.anomaly_score=+%
{tx.warning_anomaly_score},setvar:tx.policy_score=+%{tx.warning_anomaly_score},
setvar:tx.%{rule.id}-POLICY/PROTOCOL_NOT_ALLOWED-%{matched_var_name}=%{matched_var}"
该规则是如何导致这些 URL 损坏的?
答案1
modsecurity_crs_10_config.conf
您应该有一个如下所示的部分:
#
# -=[ HTTP Policy Settings ]=-
#
# Set the following policy settings here and they will be propagated to the 30 rules
# file (modsecurity_crs_30_http_policy.conf) by using macro expansion.
# If you run into false positves, you can adjust the settings here.
#
SecAction "phase:1,id:'981212',t:none,nolog,pass, \
setvar:'tx.allowed_methods=GET HEAD POST OPTIONS', \
setvar:'tx.allowed_request_content_type=application/x-www-form-urlencoded multipart/form-data text/xml application/xml application/x-amf', \
setvar:'tx.allowed_http_versions=HTTP/0.9 HTTP/1.0 HTTP/1.1', \
setvar:'tx.restricted_extensions=.asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/', \
setvar:'tx.restricted_headers=/Proxy-Connection/ /Lock-Token/ /Content-Range/ /Translate/ /via/ /if/'"
您能否将“来自”这一行添加allowed_http_versions
到您的问题中?或者更好的是,将整个部分添加到问题中?
Apache 访问日志中针对同一请求的日志行可能也有用,但我认为仅使用配置中的 allowed_http_versions 行就足以获得信息了。
错误消息包含[data "HTTP/1.1"]
,表示由于HTTP/1.1
不是允许的 HTTP 版本之一而触发了规则。要么是您的allowed_http_versions
不包含HTTP/1.1
,要么是该规则集有其他问题,这意味着变量设置不正确。