使用正则表达式更新 Mod 安全核心规则集 OWASP 中的参数

Using Regular Expression in updating an argument in Mod Security Core Ruleset OWASP

我只是 运行 遇到了规则 981173 的问题 [msg "Restricted SQL Character Anomaly Detection Alert - Total] 用于将一些 youtube ID 发送到数据库。某些 ID 具有特殊字符,例如 -,我猜这是引发警告的原因

我一直在尝试从规则中排除 $_POSTvideo[391][],其中 391 是产品 ID,因此它不是修复键。它可以是 video[500][] 或类似的东西。

我试过了

    SecRuleUpdateTargetById 981173 !ARGS:video[*][]

但它不起作用。关于如何从规则中排除此动态 $_POST 键的任何想法?

  Message: Access denied with code 403 (phase 2). 
  Pattern match "([\~\!\@\#\$\%\^\&\*\(\)\-\+\=\{\}\[\]\|\:\;\"\'\\xc2\xb4\\xe2\x80\x99\\xe2\x80\x98\`\<\>].*?){4,}" 
at ARGS_NAMES:video[391][]. [file "/etc/httpd/crs-tecmint/owasp-modsecurity-crs/base_rules/modsecurity_crs_41_sql_injection_attacks.conf"] 
[line "159"] [id "981173"] [rev "2"] 
[msg "Restricted SQL Character Anomaly Detection Alert - Total # of special characters exceeded"] 
[data "Matched Data: ] found within ARGS_NAMES:video[391][]: video[391][]"] [ver "OWASP_CRS/2.2.9"] [maturity "9"] 
[accuracy "8"] [tag "OWASP_CRS/WEB_ATTACK/SQL_INJECTION"]

我觉得应该是:

SecRuleUpdateTargetById 981173 "!ARGS_NAMES:/^video\[.*\]\[\]/"

或者如果只有数字 ID,那么这个:

SecRuleUpdateTargetById 981173 "!ARGS_NAMES:/^video\[[0-9]*\]\[\]/"

请参阅此处的正则表达式示例:https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#SecRuleUpdateTargetById