CVE-2010-3962分析
相关代码参考win2k:win2k\private\inet\mshtml\src\site\download\
问题代码为:
代码:
<table style=position:absolute;clip:rect(0)>
分析步骤:
// TABLE
static CHtmlParseClass s_hpcTable =
{
SCOPE_NESTED, // _scope
TEXTTYPE_ALWAYS, // _texttype ; textlike; force BODY etc
s_atagTable, // _atagEndContainers
s_atagTableCellCaption, // _atagBeginContainers ; allow nesting inside TD, CAPTION, TABLE
NULL, // _atagMaskingContainers
s_atagTableCloses, // _atagProhibitedContainers ; close prevous TABLE, TC, SELECT, OPTION
NULL, // _atagRequiredContainers
ETAG_NULL, // _etagDefaultContainer
FALSE, // _fQueueForRequired
TEXTSCOPE_EXCLUDE, // _textscope ; exclude text
ETAG_TC, // _etagTextSubcontainer ; wrap contained text in a TC
NULL, // _atagMatch
ETAG_NULL, // _etagUnmatchedSubstitute
NULL, // _pfnHpxCreator
FALSE, // _fMerge
ETAG_NULL, // _etagImplicitChild
FALSE, // _fCloseImplicitChild
};
代码:
.text:7E2C5D9D ; .text:7E2C5D9D push eax .text:7E2C5D9E lea eax, [ebx+0Ch] .text:7E2C5DA1 push eax .text:7E2C5DA2 call CDispContainer::New(CDispClient *,ulong)
代码:
.text:7E2B5D2A CDispContainer::New .......................................................... .text:7E291CF0 movzx esi, ds:uchar const * const CDispNode::_extraSizeTable[ebx] .text:7E291CF7 shl esi, 2 .text:7E291CFA push edi .text:7E291CFB add eax, esi .text:7E291CFD push eax ; dwBytes .text:7E291CFE call _MemAllocClear(x) .text:7E291D03 mov edi, eax .text:7E291D05 test edi, edi .text:7E291D07 jz short loc_7E291D17 .text:7E291D09 add edi, esi .text:7E291D0B test bl, 40h .text:7E291D0E mov [edi+4], ebx <-------这里保存CliprectInfo_size的大小
代码:
.text:7E36B4C4 CDispNode::SetUserClip ............................... .text:7E36B54D mov eax, [edi+4] <-------当这里为0时,虚函数表就被悲剧了. .text:7E36B550 and eax, esi .text:7E36B552 movzx ecx, ds:uchar const * const CDispNode::_extraSizeTable[eax] .text:7E36B559 mov eax, edi .text:7E36B55B shl ecx, 2 .text:7E36B55E sub eax, ecx .text:7E36B560 or dword ptr [eax], 1 <-----------------------虚函数表被改了
<table style=position:absolute;clip:rect(0)><td>后将导致CTableCaption对象不会生成,因为td的CHtmlParseClass 根本没有_etagTextSubcontainer,这样不会导致代码出问题,到底是s_hpcTable出了问题还是SetUserClip检查不严格?还是两者都有问题?
函数调用序列:
代码:
CHtmParse::ParseEof
代码:
CHtmParse::ParseText | CHtmlParseClass *phpc; phpc = HpcFromEtag(etag); if (phpc->_atagProhibitedContainers) { hr=THR(CloseAllContainers(phpc->_atagProhibitedContainers, phpc->_atagBeginContainers)); if (hr) goto Cleanup; } hr = THR(OpenContainer(etag));
代码:
CHtmParse::OpenContainer | 此时etagItem=0x62表示ETAG_TC,这时将创建一个CTableCaption对象 hr = THR(CreateElement(etagItem, &pel, _pDoc, _pMarkup, TRUE, &_fDie)); CreateElement函数根据etagItem=0x62去索引hash表g_atagdesc,查表得具体的对象的CreateElement函数接着CTableCaption::CreateElement函数将被调用
代码:
CHtmPos::Exec CHtmPos::Notify CTableCell:Notify(CTableCaption继承该类)
代码:
CTableCell::EnterTree | hr = pTableLayout->AddCaption(pCaption);导致 pTableLayout对象中存在标题
代码:
CTableLayoutBlock::EnsureTableDispNode(CTableLayoutBlock即上面的pTableLayout)
代码:
CDispNode::SetUserClip | movzx ecx, ds:uchar const * const CDispNode::_extraSizeTable[eax] mov eax, edi shl ecx, 2 sub eax, ecx or dword ptr [eax], 1
当对CliprectInfo操作时虚函数表在这里活生生成被修改了一位,后续对对象的调用都会导致访问异常。