【Azure 应用服务】在安全漏洞扫描中发现有泄露服务器IIS版本的情况,如何实现屏蔽服务版本号信息呢?

简介: 【Azure 应用服务】在安全漏洞扫描中发现有泄露服务器IIS版本的情况,如何实现屏蔽服务版本号信息呢?

问题描述

当对Azure App Service应用进行安全扫描时,发现了HTTP/S请求的响应头中会包含服务端IIS的版本信息,这是一个低风险因素。

如:

Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 5.2
X-Powered-By: ASP.NET

如来修改App Service的Web.config来屏蔽这些信息呢?

问题解答

进入App Service的高级工具Kudu站点:

在已有的web.config中,添加如下两部分内容。

1:在web.config文件中的system.webServer 部分增加

<security>
  <requestFiltering removeServerHeader="true" />
</security>

2:如果想屏蔽  Server,X-AspNet-Version,X-AspNetMvc-Version 和 X-Powered-By,需要增加:

<httpProtocol>
  <customerHeaders>
    <remove name="Server" />
    <remove name="X-AspNet-Version" />
    <remove name="X-AspNetMvc-Version" />
    <remove name="X-Powered-By" />
  </customerHeaders>
</httpProtocol>

<system.web>
    <httpRuntime targetFramework="4.7.2"  enableVersionHeader="false" />
  </system.web>

 

修改后的web.config,应该类似:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  https://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
  </appSettings>
  <system.web>
    <compilation targetFramework="4.7.2"/>
    <httpRuntime targetFramework="4.7.2"  enableVersionHeader="false" />
  </system.web>
  
   <system.webServer>      
        <httpProtocol>
            <customHeaders>
                <remove name="Server" />
                <remove name="X-AspNet-Version" />
                <remove name="X-AspNetMvc-Version" />
                <remove name="X-Powered-By" />
            </customHeaders>
        </httpProtocol>
        <security>
            <requestFiltering removeServerHeader="true" />
        </security>
    </system.webServer>
</configuration>

经过以上的操作后,成功的删除了Server,X-AspNet-Version, X-Powered-By的消息,但是, X-AspNetMvc-Vserion 依然存在。

 

在博客园中查找到通过以下的方式来隐藏 X-AspNetMvc-Version信息。

标头名称:X-AspNet-Version

在web.config的httpRuntime部分中-设置:

<httpRuntime enableVersionHeader="false" />

标头名称:X-AspNetMvc-Version

从global.asax中的Application_Start事件-执行以下代码(C#):

MvcHandler.DisableMvcResponseHeader = true;

 

 

[END]

相关文章
|
20天前
|
缓存 NoSQL 网络安全
【Azure Redis 缓存】使用开源工具redis-copy时遇见6379端口无法连接到Redis服务器的问题
【Azure Redis 缓存】使用开源工具redis-copy时遇见6379端口无法连接到Redis服务器的问题
|
20天前
|
Linux 应用服务中间件 网络安全
【Azure 应用服务】查看App Service for Linux上部署PHP 7.4 和 8.0时,所使用的WEB服务器是什么?
【Azure 应用服务】查看App Service for Linux上部署PHP 7.4 和 8.0时,所使用的WEB服务器是什么?
|
22天前
|
微服务
【Azure Cloud Services】云服务频繁发生服务器崩溃的排查方案
【Azure Cloud Services】云服务频繁发生服务器崩溃的排查方案
|
23天前
|
XML 数据格式
【应用服务 App Service】如何移除App Service Response Header中包含的服务器敏感信息
【应用服务 App Service】如何移除App Service Response Header中包含的服务器敏感信息
|
23天前
|
域名解析 网络协议 数据中心
【应用服务 App Service】当遇见某些域名在Azure App Service中无法解析的错误,可以通过设置指定DNS解析服务器来解决
【应用服务 App Service】当遇见某些域名在Azure App Service中无法解析的错误,可以通过设置指定DNS解析服务器来解决
|
3月前
|
网络协议
windows_server2012搭建iis并配置http重定向 iis转发
windows_server2012搭建iis并配置http重定向 iis转发
154 1
|
21天前
|
开发框架 .NET 中间件
【Azure 云服务】在Cloud Service的代码中如何修改IIS Application Pool的配置呢? 比如IdleTimeout, startMode, Recycling.PeriodicRestart.Time等
【Azure 云服务】在Cloud Service的代码中如何修改IIS Application Pool的配置呢? 比如IdleTimeout, startMode, Recycling.PeriodicRestart.Time等
【Azure 云服务】在Cloud Service的代码中如何修改IIS Application Pool的配置呢? 比如IdleTimeout, startMode, Recycling.PeriodicRestart.Time等
|
23天前
|
C++
【Azure云服务 Cloud Service】如何在部署云服务Cloud Service时候通过启动任务Start Task来配置IIS (如开启ARR)
【Azure云服务 Cloud Service】如何在部署云服务Cloud Service时候通过启动任务Start Task来配置IIS (如开启ARR)
|
3月前
|
Windows
iis配置http重定向302转发get请求并去掉最后的斜杠/ iis重定向 iis去除url最后的斜杠 iis重定向链接斜杠(已解决)
iis配置http重定向302转发get请求并去掉最后的斜杠/ iis重定向 iis去除url最后的斜杠 iis重定向链接斜杠(已解决)
82 0
|
4月前
|
JavaScript Windows
VUE部署到IIS中报404错误解决方案-配置URL重写
VUE部署到IIS中报404错误解决方案-配置URL重写
199 0