您的位置:知识库 » .NET技术

ASP.NET 安全漏洞临时解决方案

作者: TerryLee  发布时间: 2010-09-20 17:40  阅读: 2003 次  推荐: 0   原文链接   [收藏]  

  在上周五一个安全会议上披露了微软ASP.NET的一个安全漏洞,利用该漏洞攻击者可以请求并下载一些ASP.NET Web.config文件,攻击者可以发送密文并根据默认错误页信息来得到Machine Key。微软目前并没有新的补丁下载,但ScottGu在自己的博客中给出了一个临时解决方案,这里简单翻译一下,大家可做参考。

  在ASP.NET 1.1 到 ASP.NET 3.5中,可以通过在Web.config中创建<customErrors>节点来解决,注意,ErrorMode必须设置为On,且对于所有的错误都转向同一个错误页,主要是防止攻击者根据不同的错误也跳转来猜测服务器发生了什么错误:

<configuration>
<
system.web>
<
customErrors mode="On" defaultRedirect="~/error.html" />
</
system.web>
</
configuration>

  在ASP.NET 3.5 SP1到ASP.NET 4.0中,在Web.config中创建<customErrors>节点,设置ErrorMode为On,设置RedirectMode模式为ResponseRewrite,对于所有的错误跳转到同一个错误页:

<configuration>
<
system.web>
<
customErrors mode="On" redirectMode="ResponseRewrite"
defaultRedirect="~/error.aspx" />
</
system.web>
</
configuration>

  并且ScottGu还建议在错误页的Page_Load()事件中加上如下代码:

<%@ Page Language="C#" AutoEventWireup="true" %>
<%
@ Import Namespace="System.Security.Cryptography" %>
<%
@ Import Namespace="System.Threading" %><script runat="server">
void
Page_Load(){
byte[] delay = new byte[1];
RandomNumberGenerator prng = new RNGCryptoServiceProvider();

prng.GetBytes(delay);
Thread.Sleep((int)delay[0]);

IDisposable disposable = prng as IDisposable;
if (disposable != null){ disposable.Dispose(); }
}
</script>

<html>
<
head id="Head1" runat="server">
<
title>Error</title>
</
head>
<
body>
<
div>
An error occurred while processing your request.
</div>
</
body>
</
html>

  另外ScottGu也提供了一个vbs脚本,可以用来测试服务器上ASP.NET 应用程序的<customErrors>节点配置,大家可以到这里下载。

  参考信息:

  1. Important: ASP.NET Security Vulnerability
  2. Microsoft Security Advisory 2416728
  3. Understanding the ASP.NET Vulnerability

  4. Microsoft Security Response Center Blog Post

0
0
 
标签:ASP.NET

.NET技术热门文章

    .NET技术最新文章

      最新新闻

        热门新闻