在微软没有推出解决方案之前,基本上可以按照scottgu的文章中给出的临时解决方法进行设置,相信微软将有一个安全修补程序可以部署到解决这个正确,使网站恢复到以前的customErrors设置:
以下内容摘自Scottgu博客的文章:Important: ASP.NET Security Vulnerability。
如果您使用的是ASP.NET 1.0,ASP.NET 1.1,ASP.NET 2.0,ASP.NET 3.5,那么你应该按照以下步骤,启用<customErrors />和映射所有错误到一个单一的错误页:
- 编辑你的ASP.NET应用程序的根Web.config文件。如果文件不存在,则在应用程序的根目录之一创建一个。
- 创建或修改web.config的配置节 <customErrors />部分,添加以下内容:
[php]<customErrors mode="On" defaultRedirect="~/error.html" /> [/php] - 你再添加一个独立的 error.html文件到应用程序,其中包含你选择你喜欢的任何内容包含(适当的错误页)。在Web应用程序中发生错误时使用该文件将显示错误。
注意:要将上面的customErrors设置“on”,而且所有的错误页的默认跳转到默认错误处理的页面。不设置任何每个状态代码定义的错误页面--这意味着<customErrors /> 的所有子配置节都删除掉。这样就可以避免攻击者通过不同的状态码判断服务器上的处理结果,并防止信息泄露。
如果您使用的是ASP.NET 3.5 SP1或ASP.NET 4.0,那么你应该按照以下步骤,,启用<customErrors />和映射所有错误到一个单一的错误页:
- 编辑你的ASP.NET应用程序的根Web.config文件。如果文件不存在,则在应用程序的根目录之一创建一个。
- Create or modify the <customErrors /> section of the web.config file to have the below settings. Note the use of redirectMode=”ResponseRewrite” with .NET 3.5 SP1 and .NET 4.0: 2)创建或修改web.config文件的配置节<customErrors/>,添加以下内容 :
- 你再添加一个Error.aspx到应用程序,其中包含你选择你喜欢的任何内容包含(适当的错误页)。在Web应用程序中发生错误时使用该文件将显示错误。
[php]<%@ 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 runat="server">
<title>Error</title>
</head>
<body>
<div>
An error occurred while processing your request.
</div>
</body>
</html>[/php]
[php] <customErrors mode="On" defaultRedirect="~/error.aspx" redirectMode="ResponseRewrite" />
注意要将redirectMode设置为ResponseRewrite.[/php]
注意:建议您阅读Microsoft的顾问 http://www.microsoft.com/technet/security/advisory/2416728.mspx ,进一步的细节请阅读Scottgu的博客 http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx 和文章中给出的error.aspx页例子。
修改后,要记得重启IIS。