IIS:如何禁用HTTP方法跟踪? [英] IIS: How to disable HTTP method TRACE?

查看:0
本文介绍了IIS:如何禁用HTTP方法跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了this,这导致this尝试禁用我的网站接受跟踪方法(动词)。基本上,我在Web.config(默认网站和其他网站)内部<system.webServer>添加了以下部分:

<security>
   <requestFiltering>
       <verbs applyToWebDAV="false">
          <add verb="TRACE" allowed="false" />
       </verbs>
   </requestFiltering>
</security>

它没有起作用。然后我转到C:WindowsSystem32inetsrvconfigapplicationHost.config并替换了<handlers>中的所有处理程序动词。简而言之,所有行都是这样的:

<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />

变成这样:

<add name="StaticFile" path="*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />

我甚至重新启动了服务器,但当我检查可用方法时,跟踪仍然存在:

$ curl -I -X OPTIONS https://example.com/mysite
HTTP/1.1 200 OK
Allow: OPTIONS, TRACE, GET, HEAD, POST
Public: OPTIONS, TRACE, GET, HEAD, POST
X-XSS-Protection: 1; mode=block
Date: Thu, 07 Feb 2019 21:03:49 GMT
Content-Length: 0

那么,我如何摆脱它?

推荐答案

若要真正阻止TRACE请求,您仍应保留已阻止TRACE谓词的请求筛选规则。

curl命令向IIS发送OPTIONS请求,ProtocolSupportModule生成响应消息

https://docs.microsoft.com/en-us/iis/get-started/introduction-to-iis/iis-modules-overview

但是,Microsoft没有在system.webServer/httpProtocol部分中为您设计任何设置来更改标题的值,以便在那里隐藏TRACE

但解决办法是使用URL重写模块

https://blogs.msdn.microsoft.com/benjaminperkins/2012/11/02/change-or-modify-a-response-header-value-using-url-rewrite/

在为AllowPublic标题创建两个出站规则的情况下,

<rewrite>
    <outboundRules>
        <rule name="ChangeHeaders" stopProcessing="false">
            <match serverVariable="RESPONSE_Allow" pattern="OPTIONS, TRACE, GET, HEAD, POST" />
            <action type="Rewrite" value="OPTIONS, GET, HEAD, POST" />
        </rule>
        <rule name="Public">
            <match serverVariable="RESPONSE_Public" pattern="OPTIONS, TRACE, GET, HEAD, POST" />
            <action type="Rewrite" value="OPTIONS, GET, HEAD, POST" />
        </rule>
    </outboundRules>
</rewrite>

这篇关于IIS:如何禁用HTTP方法跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