即使标头存在,HSTS 显示已禁用

rog*_*uce 5 iis hsts iis-10

我的公司正在使用 Tenable 来识别安全漏洞。最近发现了丢失的 HSTS。我们的服务器使用的是 IIS 10。

我已经添加了多个博客中概述的 HSTS 标头,以及此处的问题。

我的根 web.config 如下所示:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appSettings>
        <add key="Environment" value="Local" />
    </appSettings>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="HTTP to HTTPS redirect global" stopProcessing="true" >
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}"
                        redirectType="Permanent" />
                </rule>
            </rules>
            <outboundRules>
                <rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
                    <match serverVariable="RESPONSE_Strict_Transport_Security"
                        pattern=".*" />
                    <conditions>
                        <add input="{HTTPS}" pattern="on" ignoreCase="true" />
                    </conditions>
                    <action type="Rewrite" value="max-age=31536000; includeSubDomains; preload" />
                </rule>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>

Run Code Online (Sandbox Code Playgroud)

问题:应用更改后,Tenable 仍然显示漏洞。此外,在检查 FireFox 开发工具中的站点时,我可以看到标头存在,但安全选项卡表明 HSTS 已禁用。

问题:如何让 Firefox 和 Tenable 显示此更改?

在此输入图像描述

在此输入图像描述

Att*_* H. -1

它也可能与您在 HSTS 标头中提到的预加载标记有关。您确定您的网站已添加到预加载列表中(由 google/chrome 维护)

如果您将站点部署为子域,那么您可能还需要将 HSTS 添加到父域(不是子域)并提交以进行预加载。

完成后,您可以在https://hstspreload.org/进行验证并查找更多详细信息