漏洞
漏洞名称:84502 (15) - HSTS Missing From HTTPS Server
漏洞名称:84502(4)-HTTPS服务器中缺少HSTS
漏洞描述:The remote HTTPS server is not enforcing HTTP Strict Transport Security (HSTS). HSTS is an optional response header that can be configured on the server to instruct the browser to only communicate via HTTPS. The lack of HSTS allows downgrade attacks, SSL-stripping man-in-the-middle attacks, and weakens cookie-hijacking protections.
安全报告的这个漏洞都是tomcat的https端口报出来的
1、tomcat过滤器配置说明
需要对应版本的tomcat7、8配置过滤器,配置路径:/tomcat/conf/web.xml
配置说明:
如官网tomcat8的配置文档:https://tomcat.apache.org/tomcat-8.5-doc/config/filter.html
2、具体配置示例如下
打开两处注释
打开注释 并添加几项配置
<filter>
<filter-name>httpHeaderSecurity</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
<init-param>
<param-name>hstsMaxAgeSeconds</param-name>
<param-value>31536000</param-value>
</init-param>
<init-param>
<param-name>antiClickJackingOption</param-name>
<param-value>SAMEORIGIN</param-value>
</init-param>
<async-supported>true</async-supported>
</filter>
打开注释
<filter-mapping>
<filter-name>httpHeaderSecurity</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
配置好后重启
3、配置后无效的问题
配置重启后这个漏洞还是存在,这个需要访问根路径看下是否有消息头:Strict-Transport-Security: max-age=31536000
一般访问根路径https://ip:8030/会打开tomcat默认页面的。
但是之前安全要求是删掉了webapps下面的除自己的war包以外的其他目录,如ROOT目录这些,所以访问会报404。
我配置了Tomcat 错误页面重定向,会重定向到ROOT下面的页面,那么我就新建目录ROOT,自定义一个error.jsp放在ROOT目录下面!
Tomcat 错误页面重定向配置web.xml最后</web-app>前面加上
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>400</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>/error.jsp</location>
</error-page>
配置好后重启再次验证成功