最近公司扫描负责的网站出来一堆安全漏洞。吓死宝宝了。
贴出来刚刚改的几个。
1,使用了不安全的http请求。
解决方案: 禁止DELETE、PUT、OPTIONS、TRACE、HEAD等协议访问应用程序应用程序。
解决步骤:
第一步:修改应用程序的web.xml文件的协议
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
第二步:在应用程序的web.xml中添加如下的代码即可
<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>HEAD</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
</web-resource-collection>
<auth-constraint>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
2,会话cookie缺少了httpOnly属性。
解决方案:在web.xml加过滤器
<filter>
<filter-name>cookieHttpOnlyFilter</filter-name>
<filter-class>com.gtc.cms.filter.CookieHttpOnlyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cookieHttpOnlyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3,中间件版本信息泄露。
解决方案:
定制统一的错误页面,当程序异常时显示统一的错误提示页面;
删除/修改/隐藏HTTP Header中的中间件程序版本信息,避免信息泄漏。
配置xml errorpage
<error-page>
<error-code>500</error-code>
<location>/500.html</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>