【问题标题】:ModSecurity subrequest whitelistModSecurity 子请求白名单
【发布时间】:2020-11-14 22:53:45
【问题描述】:

我有带有 ModSecurity 的 Nginx 和 OWASP CRS 设置被用作几个不同 Web 服务器的反向代理。我正在使用add_after_body /gdprmessage.html; 将 GDPR 接受附加到每个页面。一切正常,但偶尔在 POST 请求上,结果页面会呈现丑陋的 403 错误,而不是我的 GDPR 消息。我在日志中收到这条消息:

2020/07/24 22:42:42 [error] 19576#0: *1664601 [client 10.0.0.10] ModSecurity: Access denied with code 403 (phase 2). Matched "Operator `Ge' with parameter `5' against variable `TX:ANOMALY_SCORE' (Value: `5' ) [file "/etc/nginx/owasp-modsecurity-crs/rules/REQUEST-949-BLOCKING-EVALUATION.conf"] [line "80"] [id "949110"] [rev ""] [msg "Inbound Anomaly Score Exceeded (Total Score: 5)"] [data ""] [severity "2"] [ver "OWASP_CRS/3.2.0"] [maturity "0"] [accuracy "0"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-generic"] [hostname "10.0.0.2"] [uri "/wp-login.php"] [unique_id "159562336247.351441"] [ref ""], client: 10.0.0.10, server: test.com, request: "POST /wp-login.php HTTP/1.1", subrequest: "/gdprmessage.html", host: "www.test.com", referrer: "https://www.test.com/wp-login.php"

登录页面内容呈现正常,但 GDPR 子请求不呈现。我尝试通过在我的 ModSec 规则中添加以下内容来解决此问题:

SecRule REQUEST_URI "/gdprmessage.html" "id:33000,phase:1,nolog,allow,ctl:ruleRemoveById=949110"

这不起作用,所以我尝试将请求完全列入白名单:

SecRule REQUEST_URI "/gdprmessage.html" "id:33000,phase:1,log,allow,ctl:ruleEngine=Off"

这也不起作用。我推断REQUEST_URI 可能只有原始请求,所以我测试了:

SecRule REQUEST_URI "/wp-login.php" "id:33000,phase:1,log,allow,ctl:ruleEngine=Off"

这“有效”,但不是解决方案。我查看了https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#Variables 上可用于SecRule 的所有变量,但没有看到任何可以提供“子请求”值的东西。

有没有一种方法可以将我的/gdprmessage.html 子请求列入白名单,而将 CRS 留给请求本身?

【问题讨论】:

    标签: nginx nginx-reverse-proxy mod-security2


    【解决方案1】:

    我试图通过 ModSecurity 异常来解决问题。事实证明,答案只是将modsecurity off 添加到该位置。

    如果它对其他人有帮助,这是我的网站定义中包含的 GDPR sn-p:

    add_after_body /gdprmessage.html;
    
    location = /gdprmessage.html {
        root /etc/nginx/snippets/;
        modsecurity off;
    
        if ($http_x_requested_with = XMLHttpRequest) {
            return 200;
        }
    }
    

    测试 XMLHttpRequests 可确保我的 GDPR 消息不会附加到 ajax 查询。

    【讨论】:

      猜你喜欢
      • 2018-01-10
      • 1970-01-01
      • 2014-01-16
      • 2022-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多