如何防止SignalR引起的Modsecurity误报?

时间:2016-04-26 02:51:01

标签: asp.net signalr iis-8 mod-security false-positive

我最近构建了一个全新的开发服务器,以便尝试Modsecurity。但是,我使用SignalR为客户端 - 服务器通信提供了很多由.NET 4应用程序生成的误报。

如何在不影响Modsecurity效率的情况下防止误报?

点击看起来非常通用,所以我不想完全禁用这些规则,我想避免禁用/signalr/ uri上的点击,这将失去对SignalR的保护。

以下是我继续进行设置的方法:

  1. 我安装了Windows Server 2012
  2. 已安装的IIS角色
  3. 已安装所有操作系统更新
  4. 通过WebPlatformInstaller安装ModSecurity IIS
  5. 创建网站和已部署的应用程序
  6. 以下是我得到的三个常见误报:

    SQL身份验证绕过:

    > [client 192.168.0.104:59945] ModSecurity: Warning. Pattern match
    > "(?i:(?:in\\s*?\\(+\\s*?select)|(?:(?:n?and|x?x?or|div|like|between|and|not
    > |\\|\\||\\&\\&)\\s+[\\s\\w+]+(?:regexp\\s*?\\(|sounds\\s+like\\s*?[\"'`\xc2\xb4\xe2\x80\x99\xe2\x80\x98]|[=\\d]+x))|([\"'`\xc2\xb4\xe2\x80\x99\xe2\x80\x98]\\s*?\\d\\s*?(?:--|#))
    > ..." at ARGS:connectionData. [file "C:\/Program Files/ModSecurity
    > IIS/owasp_crs/base_rules/modsecurity_crs_41_sql_injection_attacks.conf"]
    > [line "239"] [id "981246"] [msg "Detects basic SQL authentication
    > bypass attempts 3/3"] [data "Matched Data: \x22name\x22:\x22 found
    > within ARGS:connectionData: [{\x22name\x22:\x22*****serverhub\x22}]"]
    > [severity "CRITICAL"] [tag "OWASP_CRS/WEB_ATTACK/SQL_INJECTION"]
    > [hostname "*********"] [uri
    > "/signalr/start?transport=webSockets&clientProtocol=1.4&connectionToken=iIxfXzLxKm9twEhHdomj4DI95so0QmpmqeTXD4Qe0VsQoJO47CHuEIuv2z7M%2B1TYx44PK5ko18t2aoaLb4WztjR1c8g0VP8MUaGkSO9KDftOzsGektSIDl%2FI1RPMQdTd&connectionData=%5B%7B%22name%22%3A%22*****serverhub%22%7D%5D&_=1461637088340"]
    > [unique_id "17798225729515683844"]
    

    受限制的SQL字符:

    > [client 192.168.0.104:59945] ModSecurity: Warning. Pattern match
    > "([\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\+\\=\\{\\}\\[\\]\\|\\:\\;\"\\'\\\xc2\xb4\\\xe2\x80\x99\\\xe2\x80\x98\\`\\<\\>].*?){4,}"
    > at ARGS:connectionData. [file "C:\/Program Files/ModSecurity
    > IIS/owasp_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: \x22 found within ARGS:connectionData:
    > [{\x22name\x22:\x22*****serverhub\x22}]"] [ver "OWASP_CRS/2.2.9"]
    > [maturity "9"] [accuracy "8"] [tag
    > "OWASP_CRS/WEB_ATTACK/SQL_INJECTION"] [hostname "*********"] [uri
    > "/signalr/start?transport=webSockets&clientProtocol=1.4&connectionToken=iIxfXzLxKm9twEhHdomj4DI95so0QmpmqeTXD4Qe0VsQoJO47CHuEIuv2z7M%2B1TYx44PK5ko18t2aoaLb4WztjR1c8g0VP8MUaGkSO9KDftOzsGektSIDl%2FI1RPMQdTd&connectionData=%5B%7B%22name%22%3A%22*****serverhub%22%7D%5D&_=1461637088340"]
    > [unique_id "17798225729515683844"]
    

    缺少接受标题:

    > [client 192.168.0.104:59949] ModSecurity: Warning. Operator EQ matched
    > 0 at REQUEST_HEADERS. [file "C:\/Program Files/ModSecurity
    > IIS/owasp_crs/base_rules/modsecurity_crs_21_protocol_anomalies.conf"]
    > [line "47"] [id "960015"] [rev "1"] [msg "Request Missing an Accept
    > Header"] [severity "NOTICE"] [ver "OWASP_CRS/2.2.9"] [maturity "9"]
    > [accuracy "9"] [tag
    > "OWASP_CRS/PROTOCOL_VIOLATION/MISSING_HEADER_ACCEPT"] [tag
    > "WASCTC/WASC-21"] [tag "OWASP_TOP_10/A7"] [tag "PCI/6.5.10"] [hostname
    > "*********"] [uri
    > "/signalr/connect?transport=webSockets&clientProtocol=1.4&connectionToken=iIxfXzLxKm9twEhHdomj4DI95so0QmpmqeTXD4Qe0VsQoJO47CHuEIuv2z7M%2B1TYx44PK5ko18t2aoaLb4WztjR1c8g0VP8MUaGkSO9KDftOzsGektSIDl%2FI1RPMQdTd&connectionData=%5B%7B%22name%22%3A%22*****serverhub%22%7D%5D&tid=6"]
    > [unique_id "17726168135477755906"]
    

    PS:我没有在该特定应用程序中使用任何SQL技术。

1 个答案:

答案 0 :(得分:4)

对于前两个,我建议你添加以下规则来忽略这些规则的ConnectionData参数:

 SecRuleUpdateTargetById 981246 !ARGS:'ConnectionData'
 SecRuleUpdateTargetById 981173 !ARGS:'ConnectionData'

最后我建议完全删除该规则。我发现它不是很有用,因为有些浏览器(在内存中的Android上)不会发送该标题:

SecRuleRemoveById 960015

您可能希望阅读此答案以了解如何调整ModSecurity: Extra sensitive Mod Security rules giving 403 forbidden error