Jetmon被ModSecurity阻塞,如何编写override规则?

我有一个VPC上的WordPress网站,我试图调整ModSecurity以减less误报。 当ModSecurity被激活时,我有Jetpack监视被拒绝。
从Apache error.loglogging

[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头的'/' ,或者允许Jetmon IP没有有效的Accept头。 但是我没有find任何可以让我这么做的运气。

我在其他地方发现了这个规则,但看起来它会接受所有请求

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

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

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

将xxxreplace为您的IP地址八位字节。 另一种select当然是closures导致问题的规则,但这根本不是推荐的做法。

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

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

希望这可以帮助。