详细描述 | 为了方便的获得网站域名,开发人员一般依赖于HTTP Host header。例如,在php里用_SERVER["HTTP_HOST"]。但是这个header是不可信赖的,如果应用程序没有对host header值进行处理,就有可能造成恶意代码的传入。 |
解决办法 |
web应用程序应该使用SERVER_NAME而不是host header。 在Apache和Nginx里可以通过设置一个虚拟机来记录所有的非法host header。在Nginx里还可以通过指定一个SERVER_NAME名单,Apache也可以通过指定一个SERVER_NAME名单并开启UseCanonicalName选项。 |
为了解决这个安全漏洞扫描报告结果,宜兴博路网络见意在网站根目录下新建一个web.config的配置文件,然后把下面的代码保存即可,如果已经有web.config文件,需要增加以下没重复出现的红颜色代码段以及改与自己相应的网址,IIS7.0以上的代码为:
<configuration>
<system.webServer>
<rewrite>
<rules>
<!--301重定向把不带3W的域名 定向到带3W-->
<rule name="301Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^boroad.net$" />
</conditions>
<action type="Redirect" url="http://www.boroad.net/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false" />
<defaultDocument enabled="true">
<files>
<clear />
<add value="index.html" />
<add value="index.php" />
</files>
</defaultDocument>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
<add name="X-Content-Type-Options" value="nosniff" />
<add name="X-Frame-Options" value="DENY" />
<add name="X-XSS-Protection" value="1; mode=block" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>