tomcat禁用PUT,DELETE等一些不必要的HTTP方法
前言
在專案進行滲透測試的時候,我們收到了第三方測試報告,要求我們禁用DELETE、PUT、TRACE、MOVE、COPY、OPTIONS等HTTP請求方法,降低可攻擊性。
解決辦法在tomcat的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">
<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>