Skip to content

Commit cb9957e

Browse files
jackhortonAtul Katti
authored andcommitted
[CVE-2018-8298] Edge - Chakra: Bugs in InitializeNumberFormat and InitializeDateTimeFormat - Google, Inc.
1 parent 8bd6826 commit cb9957e

11 files changed

+12410
-12406
lines changed

lib/Runtime/ByteCode/ByteCodeCacheReleaseFileVersion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
//-------------------------------------------------------------------------------------------------------
55
// NOTE: If there is a merge conflict the correct fix is to make a new GUID.
66

7-
// {2E95A003-1442-404F-98D5-D5C973B8A719}
7+
// {18949169-1B93-4123-B34A-F42F1C1EAF9A}
88
const GUID byteCodeCacheReleaseFileVersion =
9-
{ 0x2E95A003, 0x1442, 0x404F, { 0x98, 0xD5, 0xD5, 0xC9, 0x73, 0xB8, 0xA7, 0x19 } };
9+
{ 0x18949169, 0x1B93, 0x4123, { 0xB3, 0x4A, 0xF4, 0x2F, 0x1C, 0x1E, 0xAF, 0x9A } };

lib/Runtime/InternalPropertyList.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ INTERNALPROPERTY(FrozenType) // Used to store shared frozen
1919
INTERNALPROPERTY(StackTrace) // Stack trace object for Error.stack generation
2020
INTERNALPROPERTY(StackTraceCache) // Cache of Error.stack string
2121
INTERNALPROPERTY(WeakMapKeyMap) // WeakMap data stored on WeakMap key objects
22-
INTERNALPROPERTY(HiddenObject) // Used to store hidden data for JS library code (Intl as an example will use this)
22+
INTERNALPROPERTY(HiddenObject) // Used to store internal slot data for JS library code (Intl as an example will use this)
23+
INTERNALPROPERTY(CachedUCollator) // Used to store cached UCollator objects for Intl.Collator
24+
INTERNALPROPERTY(CachedUNumberFormat) // Used to store cached UNumberFormat objects for Intl.NumberFormat and Intl.PluralRules
25+
INTERNALPROPERTY(CachedUDateFormat) // Used to store cached UDateFormat objects for Intl.DateTimeFormat
26+
INTERNALPROPERTY(CachedUPluralRules) // Used to store cached UPluralRules objects for Intl.PluralRules
2327
INTERNALPROPERTY(RevocableProxy) // Internal slot for [[RevokableProxy]] for revocable proxy in ES6
2428
INTERNALPROPERTY(MutationBp) // Used to store strong reference to the mutation breakpoint object
2529
#undef INTERNALPROPERTY

lib/Runtime/Library/InJavascript/Intl.js.bc.32b.h

Lines changed: 3194 additions & 3193 deletions
Large diffs are not rendered by default.

lib/Runtime/Library/InJavascript/Intl.js.bc.64b.h

Lines changed: 3194 additions & 3194 deletions
Large diffs are not rendered by default.

lib/Runtime/Library/InJavascript/Intl.js.nojit.bc.32b.h

Lines changed: 2862 additions & 2861 deletions
Large diffs are not rendered by default.

lib/Runtime/Library/InJavascript/Intl.js.nojit.bc.64b.h

Lines changed: 2860 additions & 2860 deletions
Large diffs are not rendered by default.

lib/Runtime/Library/IntlEngineInterfaceExtensionObject.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ namespace Js
743743
Js::CallInfo callInfo(Js::CallFlags_Value, _countof(args));
744744

745745
Js::Arguments arguments(callInfo, args);
746-
scriptContext->GetThreadContext()->ExecuteImplicitCall(function, Js::ImplicitCall_Accessor, [=]()->Js::Var
746+
scriptContext->GetThreadContext()->ExecuteImplicitCall(function, Js::ImplicitCall_Accessor, [=]()->Js::Var
747747
{
748748
return JavascriptFunction::CallRootFunctionInScript(function, arguments);
749749
});
@@ -1536,7 +1536,7 @@ DEFINE_ISXLOCALEAVAILABLE(PR, uloc)
15361536
}
15371537

15381538
state->SetInternalProperty(
1539-
InternalPropertyIds::HiddenObject,
1539+
InternalPropertyIds::CachedUNumberFormat,
15401540
fmt,
15411541
PropertyOperationFlags::PropertyOperation_None,
15421542
nullptr
@@ -1817,14 +1817,13 @@ DEFINE_ISXLOCALEAVAILABLE(PR, uloc)
18171817
}
18181818

18191819
// Below, we lazy-initialize the backing UCollator on the first call to localeCompare
1820-
// On subsequent calls, the UCollator will be cached in state.hiddenObject
1821-
// TODO(jahorto): Make these property IDs sane, so that hiddenObject doesn't have different meanings in different contexts
1822-
Var hiddenObject = nullptr;
1820+
// On subsequent calls, the UCollator will be cached in state.CachedUCollator
1821+
Var cachedUCollator = nullptr;
18231822
FinalizableUCollator *coll = nullptr;
18241823
UErrorCode status = U_ZERO_ERROR;
1825-
if (state->GetInternalProperty(state, Js::InternalPropertyIds::HiddenObject, &hiddenObject, nullptr, scriptContext))
1824+
if (state->GetInternalProperty(state, InternalPropertyIds::CachedUCollator, &cachedUCollator, nullptr, scriptContext))
18261825
{
1827-
coll = reinterpret_cast<FinalizableUCollator *>(hiddenObject);
1826+
coll = reinterpret_cast<FinalizableUCollator *>(cachedUCollator);
18281827
INTL_TRACE("Using previously cached UCollator (0x%x)", coll);
18291828
}
18301829
else
@@ -1898,7 +1897,7 @@ DEFINE_ISXLOCALEAVAILABLE(PR, uloc)
18981897

