Skip to content

Commit 765bcd2

Browse files
pleathaneeshdk
authored andcommitted
[CVE-2018-8384] Edge - Chakra: Type confusion with PathTypeHandlerBase::SetAttributesHelper - Google, Inc.
1 parent d52c72d commit 765bcd2

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

lib/Runtime/Types/PathTypeHandler.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,17 @@ namespace Js
388388
#endif
389389
// This can happen if object header inlining is deoptimized, and we haven't built a full path from the root.
390390
// For now, just punt this case.
391-
return TryConvertToSimpleDictionaryType(instance, GetPathLength())->SetAttributes(instance, propertyId, ObjectSlotAttributesToPropertyAttributes(propertyAttributes));
391+
392+
if (setAllAttributes)
393+
{
394+
// We could be trying to convert an accessor to a data property, or something similar, so do the type handler conversion here and let the caller handle setting the attributes.
395+
TryConvertToSimpleDictionaryType(instance, GetPathLength());
396+
return false;
397+
}
398+
else
399+
{
400+
return TryConvertToSimpleDictionaryType(instance, GetPathLength())->SetAttributes(instance, propertyId, ObjectSlotAttributesToPropertyAttributes(propertyAttributes));
401+
}
392402
}
393403
predTypeHandler = PathTypeHandlerBase::FromTypeHandler(currentType->GetTypeHandler());
394404
}
@@ -752,16 +762,25 @@ namespace Js
752762
// In CacheOperators::CachePropertyWrite we ensure that we never cache property adds for types that aren't shared.
753763
Assert(!instance->GetDynamicType()->GetIsShared() || GetIsShared());
754764

765+
bool setAttrDone;
755766
if (setAttributes)
756767
{
757-
this->SetAttributesHelper(instance, propertyId, index, GetAttributeArray(), attr, true);
768+
setAttrDone = this->SetAttributesHelper(instance, propertyId, index, GetAttributeArray(), attr, true);
769+
if (!setAttrDone)
770+
{
771+
return instance->GetTypeHandler()->SetPropertyWithAttributes(instance, propertyId, value, attr, info, flags, possibleSideEffects);
772+
}
758773
}
759774
else if (isInit)
760775
{
761776
ObjectSlotAttributes * attributes = this->GetAttributeArray();
762777
if (attributes && (attributes[index] & ObjectSlotAttr_Accessor))
763778
{
764-
this->SetAttributesHelper(instance, propertyId, index, attributes, (ObjectSlotAttributes)(attributes[index] & ~ObjectSlotAttr_Accessor), true);
779+
setAttrDone = this->SetAttributesHelper(instance, propertyId, index, attributes, (ObjectSlotAttributes)(attributes[index] & ~ObjectSlotAttr_Accessor), true);
780+
if (!setAttrDone)
781+
{
782+
return instance->GetTypeHandler()->InitProperty(instance, propertyId, value, flags, info);
783+
}
765784
// We're changing an accessor into a data property at object init time. Don't cache this transition from setter to non-setter,
766785
// as it behaves differently from a normal set property.
767786
PropertyValueInfo::SetNoCache(info, instance);

0 commit comments

Comments
 (0)