【问题标题】:SonarQube - Cookie not sent over SSL (CWE 614) (HttpOnly)SonarQube - Cookie 未通过 SSL (CWE 614) (HttpOnly) 发送
【发布时间】:2018-03-18 13:15:47
【问题描述】:

我们正在我们的环境中实现SonarQube,在IIS 代理后面运行HTTPS 连接。
在对应用程序(HP Fortify)运行安全扫描后,它返回了一些 cookie 安全问题,具体如下:

Cookie Security: Cookie Not Sent Over SSL (4720)
CWE: 614

GET /sonarqube/ HTTP/1.1
Host: sonar
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
X-WIPP: AscVersion=16.20.608.0
X-Scan-Memo: Category="Crawl.EventMacro.Startup";
SID="F0A2B8712E7F609FAA4899C"; SessionType="StartMacro"; CrawlType="None";
X-RequestManager-Memo: sid="13442"; smi="0"; Category="EventMacro.Login";
MacroName="sonarqube-priv-loginmacro";
X-Request-Memo: ID="0e42a-fcf-4b6-a8f-0fbceb4c"; ThreadId="169";
Pragma: no-cache
Cookie: CustomCookie=WebInspect0
Response:
Report Date: 09/3/2017 38
HTTP/1.1 302 Found
Cache-Control: no-cache
Content-Type: text/html;charset=utf-8
Location: https://sonar/sonarqube/sessions/new
Server: Microsoft-IIS/10.0
Set-Cookie: JSESSIONID=XXX; Path=/sonarqube/; HttpOnly
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1...TRUNCATED...

您认为这是由于IIS 配置还是只是SonarQube 应用程序中的标准配置?
我不知道如何解释这里的结果或如何挖掘它。
任何建议将不胜感激。

【问题讨论】:

    标签: cookies sonarqube sonarqube-ops cookie-httponly


    【解决方案1】:

    使用 IIS 等反向代理,您必须配置反向代理以将以下标头发送到 SonarQube:X-Forwarded-Proto: https

    你可以看看这里:IIS Equivalent of "proxy_set_header X-Forwarded-Proto https;"

    设置此标头后,会话将缺少安全标志。

    【讨论】:

    • 谢谢埃里克。我已经在IIS 中设置了X-Forwarded-Proto: https。其余流量为https。根据您引用的链接,我也尝试添加HTTP_X_FORWARDED_SCHEMA,但没有成功。我已按照官方 SonarQube 安装 here 中链接的步骤进行操作。似乎我缺少将 cookie 设置为安全的东西。
    • 我能够使用 NGINX 重现相同的东西。 JSESSIONID 没有 secure 标志。 location / { proxy_pass http://localhost:9000/; proxy_read_timeout 90; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto "https"; }
    • @lapfrank 你能告诉我你使用的是哪个 SonarQube 版本吗?
    • 我使用的是 5.6.6 LTS 版本。
    • 哦,我看到 5.6.6 仍在使用 Ruby on Rails,并且这些 cookie 上缺少安全标志。最好的方法是配置 IIS 来添加这个缺失的标志。我不是 IIS 专家,但 stackoverflow.com/questions/25676490/… 之类的东西会解决这个问题。
    【解决方案2】:

    感谢this answer,我能够在JSESSIONID cookie 上将标志设置为secure

    WEB-INF\web.xml 中嵌入的tomcat 实例中,我添加了secure true 行:

      <session-config>
        <!-- in minutes -->
        <session-timeout>20</session-timeout>
        <cookie-config>
          <http-only>true</http-only>
          <secure>true</secure>
        </cookie-config>
      </session-config>
    

    这可能不是最安全的方法,因为它似乎在任何情况下都强制使用secure 标志,但由于我在反向代理后面并拒绝除https/443 流量之外的任何传入连接,它应该工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-19
      • 2021-08-26
      • 2021-08-05
      • 1970-01-01
      • 2019-01-27
      • 1970-01-01
      • 2021-10-15
      • 1970-01-01
      相关资源
      最近更新 更多