firefox-addon - 有没有办法在我的网站的 Content-Security-Policy 中包含一个 firefox 扩展弹出窗口?
问题描述
我想在 Firefox 扩展的弹出窗口中嵌入 iframe,但我得到“ Firefox 无法打开此页面 - 为了保护您的安全,如果其他站点嵌入了该页面,www.example.com将不允许 Firefox 显示该页面。 ",这是因为站点 example.com 已经配置 Content-Security-Policy
了frame-ancestors 'self'
. 我可以将其更改为,frame-ancestors *
但我想要不那么广泛的内容。
解决方案
这取决于您的弹出窗口的来源(在<iframe src=
或 中指定的内容<iframe srcdoc=
)
一些来源是 CSP 规定的主题,另一些则不是。例如,供应商的方案(如moz-extension:
/ )chrome:
应该绕过 CSP。
'self' 标记也可能非常阴险:
,----------------- parent HTTP://example.com --------------------,
| |
| * Host-source is HTTP://example.com with the HTTP: scheme |
| |
| <iframe src='HTTPS://example.com'> |
| Content-Security-Policy: frame-ancestors 'self' |
| |
| * 'self' would be substituted by HTTPS://example.com, it |
| means that you actually have the header: |
| Content-Security-Policy: frame-ancestors HTTPS://example.com |
| therefore it will block embedding into parent with |
| HTTP://example.com because of schemes mismatch |
| (HTTP: !== HTTPS:) |
| |
| <iframe> |
|________________________________________________________________|
但相反的情况(使用 HTTPS: 的父级和使用 HTTP: 的 iframe)不会在 CSP3 浏览器中导致问题(但会在 CSP2 浏览器中导致)。
推荐阅读
- c# - 如何正确使用四元数来偏离原始旋转的 x 量?
- google-cloud-firestore - 服务器端代码的 Firestore 安全规则
- javascript - 如何在 Ionic 中获取设备的初始绝对方向
- html - 悬停时如何使 div 网格元素成为链接并与图像叠加?
- javascript - 不理解使用三点符号的 Javascript 语法
- python - 为什么 dbus 服务无法正常运行?
- c# - 使用 Windows MAF(插件管道)调试时出现异常
- c# - 单元测试未在 vs 2017 中运行
- python-3.x - Requests.get(zipfile) 获取“BadZipFile:文件不是 zip 文件”
- ruby-on-rails - 当我在非 SSL 上运行应用程序时,会话过期停止工作