有没有办法在我的网站的内容安全政策中包括一个firefox扩展弹出窗口



我想在firefox扩展的弹出窗口中嵌入一个iframe,但我得到了">Firefox无法打开此页面-为了保护您的安全,如果其他网站嵌入了该页面,www.example.com将不允许Firefox显示该页面。"这是因为网站example.com已经用CCD_ 2配置了CCD_。我可以把它改成frame-ancestors *,但我想要不那么宽泛的。

这取决于弹出窗口的来源(<iframe src=<iframe srcdoc=中指定了什么(
有些来源受CSP监管,另一个则不受。例如,像moz-extension:/chrome:这样的供应商方案应该绕过CSP。

此外,"自我"标记可能非常阴险:

,----------------- 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:的parent和使用HTTP:的iframe(不会在CSP3浏览器中引起问题(但会在CSP2浏览器中引起(。

如果是IIS,您需要将X-FRAME-OPTIONS标头从";拒绝";至";SAME-ORIGIN";或者添加X-FRAME-OPTIONS(如果不存在(。要做到这一点:

  • 打开IIS管理器,在左侧树上,左键单击要管理的站点
  • 双击"HTTP响应标头"图标
  • 右键单击标题列表并选择"添加">
  • 对于"名称",写入"X-FRAME-OPTIONS",对于值,写入所需选项,例如"SAME-ORIGIN">

最新更新