apache - 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/
此错误仅在第二次访问该网站时才会发生,因此很难解决。
解决方案
在检查日志后,我发现 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
推荐阅读
- python - Peewee 主键未显示(失败行包含 null)
- c++ - 在大型项目中以现代 CMake 方式添加标头
- android - 我应该为不同的图像组件大小存储不同大小的图像以提高性能吗?
- css - 两个 Bootstrap 列不适合屏幕
- wordpress - Docker Nginx + 多个域 + 多个 wordpress 在他们自己的目录上 1 vps
- javascript - 使用 three.js 循环浏览材料 onclick
- openssl - 无法安装 DeepDive
- c# - 使用对象优化 C# Web API 内存管理的最佳实践
- c# - SQLite Xamarin 将数据库表形成为 ListView
- c# - 在c#中将字典转换为匿名对象?