檢查ASP.NET安全漏洞及對策
2024-07-10 13:04:23
供稿:網友
 
在nt-bugtraq的郵件列表上首先報告的security bug in .net forms authentication適用于asp.net 1.0 (rtm, sp1, sp2, sp3)和asp.net 1.1 (rtm, sp1).
當form authentication被使用時,匿名用戶在試圖訪問被保護的頁面如http://localhost/webapplication2/secret.aspx時會被redirect到登錄網頁如http://localhost/webapplication2/login.aspx?returnurl=%2fwebapplication2%2fsecret.aspx.
但是如果使用mozilla,匿名用戶可以這樣未經認證就訪問被保護的頁面:http://localhost/webapplication2/secret.aspx;對ie,可以使用%5c達到類似的效果:http://localhost/webapplication2%5csecret.aspx
微軟在10月5日發布了what you should know about a reported vulnerability in microsoft asp.net網頁以提供針對此安全漏洞的對策。當前的對策主要是如kb887459所描述的那樣在global.asax或其code-behind中在application_beginrequest中增加檢查
    if (request.path.indexof('//') >= 0 ||        system.io.path.getfullpath(request.physicalpath) != request.physicalpath)     {        throw new httpexception(404, "not found");    }
顯然每個application都需要有這樣的檢查以應對此安全漏洞。微軟還會提供其他的對策,請關注what you should know about a reported vulnerability in microsoft asp.net網頁更新。
對asp.net 2.0 beta1,并沒有此漏洞而是得到404錯誤。
貼子以"現狀"提供且沒有任何擔保也沒有授予任何權利
發表于 thursday, october 07, 2004 1:53 am 
評論
# re: asp.net form authentication安全漏洞及對策 10/7/2004 8:49 am tommywoo 
http://localhost/webapplication2%5csecret.aspx 
試過了,不行。ie 版本問題? 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 9:40 am r2 
啊,好可怕!幸好我用beta1 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 9:43 am r2 
難道微軟的這種form認證這么脆弱?? 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 10:09 am wonge 
windows 2003下不會出現這種錯誤:http://localhost/webapplication2%5csecret.aspx ? 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 10:12 am 孫展波 
我是使用xpsp2的os及其帶的ie6驗證的。 
從what you should know about a reported vulnerability in microsoft asp.net網頁,windows 2003 server也有這個問題。這是asp.net的bug而不是os的bug. 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 10:44 am lostinet 
可怕的漏洞啊~~~ 
解決方法可以做個簡單的ihttpmodule,把它注冊到gac和machine.config中. 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 1:21 pm flashtoy 
我按方法試了.怎么沒有這個問題. 
嚇的我半死! 
http://www.creva.org.cn/creva/orgshow.aspx 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 6:19 pm tommywoo 
樓上的朋友,,我想到了。。 
因為我們用的是ie,ie要用這個漏洞,得使用%5c來代替/符號。。。 
我們兩個都是在根目錄的第一級子目錄加驗證的,比如你的,得用http://www.creva.org.cn%5ccreva/orgshow.aspx 
顯然這里有一個問題,域名是什么?這里域名被表示成了“www.creva.org.cn%5ccreva”,而不是實際域名“www.creva.org.cn”。 
我想問題應該在這里,展波用的是,虛擬目錄下的子目錄,所以出現了那個漏洞。 
你可以用mozilla的/符號試試。 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 6:25 pm 藍色空間 
確實有問題,趕快修正 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 6:38 pm libber 
為什么我測試不出來呢? .net framework 1.1 sp1 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 8:28 pm kwklover 
我也測試過了,沒有這個問題啊 
大家可以測試一下這個網站 
# re: asp.net form authentication安全漏洞及對策 10/7/2004 8:33 pm erictang2003 
我也沒測試出來,用ie6 和 firefox1.0 都沒試出來. 
不過還是改了代碼以防萬一 
# re: asp.net form authentication安全漏洞及對策 10/8/2004 12:10 am xiaoheng 
測試了,沒發現問題?。。?! 
# re: asp.net form authentication安全漏洞及對策 10/8/2004 9:09 am gigabyte 
可以在global.asax里面加上這么一段解決: 
void application_beginrequest(object source, eventargs e) { 
if (request.path.indexof('//') >= 0 || 
system.io.path.getfullpath(request.physicalpath) != request.physicalpath) { 
throw new httpexception(404, "not found"); 
} 
} 
這里有ms的解釋: 
http://www.kbalertz.com/kb_887459.aspx 
# re: asp.net form authentication安全漏洞及對策 10/8/2004 1:14 pm michael lee 
god ! 噩耗?。?! 
這種毛病都能出。還有前一陣的那個gdi+的bug,更是讓人匪夷所思。