Skip to content

Commit

Permalink
[CVE-2018-0874] - Chakra Array Includes Uninitialized Memory RCE - In…
Browse files Browse the repository at this point in the history
…dividual

Callbacks while sorting causes the head of an array to not have any missing value, although later we cause an exception in the sorting. Which left the array
in the inconsistent state. Later in the HeadSegmentIndexOfHelper we exploit that situation.
Fixed that by reseting the no-missing value state in the no-exception case. And also put fail-fast where we don't expect it happen.
  • Loading branch information
akroshg committed Mar 12, 2018
1 parent 024353a commit 7087c31
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Runtime/Library/JavascriptArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4137,6 +4137,10 @@ namespace Js
return i;
}
}
else if (SparseArraySegment<Var>::IsMissingItem(&element))
{
AssertOrFailFast(false);
}
else if (includesAlgorithm && JavascriptConversion::SameValueZero(element, search))
{
//Array.prototype.includes
Expand Down Expand Up @@ -6667,6 +6671,8 @@ namespace Js
ClearSegmentMap(); // Dump the segmentMap again in case user compare function rebuilds it
if (hasException)
{
// The current array might have affected due to callbacks. As we have got the exception we should be resetting the missing value.
SetHasNoMissingValues(false);
head = startSeg;
this->InvalidateLastUsedSegment();
}
Expand Down

0 comments on commit 7087c31

Please sign in to comment.