首页 > 解决方案 > mod_security 规则 981172 误报

问题描述

Apache 中的 mod_security 配置在 CWP7.admin 上403 access denied运行 Grav CMS 时会产生错误:

[Thu Mar 21 15:40:47.967502 2019] [:error] [pid 21727:tid 140715786946304] [client 186.67.206.59:57900] [client 186.67.206.59] ModSecurity:使用代码 403 拒绝访问(阶段 2)。模式匹配 "([\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\+\\=\\{ \\}\\[\\]\\|\\:\\;\"\\'\\\xc2\xb4\\\xe2\x80\x99\\\xe2\x80\x98\\`\\ <\\>].*?){8,}" 在 REQUEST_COOKIES:grav-tabs-state. [file "/usr/local/apache/modsecurity-owasp-old/base_rules/modsecurity_crs_41_sql_injection_attacks.conf"] [line "157 "] [id "981172"] [rev "2"] [msg "Restricted SQL Character Anomaly Detection Alert - Total # of special characters exceeded"] [data "Matched Data: \x22 found in REQUEST_COOKIES:grav-tabs-state: {\x22tab-content.options.advanced\x22:\x22data.content\x22,\x22tab-content.options\x22:\x22data。http://xxxxxxxx.com/

此错误仅在第二次访问该网站时才会发生,因此很难解决。

标签: apachemod-securitygrav

解决方案


在检查日志后,我发现 mod_security 生成的基于 Grav CMS 的站点存在相同的错误模式。Barry Pollard 的这个回答指导了我的解决方案

该错误指出 mod_security 规则阻止了我的请求:

/usr/local/apache/modsecurity-owasp-old/base_rules/modsecurity_crs_41_sql_injection_attacks.conf _

对应的行

[行“157”]

以及它的ID

[编号“981172”]

使用来自 Barry 的建议,我在规则后添加了以下行:

SecRuleUpdateTargetById 981172 !REQUEST_COOKIES:grav-tabs-state

在这种情况下,我要求从规则 981172mod_security中省略。这解决了问题。REQUEST_COOKIES:grav-tabs-state

衷心感谢@barrypollard


推荐阅读