大网数据广告活动
服务器运维问答

Apache/Tomcat web server: nmap always returns that all http-methods are allowed

· 52CE 我爱测

I'm running a web server with Apache http server in front of an Apache Tomcat server. My goal: Disable http-methods DELETE and PUT on the web server. According to OWASP ( https://www.owasp.org/index.php/Test_HTTP_Methods_(OTG-CON…

问题原文

原帖链接 · chloesoe · CC BY-SA 3.0

I'm running a web server with Apache http server in front of an Apache Tomcat server.

My goal: Disable http-methods DELETE and PUT on the web server.

According to OWASP (https://www.owasp.org/index.php/Test_HTTP_Methods_(OTG-CONFIG-006)) this should be tested with this command:

nmap -p 80 --script http-methods www.example.com

On my server I get this response:

PORT   STATE SERVICE
80/tcp open  http
| http-methods:
|   Supported Methods: GET HEAD POST PUT DELETE OPTIONS
|_  Potentially risky methods: PUT DELETE

According to http://www.techstacks.com/howto/disable-http-methods-in-tomcat.html I can disable PUT and DELETE with this lines in web.xml

<security-constraint>
     <web-resource-collection>
          <web-resource-name>restricted methods</web-resource-name>
          <url-pattern>/*</url-pattern>
          <http-method>PUT</http-method>
          <http-method>DELETE</http-method>
     </web-resource-collection>
     <auth-constraint />
</security-constraint>

If I add this, my response still is Supported Methods: GET HEAD POST PUT DELETE OPTIONS.
If I additionally disable the http-method OPTIONS with adding <http-method>OPTIONS</http-method> to the web.xml, then I get this good looking response:

80/tcp open  http
| http-methods:
|_  Supported Methods: GET HEAD POST OPTIONS

The same happens, if I try to disable that http-methods in the Apache web server which actually is in front of the tomcat. see: http://www.techstacks.com/howto/disable-http-methods-in-apache.html

What I want:

  • Disable PUT and DELETE
  • Don't disable OPTIONS
  • nmap -p 80 --script http-methods www.example.com should response, that DELETE and PUT are disabled

已采纳解答

原帖链接 · bonsaiviking · CC BY-SA 3.0

The script is sending an OPTIONS request and reporting the results. This reports what methods the server software supports. Your security configuration is not changing what methods Tomcat understands; it is adding a security constraint that those methods are only allowed for users who meet the auth-constraint condition, which in this case contains no users. So Tomcat is being truthful: it does understand PUT and DELETE, even if nobody is allowed to use them.

If you want further confirmation, you can add --script-args http-methods.retest to your command. This will instruct the script to send a request with each of the discovered methods and report the status code of the response. But be careful: this will result in sending requests like DELETE /, which can be harmful.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-11-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。