我有以下网址来调用我的应用程序: http://machine.domain.com:8383/eqube70/BuildNPlay 这很好用,它按照我的期望来调用index.jsp。
但是如果我的请求网址被更改为: http://machine.domain.com:8383/eqube70/BuildNPlay/?--%3E%3C/script%3E%3Cscript%3Ealert('你被黑了')%3C / script%3E 然后我得到警报,我无法让我的应用程序工作。这可能是请求url中的脚本被执行。
为了禁止脚本从url执行,我添加了servlet过滤器并在我的过滤器中添加了以下代码
private String mode = "1;mode=SAMEORIGIN";
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse)response;
res.addHeader("X-XSS-Protection", mode );
chain.doFilter(request, response);
}
这适用于IE和Chrome,但不支持Firefox。 如果我为firefox安装noscript插件,那么它可以工作。 但我不想要那个解决方案。 我有什么方法可以吗?
提前谢谢。
答案 0 :(得分:0)
不幸的是,(或者幸运的是,取决于您的观点)Firefox本身并不支持X-XSS-Protection保护标头,因此并不是说标题没有正确添加,只是Firefox不是用它做任何事情。
因此,您需要继续使用NoScript才能在Firefox上获得客户端XSS保护。