【问题标题】:How can I modify a pattern in Modsecurity Core Rule Set如何修改 Modsecurity 核心规则集中的模式
【发布时间】:2023-06-21 06:18:02
【问题描述】:

有没有办法更新 modsecurity_crs_custom.conf 文件中的规则模式?我有一个富文本编辑器,可以让人们包装链接文本。 <a href></a> 正在从 rule 973304 发出警告。我想从模式中排除href,但我不知道该怎么做。看起来没有类似SecRuleUpdatePatternById的选项

我试过了 SecRuleUpdateTargetById 973304 "XML:\b(background|dynsrc|lowsrc|src)\b\W*?="

但这显然行不通

这是警告:

Message: Access denied with code 403 (phase 2). Pattern match
"\\b(background|dynsrc|href|lowsrc|src)\\b\\W*?=" at ARGS:comment. 
[file "/etc/httpd/crs/owasp-  modsecurity/crs/base_rules/modsecurity_crs_41_xss_attacks.conf"] 
[line "333"] [id "973304"] [rev "2"] [msg "XSS Attack Detected"] 
[data "Matched Data: href= found within ARGS:comment: 
txt <a href=\x22http://kslll.com/391\x22>dgfdfgfdf </a> ......

【问题讨论】:

    标签: apache httpd.conf owasp mod-security


    【解决方案1】:

    我不知道编辑模式的方法,所以最简单的方法可能是忽略该参数的整个规则:

    SecRuleUpdateTargetById 973304 "!ARGS:comment"
    

    如果您想保留规则提供的其他保护而不是 href 位,那么您可以再次添加规则的副本(使用不同的规则 id)但没有 href 位。

    【讨论】: