Skip to content

Commit

Permalink
[CVE-2019-1139] Chakra JIT Type Confusion
Browse files Browse the repository at this point in the history
array.slice converts the native array to var array which was not captured during the optimization.
Due to that the native array type is forced to var array which leads to the type confusion.
Fixed this by killing the object type for the slice (as well as concat)
  • Loading branch information
akroshg authored and wyrichte committed Aug 13, 2019
1 parent dce7443 commit ae8a8d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Backend/GlobOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13470,6 +13470,7 @@ GlobOpt::CheckJsArrayKills(IR::Instr *const instr)
case IR::HelperArray_Splice:
case IR::HelperArray_Unshift:
case IR::HelperArray_Concat:
case IR::HelperArray_Slice:
kills.SetKillsArrayHeadSegments();
kills.SetKillsArrayHeadSegmentLengths();
break;
Expand Down
12 changes: 12 additions & 0 deletions lib/Backend/GlobOptFields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,18 @@ GlobOpt::ProcessFieldKills(IR::Instr *instr, BVSparse<JitArenaAllocator> *bv, bo
}
break;

case IR::JnHelperMethod::HelperArray_Slice:
case IR::JnHelperMethod::HelperArray_Concat:
if (inGlobOpt && this->objectTypeSyms)
{
if (this->currentBlock->globOptData.maybeWrittenTypeSyms == nullptr)
{
this->currentBlock->globOptData.maybeWrittenTypeSyms = JitAnew(this->alloc, BVSparse<JitArenaAllocator>, this->alloc);
}
this->currentBlock->globOptData.maybeWrittenTypeSyms->Or(this->objectTypeSyms);
}
break;

case IR::JnHelperMethod::HelperRegExp_Exec:
case IR::JnHelperMethod::HelperRegExp_ExecResultNotUsed:
case IR::JnHelperMethod::HelperRegExp_ExecResultUsed:
Expand Down

0 comments on commit ae8a8d9

Please sign in to comment.