favicon.ico、robots.txt 和 sitemap.xml 等文件是否容易受到 XSS 攻击?

信息安全 xss 扎普
2021-09-06 11:54:04

针对应用程序的 Zap 扫描检测到站点地图和网站图标上的“未启用 Web 浏览器 XSS 保护”漏洞。忽略这些 URL 是否安全,或者这是否意味着该应用程序易受攻击?

这是 favicon 的完整输出:

{'long_description':
  "The X-XSS-Protection HTTP response header allows the web server to enable or disable the web browser's XSS protection mechanism.
  The following values would attempt to enable it: 
    X-XSS-Protection: 1; mode=block
    X-XSS-Protection: 1; report=http://www.example.com/xss
  The following values would disable it:
    X-XSS-Protection: 0
  The X-XSS-Protection HTTP response header is currently supported on Internet Explorer, Chrome and Safari (WebKit).
  Note that this alert is only raised if the response body could potentially contain an XSS payload
  (with a text-based content type, with a non-zero length)."
'method': 'GET'
'pluginId': '10016',
'cweid': '933',
'confidence': 'Medium',
'wascid': '14',
'description': "Web Browser XSS Protection is not enabled, or is disabled by the configuration of the 'X-XSS-Protection'
  HTTP response header on the web server"
'url': 'http://xxx.xxx.xxx.xxx/favicon.ico',
'reference': 'https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet\nhttps://www.veracode.com/blog/2014/03/guidelines-for-setting-security-headers/',
'solution': "Ensure that the web browser's XSS filter is enabled, by setting the X-XSS-Protection HTTP response header to '1'.",
'name': 'Web Browser XSS Protection Not Enabled', 'risk': 'Low', 'id': '0'}
2个回答

我们将很快弃用该被动扫描规则。

这是问题所在:https
://github.com/zaproxy/zaproxy/issues/5849 以下是相关的 PR:

你真的应该有 CSP,至于这些文件是否重要,这取决于它们是否存在,如果不存在,如何处理错误。

此外,正如MDN所指出的

这意味着如果您不需要支持旧版浏览器,建议您使用Content-Security-Policy不支持 unsafe-inline脚本来代替。

在这个 Q/A中也有关于这个主题的进一步讨论(X-XSS-Protection vs CSP)

更新:“标头 XSS 保护”被动扫描规则已从被动扫描规则 v27 > https://github.com/zaproxy/zap-extensions/releases/tag/pscanrules-v27 中删除

favicon.ico 和 robots.txt:不。浏览器不会在这些文件中执行 JavaScript。

理论上,sitemap.xml 可能是个问题。你可以用 xml 做很多讨厌的把戏。实际上,这将是一个非常非常困难的攻击(尤其是考虑到这是一个静态文件的可能情况)。