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

标签 security web browser content-security-policy

问题是关于拥有 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 along with any other policies active for the protected resource, regardless of where they’re specified. The general impact of enforcing multiple policies 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 policies to enforce can only further restrict the capabilities of the protected resource.

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

相关文章:

security - 定义的 ('_JEXEC' )或死 ('Restricted access' )如何工作?

angularjs - JWT 身份验证过期

bash - 检查网页是否已更新的简单脚本

c# - Ajax 幻灯片放映扩展器不起作用

css - 如果多背景,背景简写不起作用

security - ArcGIS JavaScript API 中的参数化查询

php - 所有 PHP 文件都被黑客入侵

Docker-compose 挂起附加到

windows - Mac 设置以在每种可能的浏览器中测试应用程序?

google-chrome - Protractor - 不要在导航后清除控制台日志