Skip to content

Commit 8d21cde

Browse files
committed
CVE-2018-8583 Edge - Chakra JIT OOB 9 13 leads to RCE
In the loop range check we emit add instruction to add 1 to the range. That can overflow. We did't have overflow bailout over there. Fixed that by adding bailout over there.
1 parent abb5d88 commit 8d21cde

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/Backend/GlobOptIntBounds.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,11 +1822,16 @@ void GlobOpt::GenerateLoopCountPlusOne(Loop *const loop, LoopCount *const loopCo
18221822
IR::RegOpnd *loopCountOpnd = IR::RegOpnd::New(type, func);
18231823
IR::RegOpnd *minusOneOpnd = IR::RegOpnd::New(loopCount->LoopCountMinusOneSym(), type, func);
18241824
minusOneOpnd->SetIsJITOptimizedReg(true);
1825-
insertBeforeInstr->InsertBefore(IR::Instr::New(Js::OpCode::Add_I4,
1826-
loopCountOpnd,
1827-
minusOneOpnd,
1828-
IR::IntConstOpnd::New(1, type, func, true),
1829-
func));
1825+
IR::Instr* incrInstr = IR::Instr::New(Js::OpCode::Add_I4,
1826+
loopCountOpnd,
1827+
minusOneOpnd,
1828+
IR::IntConstOpnd::New(1, type, func, true),
1829+
func);
1830+
1831+
insertBeforeInstr->InsertBefore(incrInstr);
1832+
1833+
// Incrementing to 1 can overflow - add a bounds check bailout here
1834+
incrInstr->ConvertToBailOutInstr(bailOutInfo, IR::BailOutOnFailedHoistedLoopCountBasedBoundCheck);
18301835
loopCount->SetLoopCountSym(loopCountOpnd->GetStackSym());
18311836
}
18321837
}

0 commit comments

Comments
 (0)