2017-08-03 226 views
0

这是比赛,我得到:ModSecurity的白名单JSON ARG

against variable `ARGS:json' (Value: `{"j_username": "username", "j_password": "password_with_special_marks", "remember_me": false, "from": (4 characters omitted)') [file "/usr/local/nginx/conf/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"] [line "509"] [id "942130"] 

密码具有特殊的标志,它标志它作为SQL注入。

我试着白名单规则既:

SecRuleUpdateTargetById 942130 !ARGS:'j_password' 
SecRuleUpdateTargetById 942130 !ARGS:'json' 

两人都不工作。问题是我应该从ARGS的比赛中拿出什么样的论据?

回答

0

你应该匹配ARGS:json。这里有几件事要考虑。

  1. SecRuleUpdateTargetById必须在规则之后。它看起来像你使用OWASP CRS 3.x中,所以这意味着,理想情况下,重命名RESPONSE-999-排除规则-AFTER-CRS.conf.example到RESPONSE-999-排除规则-AFTER-CRS.conf和把它放在那里。
  2. 为了安全起见我会遵循参考手册https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#secruleupdatetargetbyid提出的指导。格式应该是SecRuleUpdateTargetById 12345“!ARGS:foo”。在你的情况SecRuleUpdateTargetById 942130“ARGS:JSON”
  3. 虽然它可能不是这样,如果你的整个请求是JSON你可以告诉ModSecurity的处理它是这样。这在默认情况下在建议的ModSecurity配置(https://github.com/SpiderLabs/ModSecurity/blob/v2/master/modsecurity.conf-recommended#L25)中完成。如果只是参数是JSON,不幸的是ModSecurity目前无法处理给定的参数。但是,保护措施仍然有效,但不像上述情况那样理想。
  4. 如果这是一个完善的项目,如Drupal的,可以考虑使用现有的Drupal排除(https://github.com/SpiderLabs/owasp-modsecurity-crs/blob/e4e0497be4d598cce0e0a8fef20d1f1e5578c8d0/rules/REQUEST-903.9001-DRUPAL-EXCLUSION-RULES.conf)。这些可以通过在crs-setup.conf中注释SecAction 900130并启用Drupal排除来启用。请参阅示例https://github.com/SpiderLabs/owasp-modsecurity-crs/blob/v3.0/master/crs-setup.conf.example#L296

祝你好运!