ModSecurity:破坏性行为只能由链启动器规则指定

use*_*812 2 mod-security mod-security2

仅当文件驻留在特定目录中时,我才想使用 ModSecurity 修改响应内容。我实施了这样的规则:

SecRule REQUEST_URI "@contains /admin/" "phase:2,chain,t:none,t:urlDecode,t:lowercase,t:normalizePath,deny,log"

SecRule STREAM_OUTPUT_BODY "@rsub s/test/replaced_string/" "phase:4,t:none,log,pass,msg:'String replaced'"
Run Code Online (Sandbox Code Playgroud)

但是写完这条规则后,当我重新启动 apache2 时,modsecurity 给了我一个错误:ModSecurity: Disruptive actions can only be specified by chain starter rules。我也尝试以其他方式编写规则,但没有帮助。

知道为什么会这样吗?

Bar*_*ard 5

你的规则毫无意义。

如果它在管理区域中,则拒绝它并查看下一条规则(链),您允许它通过!是哪一个?阻止还是通过?

此外,您不能链接来自两个不同阶段的规则(链中第一个规则中的阶段 2 和第二个规则中的阶段 4)。

我建议你可能想要这样的东西:

SecRule REQUEST_URI "@contains /admin/" "phase:4,chain,t:none,t:urlDecode,t:lowercase,t:normalizePath,pass,log"
    SecRule STREAM_OUTPUT_BODY "@rsub s/test/replaced_string/" "t:none,log,msg:'String replaced'"
Run Code Online (Sandbox Code Playgroud)