3

我用 apache 服务器安装了 mod_security,现在它只阻止了 ie7/8/9 浏览器。(我可以用 firefox/chromium/etc 浏览网页)

日志说:

Message: String match within "Proxy-Connection Lock-Token Content-Range Translate via if" at REQUEST_HEADERS_NAMES:Connection. [file "/etc/apache2/mod_security/modsecurity_crs_30_http_policy.conf"] [line "99"] [id "960038"] [msg "HTTP header is restricted by policy"] [data "Connection"] [severity "WARNING"] [tag "POLICY/HEADER_RESTRICTED"] [tag "POLICY/FILES_NOT_ALLOWED"] [tag "WASCTC/WASC-21"] [tag "OWASP_TOP_10/A7"] [tag "PCI/12.1"] [tag "WASCTC/WASC-15"] [tag "OWASP_TOP_10/A7"] [tag "PCI/12.1"]
Message: Access denied with code 403 (phase 2). [file "/etc/apache2/mod_security/modsecurity_crs_49_enforcement.conf"] [line "25"] [msg "Anomaly Score Exceeded (score 20): Common SPAM/Email Harvester crawler"]
Action: Intercepted (phase 2)
Stopwatch: 1337888078594451 2694 (918 2353 -)
Producer: ModSecurity for Apache/2.5.12 (http://www.modsecurity.org/); core ruleset/2.0.6.
Server: Apache

规则 id "960038" 是:

SecRule REQUEST_HEADERS_NAMES "@within %{tx.restricted_headers}""phase:2,t:none,pass,nolog,auditlog,msg:'HTTP header is restricted by policy',id:'960038',tag:'POLICY/HEADER_RESTRICTED',tag:'POLICY/FILES_NOT_ALLOWED',tag:'WASCTC/WASC-21',tag:'OWASP_TOP_10/A7',tag:'PCI/12.1',tag:'WASCTC/WASC-15',tag:'OWASP_TOP_10/A7',tag:'PCI/12.1',severity:'4',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/HEADERS_RESTRICTED-%{matched_var_name}=%{matched_var}"

我有一个主要问题,另外两个来自第一个问题:

  • 我怎么知道这条规则是什么?
    • 忽略此规则是否安全?
    • 有什么方法可以修改规则以允许浏览网页?
4

1 回答 1

1
  1. 回答您的第一个问题 Mod-Security 为我们提供了有关其规则语言语法的非常详细的文档,以下是其文档的链接。ModSecurity 规则语言

  2. TX 用于用户定义的变量tx.restricted_headers它定义了您的 HTTP 策略,例如

    SecAction "phase:1,t:none,nolog,pass,setvar:'tx.restricted_headers=/Proxy-Connection/ /Lock-Token/ /Content-Range/ /Translate/ /via/ /if/'" 更详细信息请参阅此HTTP 政策

  3. 您上面提到的规则不是阻塞的,而是增加了一个针对可疑标头名称维护的数值,如我上面解释的 HTTP 策略中所述。

  4. 从提到的日志中可以看到阻止 IE 的规则

    消息:使用代码 403(第 2 阶段)拒绝访问。[file "/etc/apache2/mod_security/modsecurity_crs_49_enforcement.conf"] [line "25"] [msg "Anomaly Score Exceeded (score 20): Common SPAM/Email Harvester crawler"]

您可以修改异常分数阈值,也可以更改您的 HTTP 策略。您提到的规则是正确的,不需要评论。希望您明白我的意思

于 2012-06-02T11:38:05.373 回答