我创建了一个 WordPress 插件,该插件很受欢迎,但我收到很多抱怨它不起作用。登录到许多用户的 WP 网站后(在询问管理员密码后),我注意到我无法轻松解决的最后一个问题是 mod_security 和 mod_security2 阻止了某些 AJAX 请求或 .htaccess ,这导致某些配置出现 500 错误。
那么首先为什么这段代码会导致某些服务器返回 500 错误
<IfModule mod_security2.c>
SecRuleRemoveById 300015
SecRuleRemoveById 300016
SecRuleRemoveById 300017
SecRuleRemoveById 950907
SecRuleRemoveById 950005
SecRuleRemoveById 950006
SecRuleRemoveById 960008
SecRuleRemoveById 960011
SecRuleRemoveById 960904
SecRuleRemoveById phpids-17
SecRuleRemoveById phpids-20
SecRuleRemoveById phpids-21
SecRuleRemoveById phpids-30
SecRuleRemoveById phpids-61
在其他服务器上,通过 id 删除规则会导致 500 错误:
<IfModule mod_security.c>
SecRuleRemoveById 300015
...
SecRuleRemoveById phpids-61
</IfModule>
所以目前唯一不会导致任何服务器崩溃的工作是
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
但这对于具有 mod_security2 的服务器来说还不够!
如何编写跨服务器 .htaccess 文件,以及应该添加哪些 IF 条件来在适用的任何地方禁用 mod_security 和 mod_security2,并且不会在其他配置上导致 500 错误?
编辑:
不仅在阿帕奇。任何使用 .htaccess 的地方。
Ryan C. Barnett,ModSecurity 社区经理声称:
2.x 中不再支持 .htaccess 文件,因为它也提高了
许多安全问题。
source: http://article.gmane.org/gmane.comp.apache.mod-security.user/3065 http://article.gmane.org/gmane.comp.apache.mod-security.user/3065
在 htaccess 上启用的唯一可能的配置如下(自 2.7.3 起),但您需要./configure --enable-htaccess-config
:
- SecAction
SecRule
SecRuleRemoveByMsg
- SecRule按标签删除
SecRuleRemoveById
SecRuleUpdateActionById
- SecRuleUpdateTargetById
- SecRuleUpdateTargetByTag
- SecRuleUpdateTargetByMsg
https://github.com/SpiderLabs/ModSecurity/blob/876d4f5f9558595c00f40af25ea6216386f15cd7/CHANGES#L69 https://github.com/SpiderLabs/ModSecurity/blob/876d4f5f9558595c00f40af25ea6216386f15cd7/CHANGES#L69
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)