【问题标题】:Chrome extension, because it violates the following Content Security Policy directive but only after refreshing windowChrome 扩展,因为它违反了以下内容安全策略指令,但仅在刷新窗口后
【发布时间】:2020-11-04 15:48:07
【问题描述】:

我制作了一个 chrome 扩展程序,可以在 gmail url 上加载 iframe。到目前为止,一切都很好! 当我安装扩展程序时,它会加载我没有问题的框架,但问题来了。如果我再次刷新或访问 gmail,它将不再工作,出现以下错误,并且没有其他错误。

拒绝框架“https://...........com/”,因为它违反了 遵循内容安全策略指令:“frame-src 'self' https://clients4.google.com/insights/consumersurveys/ https://calendar.google.com/accounts/https://ogs.google.com https://onegoogle-autopush.sandbox.google.com https://accounts.google.com/https://apis.google.com/u/ https://apis.google.com/_/streamwidgets/ https://clients6.google.com/static/ https://content.googleapis.com/static/ https://mail-attachment.googleusercontent.com/ https://www.google.com/calendar/https://calendar.google.com/calendar/ https://docs.google.com/https://drive.google.com https://.googleusercontent.com/docs/securesc/ https://feedback.googleusercontent.com/resources/ https://www.google.com/tools/feedback/ https://support.google.com/inapp/ https://.googleusercontent.com/gadgets/ifr https://hangouts.google.com/https://talkgadget.google.com/ https://.talkgadget.google.com/ https://www-gm-opensocial.googleusercontent.com/gadgets/ https://plus.google.com/https://wallet.google.com/gmail/ https://www.youtube.com/embed/ https://clients5.google.com/pagead/drt/dn/ https://clients5.google.com/ads/measurement/jn/ https://www.gstatic.com/mail/ww/https://www.gstatic.com/mail/intl/ https://clients5.google.com/webstore/wall/ https://ci3.googleusercontent.com/https://workspace.google.com/u/ https://workspace.google.com/marketplace/appfinder https://gsuite.google.com/u/ https://gsuite.google.com/marketplace/appfinder https://www.gstatic.com/mail/promo/https://notifications.google.com/ https://tracedepot-pa.clients6.google.com/static/ https://staging-taskassist-pa-googleapis.sandbox.google.com https://taskassist-pa.clients6.google.com https://.prod.amp4mail.googleusercontent.com/ https://.client-channel.google.com/client-channel/client https://clients4.google.com/invalidation/lcs/client https://tasks.google.com/embed/https://keep.google.com/companion https://addons.gsuite.google.com https://contacts.google.com/widget/hovercard/v/2 https://gsuite.google.com https://.googleusercontent.com/confidential-mail/attachments/”。

现在。您想知道我是否将 CSP 放在我的标题中。答案是肯定的。我有 header("Content-Security-Policy: frame-src 'self' https://*.google.com;");在我的 php 和标题 si 中加载。但我无法回答的问题是:Chrome 是否在页面刷新后看到错误,为什么?

理论上,如果 CSP 中存在问题,它应该从一开始就阻止 iframe,而不是稍后。 你知道吗?

【问题讨论】:

    标签: html google-chrome content-security-policy


    【解决方案1】:

    拒绝框架“https://...........com/”,因为它违反了 遵循内容安全策略指令:“frame-src 'self' ... Google 的域在这里 ...

    这不是您的 CSP,而是 Google 的一些 iframe 发布了自己的。因为通常谷歌不允许将自己嵌入到第三方中。 最有趣的部分:“https://...........com/”是隐藏的(这里是您的域吗?)。

    页面刷新后 Chrome 是否出现错误,为什么?

    Google 的服务基于很多它自己的 iframe,它们之间基于 Cookie。
    例如,您可以将 https://gmail.com 嵌入 iframe,但如果您已登录 帐户(具有身份验证 Cookie),Gmail 会自动将您重定向到不允许 iframe 的 https://mail.google.com/mail/u/0/ 页面(因为X-Frame-Options deny)。

    Google 的 iframe 的行为可能非常复杂,因此如果不进行详细研究,就无法准确回答“为什么”。

    无论如何,将 Google 服务(并非正式用于嵌入)嵌入 iframe 并不是一个好主意。出于安全考虑,Google 不允许这样做。

    【讨论】:

      猜你喜欢
      • 2016-04-29
      • 1970-01-01
      • 1970-01-01
      • 2020-06-23
      • 2020-09-26
      • 2016-01-14
      • 2016-10-24
      • 2012-11-27
      • 2015-09-21
      相关资源
      最近更新 更多