在gmail的垃圾邮件里找到一封标题为《网站有漏洞哦》的邮件,好奇地打开邮件,内容是:
详细的参考:
http://blog.119797.com/post/BlogEngine-fix-js-Download-bug.aspx
--
by benben
:)
由于涉及到链接,不敢用ie,用firefox打开一看,是一篇名为BlogEngine.NET js.axd 模块漏洞及修复的文章,往下一看,果然在js.axd文件有致命的bug,该bug可以让攻击者拿到用户名及密码,有了这些,等于完全操纵了你的blog程序,可怕!
Bug分析:
js.axd文件是一个实现了IHttpHandler接口的处理文件,它的作用是将指定的js文件进行压缩与缓存,该文件需要传递一个path参数,如:js.axd?path=xxx.js,js.axd就会将xxx.js文件中的空白去掉以减小js文件的体积。
部分方法:
[code:c#]
private static string RetrieveLocalScript(string file)
{
string path = HttpContext.Current.Server.MapPath(file);
string script = null;
using (StreamReader reader = new StreamReader(path))
{
script = reader.ReadToEnd();
HttpContext.Current.Cache.Insert(file, script, new CacheDependency(path));
}
return script;
}
[/code]
但这里出现的bug就是前面所提到的,没有对传入的file文件格式做判断
访问js.axd?path=/web.config时,居然将我的web.config文件内容原样读取出来
继续访问js.axd?path=app_data/users.xml,结果同上,将这个xml文件的内容一行不漏地读取了,而该文件中存储的正是帐户信息!!
修补方法:
在private static string RetrieveLocalScript(string file)方法及private static string RetrieveRemoteScript(string file)方法中添加以下代码:
//判断是不是请求.js文件,如果不是则抛出安全性异常。
if (!file.EndsWith(".js", StringComparison.OrdinalIgnoreCase))
{
throw new System.Security.SecurityException("No access");
}
再访问上述地址时:

问题基本得到修复,官方也就此bug发布了更新版本http://www.dotnetblogengine.net/post/Critical-Security-Patch-Available.aspx
使用dotnetblogengine的朋友一定要打此补丁,否则欲哭无泪了
在此,谢谢给我邮件的朋友,他的blog地址:
http://blog.119797.com/