18991898
// cache coll for later use (so that the condition that brought us here returns true for future calls)
19001899
state->SetInternalProperty(
1901-
InternalPropertyIds::HiddenObject,
1900+
InternalPropertyIds::CachedUCollator,
19021901
coll,
19031902
PropertyOperationFlags::PropertyOperation_None,
19041903
nullptr
@@ -2360,8 +2359,8 @@ DEFINE_ISXLOCALEAVAILABLE(PR, uloc)
23602359
DynamicObject *state = DynamicObject::UnsafeFromVar(args[2]);
23612360
bool toParts = JavascriptBoolean::UnsafeFromVar(args[3])->GetValue();
23622361
bool forNumberPrototypeToLocaleString = JavascriptBoolean::UnsafeFromVar(args[4])->GetValue();
2363-
Var cachedFormatter = nullptr; // cached by EntryIntl_CacheNumberFormat
2364-
AssertOrFailFast(state->GetInternalProperty(state, Js::InternalPropertyIds::HiddenObject, &cachedFormatter, NULL, scriptContext));
2362+
Var cachedUNumberFormat = nullptr; // cached by EntryIntl_CacheNumberFormat
2363+
AssertOrFailFast(state->GetInternalProperty(state, InternalPropertyIds::CachedUNumberFormat, &cachedUNumberFormat, NULL, scriptContext));
23652364

23662365
if (forNumberPrototypeToLocaleString)
23672366
{
@@ -2379,7 +2378,7 @@ DEFINE_ISXLOCALEAVAILABLE(PR, uloc)
23792378
INTL_TRACE("Calling NumberFormat.prototype.format(%f)", num);
23802379
}
23812380

2382-
auto fmt = static_cast<FinalizableUNumberFormat *>(cachedFormatter);
2381+
auto fmt = static_cast<FinalizableUNumberFormat *>(cachedUNumberFormat);
23832382
char16 *formatted = nullptr;
23842383
int formattedLen = 0;
23852384

@@ -2620,14 +2619,13 @@ DEFINE_ISXLOCALEAVAILABLE(PR, uloc)
26202619
}
26212620

26222621
// Below, we lazy-initialize the backing UDateFormat on the first call to format{ToParts}
2623-
// On subsequent calls, the UDateFormat will be cached in state.hiddenObject
2624-
// TODO(jahorto): Make these property IDs sane, so that hiddenObject doesn't have different meanings in different contexts
2625-
Var hiddenObject = nullptr;
2622+
// On subsequent calls, the UDateFormat will be cached in state.CachedUDateFormat
2623+
Var cachedUDateFormat = nullptr;
26262624
FinalizableUDateFormat *dtf = nullptr;
26272625
UErrorCode status = U_ZERO_ERROR;
2628-
if (state->GetInternalProperty(state, Js::InternalPropertyIds::HiddenObject, &hiddenObject, nullptr, scriptContext))
2626+
if (state->GetInternalProperty(state, InternalPropertyIds::CachedUDateFormat, &cachedUDateFormat, nullptr, scriptContext))
26292627
{
2630-
dtf = reinterpret_cast<FinalizableUDateFormat *>(hiddenObject);
2628+
dtf = reinterpret_cast<FinalizableUDateFormat *>(cachedUDateFormat);
26312629
INTL_TRACE("Using previously cached UDateFormat (0x%x)", dtf);
26322630
}
26332631
else
@@ -2668,7 +2666,7 @@ DEFINE_ISXLOCALEAVAILABLE(PR, uloc)
26682666

26692667
// cache dtf for later use (so that the condition that brought us here returns true for future calls)
26702668
state->SetInternalProperty(
2671-
InternalPropertyIds::HiddenObject,
2669+
InternalPropertyIds::CachedUDateFormat,
26722670
dtf,
26732671
PropertyOperationFlags::PropertyOperation_None,
26742672
nullptr
@@ -2949,11 +2947,11 @@ DEFINE_ISXLOCALEAVAILABLE(PR, uloc)
29492947
#ifdef INTL_ICU
29502948
static FinalizableUPluralRules *GetOrCreatePluralRulesCache(DynamicObject *stateObject, ScriptContext *scriptContext)
29512949
{
2952-
Var hiddenObject = nullptr;
2950+
Var cachedUPluralRules = nullptr;
29532951
FinalizableUPluralRules *pr = nullptr;
2954-
if (stateObject->GetInternalProperty(stateObject, InternalPropertyIds::HiddenObject, &hiddenObject, nullptr, scriptContext))
2952+
if (stateObject->GetInternalProperty(stateObject, InternalPropertyIds::CachedUPluralRules, &cachedUPluralRules, nullptr, scriptContext))
29552953
{
2956-
pr = reinterpret_cast<FinalizableUPluralRules *>(hiddenObject);
2954+
pr = reinterpret_cast<FinalizableUPluralRules *>(cachedUPluralRules);
29572955
INTL_TRACE("Using previously cached UPluralRules (0x%x)", pr);
29582956
}
29592957
else
@@ -2981,7 +2979,7 @@ DEFINE_ISXLOCALEAVAILABLE(PR, uloc)
29812979

29822980
INTL_TRACE("Caching UPluralRules object (0x%x) with langtag %s and type %s", langtag->GetSz(), type->GetSz());
29832981

2984-
stateObject->SetInternalProperty(InternalPropertyIds::HiddenObject, pr, PropertyOperationFlags::PropertyOperation_None, nullptr);
2982+
stateObject->SetInternalProperty(InternalPropertyIds::CachedUPluralRules, pr, PropertyOperationFlags::PropertyOperation_None, nullptr);
29852983
}
29862984

29872985
return pr;

0 commit comments

Comments
 (0)