ASP.NET 安全漏洞臨時解決方案

作者: TerryLee  發布時間: 2010-09-20 17:40  閱讀: 1798 次  推薦: 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
 
 

文章列表

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()