Skip to content

Commit

Permalink
CVE-2018-8583 Edge - Chakra JIT OOB 9 13 leads to RCE
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akroshg committed Dec 10, 2018
1 parent abb5d88 commit 8d21cde
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/Backend/GlobOptIntBounds.cpp
Expand Up @@ -1822,11 +1822,16 @@ void GlobOpt::GenerateLoopCountPlusOne(Loop *const loop, LoopCount *const loopCo
IR::RegOpnd *loopCountOpnd = IR::RegOpnd::New(type, func);
IR::RegOpnd *minusOneOpnd = IR::RegOpnd::New(loopCount->LoopCountMinusOneSym(), type, func);
minusOneOpnd->SetIsJITOptimizedReg(true);
insertBeforeInstr->InsertBefore(IR::Instr::New(Js::OpCode::Add_I4,
loopCountOpnd,
minusOneOpnd,
IR::IntConstOpnd::New(1, type, func, true),
func));
IR::Instr* incrInstr = IR::Instr::New(Js::OpCode::Add_I4,
loopCountOpnd,
minusOneOpnd,
IR::IntConstOpnd::New(1, type, func, true),
func);

insertBeforeInstr->InsertBefore(incrInstr);

// Incrementing to 1 can overflow - add a bounds check bailout here
incrInstr->ConvertToBailOutInstr(bailOutInfo, IR::BailOutOnFailedHoistedLoopCountBasedBoundCheck);
loopCount->SetLoopCountSym(loopCountOpnd->GetStackSym());
}
}
Expand Down

0 comments on commit 8d21cde

Please sign in to comment.