gpt4 book ai didi

php - ModSecurity 最大发布限制(PCRE 限制错误)

转载 作者:可可西里 更新时间:2023-11-01 12:38:15 28 4
gpt4 key购买 nike

我在 Mod 安全方面遇到了很多问题。我正忙于为工作中的项目编写 CMS,而在开发页面以编辑特定数据库记录时,我不断收到 403 错误。在我的头撞在 table 上几个小时后,调整了一些代码,我终于改变了我的表单被发布到的脚本,以包含一个简单的 echo "test";。即使提交到这个简单的页面也会引发 403 错误。我弄乱了我的表单,最终我发现,如果我减少数据量,我就可以很好地发布提交的表单(特别是我减少了文本区域内的文本量)。

检查日志后(是的,这不是我做的第一件事 - 叹息)我注意到我从 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 时,这对我来说很好,但在生产中,这并不是我真正想做的事情。有没有人对导致此问题的原因以及如何对其进行排序有任何想法?日志似乎指出了与正则表达式限制有关的某种规则,但是自从将我的帖子接收脚本更改为仅打印出单词测试后,我就没有对它们做任何事情(尽管我已经尝试通过 提高限制SecPcreMatchLimitSecPcreMatchLimitRecursion)。似乎我发送的数据量有问题。

最佳答案

我刚刚解决了一个类似的问题,其中有一个大型帖子在多个规则中触发了 PCRE 限制错误。我觉得 mod-security 仅仅因为请求爆炸就将其标记为恶意请求是错误的!

我按照本文中的建议将您提到的两个设置从默认值 1,500 提高到 500,000,它解决了我的问题。

The default values for the PCRE Match limit are very, very low with ModSecurity. You can got to 500K usually without harming your set. But for your information: The PCRE Match limit is meant to reduce the chance for a DoS attack via Regular Expressions. So by raising the limit you raise your vulnerability in this regard, but the PCRE errors are much worse from a security perspective. I run with 500K in prod usually:

SecPcreMatchLimit 500000 SecPcreMatchLimitRecursion 500000

https://github.com/SpiderLabs/owasp-modsecurity-crs/issues/656

另见 https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#SecPcreMatchLimit

关于php - ModSecurity 最大发布限制(PCRE 限制错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18226521/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com