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

标签 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 扩展程序的安全策略?

最佳答案

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

您可以(但不应该)简单地向您网站的内容安全策略添加规则以允许扩展程序运行...但这具有潜在危险,非常特定于具体情况,并且基本上应该只永远在企业环境中完成,在企业环境中,每个人都有一个(编码很差的)浏览器扩展来使用您的网站。即使这样,重新编码扩展通常也是首选。

关于WordPress + Disqus + 拒绝执行内联脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29323506/

相关文章:

wordpress - 如何在FTP中找到wordpress站点的文件路径?

css - 在 wordpress 主题中找不到父元素

javascript - XSS 在现代浏览器中仍然存在

github-pages - github 页面上 Disqus 的 CSP 错误

css - 识别用户在网页上的位置

ember.js - Handlebars 模板中的内联 javascript

mysql - Woocommerce 数据库中的订单状态保存在哪里

php - wp_remote_get 和 url 参数

XSS - SQL 注入(inject) - Owasp、AntiXss 与 Microsoft 反跨站脚本库

php - "Chrome detected unusual code"之前工作的 iframe 错误