Tomcat配置文件调整处理“启用了不安全的 HTTP”漏洞
漏洞:
启用了不安全的 HTTP方法
----自测,中危
任务:
禁用 WebDAV,或者禁止不需要的 HTTP 方法。
禁止DELETE、PUT、OPTIONS、TRACE、HEAD等协议访问应用程序应用程序。
解决方案:
修改tomcat/conf/web.xml文件
第一步:备份web.xml文件
第二步:将web.xml文件的协议更换为
<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">
位置:是非注释行的第二行
(在<?xml version="1.0" encoding="UTF-8"?> 下面)
第三步:调整一下内容
在web.xml文件中搜索“security-constraint”/“login-config”
如果搜索不到
搜索“security”,该单词应该在注释内
在该注释之下添加
<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>
如果搜索到“security-constraint”/“login-config”
将该处内容替换为以下内容
<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>
第三步:测试
对tomcat进行,启动测试,查看是否报错