内容安全策略 frame-ancestors 在 IE 11 中不起作用

Content security policy frame-ancestors not working in IE 11

目的是阻止其他网站在 iframe 中显示我们网站的内容。

由于站点的 URL,我无法使用 X-Frame-Options = SAMEORIGIN。主要为 www.xyz.com,次要为 sec.xyz.com。

所以我求助于内容安全策略(...代表其他域等)

<httpProtocol>
            <customHeaders>
                <add name="Content-Security-Policy" value="default-src 'self' localhost ...; script-src 'unsafe-inline' 'unsafe-eval' *;               style-src 'unsafe-inline' *; img-src * data; font-src * data:;               frame-ancestors 'self' localhost ...;" />
            </customHeaders>
        </httpProtocol>

FF 和 Chrome 不在测试页 iframe 中显示站点。

现在 IE 11 显示 iframe 内的站点,因为 frame-ancestors 不受支持。 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors

我尝试在全局文件中添加 header X-Content-Security-Policy,但 IE 11 仍然显示该站点。

protected void Application_BeginRequest(object sender, EventArgs e)
    {
        HttpContext.Current.Response.AddHeader("X-Content-Security-Policy", "frame-ancestors 'self' localhost ...");
    }

如何让 IE 11 遵守 header X-Content-Security-Policy

IE 不支持 frame-ancestors X-Content-Security-Policy。使用 X-Frame-OptionsALLOW-FROM.

定位 IE

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options