Apache SecRuleEngine On似乎在mod_security中阻止PUT和DELETE请求

Apache SecRuleEngine On似乎在mod_security中阻止PUT和DELETE请求,apache,mod-security2,Apache,Mod Security2,在本教程之后,为了在apache的mod_安全性中实现每IP请求突发限制,我启用了SecRuleEngine 经过几次测试后,它似乎在GET和POST请求上按预期工作,但是在未启用任何规则的情况下单独启用SecRuleEngine似乎会阻止PUT和DELETE请求。这似乎不是有意的行为 我在mod_security version 2中使用Apache2.4,但是如果mod_security碰巧是其中的一个bug,我愿意放弃它,并且我有一个速率限制的替代方案 我如何在使用或不使用mod_secu

在本教程之后,为了在apache的mod_安全性中实现每IP请求突发限制,我启用了SecRuleEngine

经过几次测试后,它似乎在GET和POST请求上按预期工作,但是在未启用任何规则的情况下单独启用SecRuleEngine似乎会阻止PUT和DELETE请求。这似乎不是有意的行为

我在mod_security version 2中使用Apache2.4,但是如果mod_security碰巧是其中的一个bug,我愿意放弃它,并且我有一个速率限制的替代方案


我如何在使用或不使用mod_security的情况下修复速率限制系统?

ModSecurity只会阻止要求阻止的内容

我的猜测是,尽管你说你没有启用任何规则,你还是包含了OWASP CRS,它确实阻止了那些方法

例如,版本2的modsecurity\u crs\u 10\u setup.conf.example配置文件中有以下规则:

#
# Set the following policy settings here and they will be propagated to the 30 rules
# file (modsecurity_crs_30_http_policy.conf) by using macro expansion.  
# If you run into false positves, you can adjust the settings here.
#
SecAction \
  "id:'900012', \
  phase:1, \
  t:none, \
  setvar:'tx.allowed_methods=GET HEAD POST OPTIONS', \
  setvar:'tx.allowed_request_content_type=application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/x-amf|application/json', \
  setvar:'tx.allowed_http_versions=HTTP/0.9 HTTP/1.0 HTTP/1.1', \
  setvar:'tx.restricted_extensions=.asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/', \
  setvar:'tx.restricted_headers=/Proxy-Connection/ /Lock-Token/ /Content-Range/ /Translate/ /via/ /if/', \
  nolog, \
  pass"
正如您所看到的,只有GET、HEAD、POST和OPTIONS被设置为允许的方法

较新版本3在crs-setup.conf中有类似的配置。示例:

# HTTP methods that a client is allowed to use.
# Default: GET HEAD POST OPTIONS
# Example: for RESTful APIs, add the following methods: PUT PATCH DELETE
# Example: for WebDAV, add the following methods: CHECKOUT COPY DELETE LOCK
#          MERGE MKACTIVITY MKCOL MOVE PROPFIND PROPPATCH PUT UNLOCK
# Uncomment this rule to change the default.
#SecAction \
# "id:900200,\
#  phase:1,\
#  nolog,\
#  pass,\
#  t:none,\
#  setvar:'tx.allowed_methods=GET HEAD POST OPTIONS'"
在这两种情况下,作为后续规则,than使用此设置来阻止PUT和DELETE等方法


无论您使用的是这些规则还是其他规则集,ModSecurity都应该在Apache错误日志中记录其阻止请求的原因。检查该规则以了解其被阻止的原因。

默认mod_安全模块文件中包含的usr/share文件阻止了该规则。我修复了这个问题,返回到0级偏执狂,这将禁用假阳性风险。谢谢你的回答。