WordPress + Disqus +拒绝执行内联脚本

时间:2015-03-28 22:46:29

标签: wordpress xss disqus content-security-policy

我在我的Wordpress网站上加载了Disquss,该网站运行在HTTPS上。问题是,虽然评论显示在网页的底部,但它们是白色的(因为页面的背景也是白色的,所以它们不可见)。

如果我在Chrome中打开Inspector,则会在控制台选项卡上显示以下错误。

    Refused to execute inline script because it violates the following
 Content Security Policy directive: "script-src https://*.twitter.com:* 
https://api.adsnative.com/v1/ad.json *.adsafeprotected.com *.google-analytics.com https://glitter-services.disqus.com 
https://*.services.disqus.com:* disqus.com http://*.twitter.com:* 
a.disquscdn.com api.taboola.com referrer.disqus.com *.scorecardresearch.com 
*.moatads.com https://admin.appnext.com/offerWallApi.aspx 'unsafe-eval' 
https://mobile.adnxs.com/mob *.services.disqus.com:*". Either the 'unsafe-
inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required
 to enable inline execution.

这是因为Chrome中的弹出式窗口拦截器扩展程序,但我想通过内容安全策略启用它:http://www.html5rocks.com/en/tutorials/security/content-security-policy/。基本上,错误发生在chrome-extension:// *方案中,因此我需要在Content-Security-Policy中添加适当的条目以允许chrome扩展。

如何禁用Chrome扩展程序的安全策略?

2 个答案:

答案 0 :(得分:0)

  

如何禁用Chrome扩展程序的安全策略?

不。此外,你可以不。

  

我需要在Content-Security-Policy中添加适当的条目以允许Chrome扩展。

扩展的CSP是(本地)扩展的一部分。

  

虽然评论显示在网页的底部,但它们是白色的   听起来像CSS的问题......你的文字color: black;怎么样?

或简称:网站无法使用扩展程序。哪个好 - 我不想让facebook禁用我的CSP并将我的个人色情偏好(从PornLiner插件)发送到我的个人资料。

答案 1 :(得分:0)

这不是你能够(或应该)有意义地解决的问题。它由properly implement themselves的扩展供应商决定。事实上,扩展程序正在尝试注入内联代码,并且内容安全策略会阻止它,因为CSP会阻止它。应该如此,因为从它的角度来看,扩展与恶意软件无法区分。

您可以(但)只是将规则添加到您网站的内容安全策略中以允许扩展程序运行...但这有潜在危险,非常具体案例,并且基本上应该只在企业环境中完成,其中每个人都有一个(编码不好的)浏览器扩展,需要与您的网站一起工作。即便如此,通常也会首选重新编码扩展名。

相关问题