首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >SecRuleEngine On似乎阻止mod_security中的PUT和DELETE请求

SecRuleEngine On似乎阻止mod_security中的PUT和DELETE请求
EN

Stack Overflow用户
提问于 2018-02-15 15:02:50
回答 2查看 5.5K关注 0票数 2

在本教程之后,我启用了SecRuleEngine,以便在apache的mod_security中实现每个IP请求突发限制。

https://johnleach.co.uk/words/2012/05/15/rate-limiting-with-apache-and-mod-security/

经过几次测试后,它似乎在GET和POST请求上正常工作,但是启用SecRuleEngine本身(没有启用任何规则)似乎会阻止PUT和DELETE请求。这似乎不是一种有意的行为。

https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#SecRuleEngine

我使用Apache2.4与mod_security版本2,但我愿意放弃mod_security,如果它碰巧是一个错误,我有一个替代的速率限制它。

如何使用或不使用mod_security来修复速率限制系统?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-02-15 15:20:24

ModSecurity只阻塞它要阻止的内容。

我的猜测是,尽管说您没有启用任何规则,但是包含了OWASP,它确实显式地阻止了这些方法。

例如,版本2的modsecurity_crs_10_setup.conf.example配置文件中有以下规则:

代码语言:javascript
运行
复制
#
# 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"

如您所见,只有GETHEADPOSTOPTIONS被设置为允许的方法。

更新的版本3在crs-setup.conf中具有类似的配置。

代码语言:javascript
运行
复制
# 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'"

在这两种情况下,作为后续规则,都要使用此设置来阻止PUTDELETE等方法。

无论您是在使用这些规则,还是使用其他规则集,ModSecurity都应该记录它在Apache日志中阻塞请求的原因。检查一下,看看为什么它被封锁了。

票数 6
EN

Stack Overflow用户

发布于 2021-07-22 13:44:16

将偏执狂水平改为1、2、3或4--这在新闻OWASP Mod_Security中并不重要,偏执水平永远不应该是"0“

cd /usr/share/modsecurity-crs

代码语言:javascript
运行
复制
SecAction \
"id:900000,\
phase:1,\
nolog,\
pass,\
t:none,\
setvar:tx.paranoia_level=1"
enter code here

添加RESTful API方法

允许客户端使用的HTTP方法。默认值:获取头帖选项示例:对于RESTful API,添加以下方法: PUT修补程序删除示例:对于WebDAV,添加以下方法:结帐复制删除锁合并MKACTIVITY移动PROPFIND PROPPATCH解锁解锁

只是取消HTTP方法的HTTP策略:

代码语言:javascript
运行
复制
sudo nano /usr/share/modsecurity-crs/crs-setup.conf

SecAction \
"id:900200,\
phase:1,\
nolog,\
pass,\
t:none,\
setvar:'tx.allowed_methods=GET HEAD POST OPTIONS PUT PATCH DELETE'"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48810247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档