Http-Status-Code-403
啟用 mod_security 後 URL 損壞
例如這個 pdf 在啟用 mod 後停止工作,它會產生 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 有什麼影響?
您應該有一個
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
,要麼有其他東西弄亂了那組規則,這意味著變數設置不正確。