|
在上周五一個安全會議上披露了微軟ASP.NET的一個安全漏洞,利用該漏洞攻擊者可以請求并下載一些ASP.NET Web.config文件,攻擊者可以發(fā)送密文并根據(jù)默認錯誤頁信息來得到Machine Key。微軟目前并沒有新的補丁下載,但ScottGu在自己的博客中給出了一個臨時解決方案,這里簡單翻譯一下,大家可做參考。
在ASP.NET 1.1 到 ASP.NET 3.5中,可以通過在Web.config中創(chuàng)建<customErrors>節(jié)點來解決,注意,ErrorMode必須設(shè)置為On,且對于所有的錯誤都轉(zhuǎn)向同一個錯誤頁,主要是防止攻擊者根據(jù)不同的錯誤也跳轉(zhuǎn)來猜測服務(wù)器發(fā)生了什么錯誤:
<configuration>
<system.web>
<customErrors mode="On" defaultRedirect="~/error.html" />
</system.web>
</configuration>
在ASP.NET 3.5 SP1到ASP.NET 4.0中,在Web.config中創(chuàng)建<customErrors>節(jié)點,設(shè)置ErrorMode為On,設(shè)置RedirectMode模式為ResponseRewrite,對于所有的錯誤跳轉(zhuǎn)到同一個錯誤頁:
<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腳本,可以用來測試服務(wù)器上ASP.NET 應(yīng)用程序的<customErrors>節(jié)點配置,大家可以到這里下載。
參考信息:
1. Important: ASP.NET Security Vulnerability
2. Microsoft Security Advisory 2416728
3. Understanding the ASP.NET Vulnerability
4. Microsoft Security Response Center Blog Post
NET技術(shù):ASP.NET 安全漏洞臨時解決方案,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。