gpt4 book ai didi

security - 当我有两个 CSP(内容安全策略)策略 - header 和元时会发生什么?

转载 作者:行者123 更新时间:2023-12-04 11:33:27 25 4
gpt4 key购买 nike

问题是关于拥有 CSP送达两次:

如果有一个通过 Content-Security-Policy 提供的策略会发生什么行为? HTTP 响应 header 以及使用 <meta /> 指定的另一个策略元素?

这两者会以某种方式合并吗?或者哪个优先? (我在规范中找不到关于此的明确信息)。

特定用例可能正在服务 Report-to通过 HTTP 响应 header 并将所有其他限制放在 <meta /> 中元素——因为其中一些是由 webpack 生成的——如果我不应该担心 <meta />被 HTTP 响应头策略淡化。

最佳答案

如果您在 Content-Security-Policy 中同时指定了 CSP 指令HTTP header 和 meta元素,浏览器使用最严格的 CSP 指令,无论在哪里指定。
https://w3c.github.io/webappsec-csp/#multiple-policies 上查看多个策略的详细信息以及使用 meta 的详细信息https://w3c.github.io/webappsec-csp/#meta-element 处的元素:

A policy specified via a meta element will be enforced alongwith any other policies active for the protected resource, regardlessof where they’re specified. The general impact of enforcing multiplepolicies is described in §8.1 The effect of multiple policies.

8.1. The effect of multiple policies

The impact is that adding additional policies to the list of policiesto enforce can only further restrict the capabilities of the protected resource.

关于security - 当我有两个 CSP(内容安全策略)策略 - header 和元时会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51148998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com