Skip to content

Commit ae8a8d9

Browse files
akroshgwyrichte
authored andcommitted
[CVE-2019-1139] Chakra JIT Type Confusion
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)
1 parent dce7443 commit ae8a8d9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/Backend/GlobOpt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13470,6 +13470,7 @@ GlobOpt::CheckJsArrayKills(IR::Instr *const instr)
1347013470
case IR::HelperArray_Splice:
1347113471
case IR::HelperArray_Unshift:
1347213472
case IR::HelperArray_Concat:
13473+
case IR::HelperArray_Slice:
1347313474
kills.SetKillsArrayHeadSegments();
1347413475
kills.SetKillsArrayHeadSegmentLengths();
1347513476
break;

lib/Backend/GlobOptFields.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,18 @@ GlobOpt::ProcessFieldKills(IR::Instr *instr, BVSparse<JitArenaAllocator> *bv, bo
518518
}
519519
break;
520520

521+
case IR::JnHelperMethod::HelperArray_Slice:
522+
case IR::JnHelperMethod::HelperArray_Concat:
523+
if (inGlobOpt && this->objectTypeSyms)
524+
{
525+
if (this->currentBlock->globOptData.maybeWrittenTypeSyms == nullptr)
526+
{
527+
this->currentBlock->globOptData.maybeWrittenTypeSyms = JitAnew(this->alloc, BVSparse<JitArenaAllocator>, this->alloc);
528+
}
529+
this->currentBlock->globOptData.maybeWrittenTypeSyms->Or(this->objectTypeSyms);
530+
}
531+
break;
532+
521533
case IR::JnHelperMethod::HelperRegExp_Exec:
522534
case IR::JnHelperMethod::HelperRegExp_ExecResultNotUsed:
523535
case IR::JnHelperMethod::HelperRegExp_ExecResultUsed:

0 commit comments

Comments
 (0)