Jetmon 被 ModSecurity 阻止,如何编写覆盖规则?

Jetmon 被 ModSecurity 阻止,如何编写覆盖规则?

我在 VPC 上有一个 WordPress 网站,我正在尝试调整 ModSecurity 以减少误报。我有 Jetpack 监控,但当 ModSecurity 处于活动状态时,监控会被拒绝。
来自 Apache error.log 的日志

[Sun Jul 26 20:25:31.569393 2015] [:error] [pid 5544] [client 192.0.84.33] ModSecurity: Access denied with code 403 (phase 2). Operator EQ matched 0 at REQUEST_HEADERS. [file "/etc/modsecurity/activated_rules/modsecurity_crs_21_protocol_anomalies.conf"] [line "47"] [id "960015"] [rev "1"] [msg "Request Missing an Accept Header"] [severity "NOTICE"] [ver "OWASP_CRS/2.2.9"] [maturity "9"] [accuracy "9"] [tag "OWASP_CRS/PROTOCOL_VIOLATION/MISSING_HEADER_ACCEPT"] [tag "WASCTC/WASC-21"] [tag "OWASP_TOP_10/A7"] [tag "PCI/6.5.10"] [hostname "www.randomhikes.com"] [uri "/"] [unique_id "VbWIi38AAAEAABWoVtoAAAAE"]

来自 modsec_audit.log

    --a5af5c33-A--
[26/Jul/2015:20:26:27 --0500] VbWIw38AAAEAABWngAIAAAAD 122.248.245.244 4366 172.31.41.204 80
--a5af5c33-B--
HEAD / HTTP/1.1
Host: www.randomhikes.com
User-Agent: jetmon/1.0 (Jetpack Site Uptime Monitor by WordPress.com)
Connection: Close

--a5af5c33-F--
HTTP/1.1 403 Forbidden
Connection: close
Content-Type: text/html; charset=iso-8859-1

--a5af5c33-E--

--a5af5c33-H--
Message: Access denied with code 403 (phase 2). Operator EQ matched 0 at REQUEST_HEADERS. [file "/etc/modsecurity/activated_rules/modsecurity_crs_21_protocol_anomalies.conf"] [line "47"] [id "960015"] [rev "1"] [msg "Request Missing an Accept Header"] [severity "NOTICE"] [ver "OWASP_CRS/2.2.9"] [maturity "9"] [accuracy "9"] [tag "OWASP_CRS/PROTOCOL_VIOLATION/MISSING_HEADER_ACCEPT"] [tag "WASCTC/WASC-21"] [tag "OWASP_TOP_10/A7"] [tag "PCI/6.5.10"]
Action: Intercepted (phase 2)
Stopwatch: 1437960387776697 11287 (- - -)
Stopwatch2: 1437960387776697 11287; combined=11003, p1=10427, p2=458, p3=0, p4=0, p5=95, sr=31, sw=23, l=0, gc=0
Response-Body-Transformed: Dechunked
Producer: ModSecurity for Apache/2.7.7 (http://www.modsecurity.org/); OWASP_CRS/2.2.9.
Server: Apache
Engine-Mode: "ENABLED"

--a5af5c33-Z--

从我过去几个小时的研究来看,ModSecurity 似乎拒绝了 JetMon,因为它没有发送 Accept Header,因此被标记为潜在的恶意攻击。

我希望可以为虚拟主机 .conf 文件编写一个覆盖,以便允许jetmon用户代理尝试'/'在没有 Accept Header 的情况下进行访问,或者允许 Jetmon IP 在没有有效 Accept Header 的情况下通过。但我没有找到任何可以让我做到这一点的东西。

我在其他地方找到了这条规则,但它看起来会接受所有请求

SecRule REQUEST_URI "/" chain
SecRule &REQUEST_HEADERS:Accept-Language "@eq 0"

答案1

如果 JetMon 服务器在您的控制之下,您可以将它本身列入白名单。在您的 mod_security.conf 文件中,添加以下行

SecRule REMOTE_ADDR "^xxx\.xxx\.xxx\.xxx$" phase:1,nolog,allow,ctl:ruleEngine=Off

将 xxx 替换为您的 IP 地址八位字节。另一个选项当然是关闭导致问题的规则,但根本不建议这样做。

更新:也许更好的是,您可以只禁用 JetMon 主机的一条规则。请注意,我从您的 modsec_audit.log 条目中获取了规则 ID。

SecRule REMOTE_ADDR "^xxx\.xxx\.xxx\.xxx$" phase:1,nolog,allow,ctl:ruleRemoveById=960015

希望这可以帮助。

相关内容