我在我的 apache/conf/httpd.conf 文件中添加了以下行来解析 XSS 跨站点脚本漏洞。
1(
<IfModule mod_headers.c>
# (1) (2)
Header set X-XSS-Protection "1; mode=block"
# `mod_headers` cannot match based on the content-type, however,
# the `X-XSS-Protection` response header should be sent only for
# HTML documents and not for the other resources.
<FilesMatch ".(%FilesMatchPattern%)$">
Header unset X-XSS-Protection
</FilesMatch>
</IfModule>
2 ) header always set x-xss-protection "1; mode=block"
3) <IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
</IfModule>
使用以下命令重新启动 Apache 服务器
httpd -k restart
但是他们都没有工作,仍然IBM BAVA安全扫描显示(跨站点脚本(是积极的,Web服务器漏洞仍然存在。
添加 X-XSS 保护标头是一项功能,可通知您使用客户端浏览器。此外,除非您的浏览器支持它,否则它根本不起作用。这无助于解决服务器端的 XSS 漏洞。
请参考这里。