明天的明天 永远的永远 未知的一切 我与你一起承担 ??

是非成败转头空 青山依旧在 几度夕阳红 。。。
  博客园  :: 首页  :: 管理

服务器--Tomcat启动了不安全的HTTP方法解决办法

Posted on 2021-01-20 10:19  且行且思  阅读(408)  评论(0编辑  收藏  举报

一、问题描述

平时我们项目中基本上用的都是GET/POST请求方法,其他的方法是很少用到的,如PUT/DELETE/HEAD/OPTIONS/TRACE,不关闭这些HTTP请求方法,是常见的web漏洞之一。

二、解决办法

把他们关闭即可!!!

添加以下节点代码到web.xml配置文件当中。可以在项目WEB-INF/web.xml中添加,也可以在tomcat/conf/web.xml中添加

  1. <!-- close insecure http methods -->
  2. <security-constraint>
  3. <web-resource-collection>
  4. <web-resource-name>fortune</web-resource-name>
  5. <url-pattern>/*</url-pattern>
  6. <http-method>PUT</http-method>
  7. <http-method>DELETE</http-method>
  8. <http-method>HEAD</http-method>
  9. <http-method>OPTIONS</http-method>
  10. <http-method>TRACE</http-method>
  11. </web-resource-collection>
  12. <auth-constraint></auth-constraint>
  13. </security-constraint>