【问题标题】:mod_security2 rules for WordPressWordPress 的 mod_security2 规则
【发布时间】:2014-01-31 14:59:48
【问题描述】:

对于带有 WordPress 网站的服务器,是否有任何标准 (?!) mod_security2 规则? 我想明确表示我不想禁用 mod_security2(它的存在是有充分理由的)。在使用 WordPress 安装时,我只是想让我的生活更轻松一些。

我已阅读此http://wpsecure.net/2012/01/using-mod_security-2-with-wordpress/,但很高兴听到已经在使用 mod_security2WordPress 的人们的更多意见。

因为我不是这方面的专家,是否有任何文档可以阅读以下内容...

<LocationMatch "/wp-admin/post.php">
  SecRuleRemoveById 300015 300016 300017 950907 950005 950006 960008 960011 960904 959006
  SecRuleRemoveById phpids-17
  SecRuleRemoveById phpids-20
  SecRuleRemoveById phpids-21
  SecRuleRemoveById phpids-30
  SecRuleRemoveById phpids-61
</LocationMatch>

<LocationMatch "/wp-admin/admin-ajax.php">
  SecRuleRemoveById 300015 300016 300017 950907 950005 950006 960008 960011 960904 959006
  SecRuleRemoveById phpids-17
  SecRuleRemoveById phpids-20
  SecRuleRemoveById phpids-21
  SecRuleRemoveById phpids-30
  SecRuleRemoveById phpids-61
</LocationMatch>

<LocationMatch "/wp-admin/page.php">
  SecRuleRemoveById 300015 300016 300017 950907 950005 950006 960008 960011 960904
  SecRuleRemoveById phpids-17
  SecRuleRemoveById phpids-20
  SecRuleRemoveById phpids-21
  SecRuleRemoveById phpids-30
  SecRuleRemoveById phpids-61
</LocationMatch>

<LocationMatch "/wp-admin/options.php">
  SecRuleRemoveById 300015 300016 300017 950907 950005 950006 960008 960011 960904 959006
  SecRuleRemoveById phpids-17
  SecRuleRemoveById phpids-20
  SecRuleRemoveById phpids-21
  SecRuleRemoveById phpids-30
  SecRuleRemoveById phpids-61
</LocationMatch>

<LocationMatch "/wp-admin/theme-editor.php">
  SecRuleRemoveById 300015 300016 300017 950907 950005 950006 960008 960011 960904 959006
  SecRuleRemoveById phpids-17
  SecRuleRemoveById phpids-20
  SecRuleRemoveById phpids-21
  SecRuleRemoveById phpids-30
  SecRuleRemoveById phpids-61
</LocationMatch>

<LocationMatch "/wp-content/plugins/">
  SecRuleRemoveById 300015 340151 1234234 340153 1234234 300016 300017 950907 950005 950006 960008 960011 960904 959006
  SecRuleRemoveById phpids-17
  SecRuleRemoveById phpids-20
  SecRuleRemoveById phpids-21
  SecRuleRemoveById phpids-30
  SecRuleRemoveById phpids-61
</LocationMatch>

<LocationMatch "/wp-includes/">
  SecRuleRemoveById 960010 960012 950006 959006
  SecRuleRemoveById phpids-17
  SecRuleRemoveById phpids-20
  SecRuleRemoveById phpids-21
  SecRuleRemoveById phpids-30
  SecRuleRemoveById phpids-61
</LocationMatch>

<LocationMatch "/wp-content/themes/">
  SecRuleRemoveById 340151 340153 1234234 950006 959006
  SecRuleRemoveById phpids-17
  SecRuleRemoveById phpids-20
  SecRuleRemoveById phpids-21
  SecRuleRemoveById phpids-30
  SecRuleRemoveById phpids-61
</LocationMatch>

<LocationMatch "/wp-cron.php">
  SecRuleRemoveById 960015
</LocationMatch>

<LocationMatch "/feed">
  SecRuleRemoveById 960015
</LocationMatch>

<LocationMatch "/category/feed">
  SecRuleRemoveById 960015
</LocationMatch>

谢谢。

【问题讨论】:

    标签: wordpress mod-security mod-security2


    【解决方案1】:

    据我所知,没有可用的公共/免费规则集,其中包含用于 Wordpress 的特殊规则集。 wordpress 的商业规则集可从AtomicorpTrustwave 获得,但实际上我没有使用/测试它们。

    如果您不想全局包含配置,您发布的配置旨在包含在 Apache2 网络服务器的配置或每个虚拟主机的配置中。

    LocationMatch 是来自 Apache2 网络服务器的指令 - 请参阅:http://httpd.apache.org/docs/2.2/en/mod/core.html#locationmatch

    SecRuleRemoveById 是来自 mod_security2 https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#wiki-SecRuleRemoveById 的指令,它通过其 ID 禁用一个或多个规则

    将两者结合在一起,配置的第一行确实删除了带有给定 ID 的 mod_security2 规则,用于匹配“/wp-admin/post.php”的所有 URL(这是负责管理 Wordpress 后端中的博客文章的脚本)。

    总而言之,该配置为多个 Wordpress 脚本禁用了许多 mod_security2 / OWASP 规则。

    我对当前版本的 mod_security2 和 Wordpress 的体验如下:

    有几个月我和你现在的情况类似。我已经有一个使用 mod_security2 和 OWASP 核心规则集运行 Apache2 的网络服务器。网络服务器只托管了一些小型 Wordpress 网站,我很高兴,因为 mod_security2 阻止了针对 Wordpress 的几次自动攻击。

    然后我不得不将 mod_security2 更新到最新版本,这还需要将 OWASP 核心规则集更新到最新版本。新版本的 OWASP 核心规则集导致 Wordpress 出现许多 mod_security2 误报,所以我来到了您在问题中提到的同一篇文章。经过数小时的调试,我得出的结论是,这篇文章(来自 2012 年)似乎已经过时,并且 mod_security2 和 Wordpress 的开发已经到此为止,显示的排除规则该文章不适用于新版本的 mod_security2/OWASP 核心规则集和 Wordpress。

    我尝试创建自己的规则集,但实际上在工作数小时后放弃了,因为我不得不禁用 OWASP 核心规则集附带的太多规则(例如,由于误报而禁用许多 SQL 注入检查),这实际上消除了 mod_security2 和 OWASP 核心规则集的许多安全优势。

    【讨论】:

    • 感谢您分享您的经验。所以...如果我猜对了,您的建议是通过阅读 (mod_security) 日志来尝试捕获。
    • 是的,使用规则集(例如 OWASP)设置 mod_security2 并配置 mod_security2,使其仅使用设置“SecRuleEngine DetectionOnly”记录到审计日志。然后在前端和后端使用 Wordpress 站点并检查审核日志以查看哪些规则会产生误报。有了这个结果,您可以使用文章中所示的 SecRuleRemoveById 创建自己的排除规则。
    猜你喜欢
    • 2012-10-19
    • 1970-01-01
    • 2012-03-10
    • 2012-11-21
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 2017-06-01
    相关资源
    最近更新 更多