【发布时间】:2016-01-29 22:57:14
【问题描述】:
Google Chrome XSS Auditor 中存在一个已知的false positive,涉及带有一些 js-ish 文本的文本区域,例如 action="":
XSS 审核员拒绝执行“https://www.dokuwiki.org/sandbox:chrome_xss_auditor?do=edit”中的脚本,因为在请求中找到了它的源代码。审核员已启用,因为服务器既未发送“X-XSS-Protection”也未发送“Content-Security-Policy”标头。
错误消息表明它可以使用X-XSS-Protection-header 或Content-Security-Policy-header 解决。事实上a related question on SO 建议使用header("X-XSS-Protection: 0"); 停用XSS-Protection。
但是,我对简单地停用 XSS 保护并尝试使用 Content-Security-Policy-header 处理此问题感到有些不安:
header('Content-Security-Policy: script-src * \'unsafe-inline\' \'unsafe-eval\'');
但不幸的是,这并没有影响问题。
我的问题是:为什么会失败,如何使用Content-Security-Policy-header 来处理问题而不完全停用 XSS-Protection?
【问题讨论】:
-
你可以在发送数据之前做一些愚蠢的事情,比如 base64 对数据进行编码,也许?
标签: google-chrome http-headers xss content-security-policy