我在 Mod Security 上遇到了很多问题。我正忙于为工作中的项目编写 CMS,并且在开发页面以编辑某个数据库记录时,我不断收到 403 错误。经过几个小时把头撞在桌子上,调整了一些代码后,我终于将表单发布到的脚本更改为包含一个简单的echo "test";
. 即使提交到这个简单的页面也会引发 403 错误。我搞砸了我的表单,我最终发现,如果我减少了提交表单的数据量(特别是我减少了 textarea 中的文本量)。
检查日志后(是的,这不是我做的第一件事 - 叹息)我注意到我从 ModSecurity 收到了许多错误,例如:
[Mon Aug 12 16:34:45 2013] [error] [client XX.XXX.XXX.XXX] ModSecurity: Failed to access DBM file "/etc/httpd/logs//global": Permission denied [hostname "XXXXXXX.XXX"] [uri "/admin/index.php"] [unique_id "UgkAlW1shFcAAHTMK80AAAAF"]
[Mon Aug 12 16:34:45 2013] [error] [client XX.XXX.XXX.XXX] ModSecurity: Failed to access DBM file "/etc/httpd/logs//ip": Permission denied [hostname "XXXXXXX.XXX"] [uri "/admin/index.php"] [unique_id "UgkAlW1shFcAAHTMK80AAAAF"]
[Mon Aug 12 17:11:33 2013] [error] [client XX.XXX.XXX.XXX] ModSecurity: Rule execution error - PCRE limits exceeded (-8): (null). [hostname "XXXXXXX.XXX"] [uri "/admin/index.php"] [unique_id "UgkJNW1shFcAAHXUMHkAAAAH"]
[Mon Aug 12 17:11:33 2013] [error] [client XX.XXX.XXX.XXX] ModSecurity: Access denied with code 403 (phase 2). Match of "streq 0" against "TX:MSC_PCRE_LIMITS_EXCEEDED" required. [file "/etc/httpd/conf.d/mod_security.conf"] [line "93"] [msg "ModSecurity internal error flagged: TX:MSC_PCRE_LIMITS_EXCEEDED"] [hostname "XXXXXXX.XXX"] [uri "/admin/index.php"] [unique_id "UgkJNW1shFcAAHXUMHkAAAAH"]
几天来我一直在胡闹,谷歌搜索和更改规则无济于事。我似乎唯一能做的就是关闭这个虚拟主机的 ModSecurity。在我开发 CMS 时这对我来说很好,但在生产中这并不是我真正想做的事情。有没有人对导致此问题的原因以及如何对其进行排序有任何想法?日志似乎指向某种与正则表达式限制有关的规则,但是自从将我的帖子接收脚本更改为仅打印出单词 test 我没有对它们做任何事情(尽管我已经尝试通过SecPcreMatchLimit
and来提高限制SecPcreMatchLimitRecursion
)。我发送的数据量似乎有问题。