Changeset 245249 in webkit


Ignore:
Timestamp:
May 13, 2019 1:52:04 PM (5 years ago)
Author:
Tadeu Zagallo
Message:

JSObject::getOwnPropertyDescriptor is missing an exception check
https://bugs.webkit.org/show_bug.cgi?id=197693
JSTests:

<rdar://problem/50441784>

Reviewed by Saam Barati.

  • stress/proxy-spread.js: Added.

(foo):

Source/JavaScriptCore:

<rdar://problem/50441784>

Reviewed by Saam Barati.

The method table call to getOwnPropertySlot might throw, and JSObject::getOwnPropertyDescriptor
must handle the exception before calling PropertySlot::getValue, which can also throw.

  • runtime/JSObject.cpp:

(JSC::JSObject::getOwnPropertyDescriptor):

Source/WebCore:

Reviewed by Saam Barati.

JSObject::getOwnPropertyDescriptor assumes that getOwnPropertySlot returns false
if an exception is thrown, but that was not true for JSLocation::getOwnPropertySlotCommon.

This is already covered by http/tests/security/cross-frame-access-getOwnPropertyDescriptor.html

  • bindings/js/JSLocationCustom.cpp:

(WebCore::getOwnPropertySlotCommon):
(WebCore::JSLocation::getOwnPropertySlot):
(WebCore::JSLocation::getOwnPropertySlotByIndex):

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r245203 r245249  
     12019-05-13  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        JSObject::getOwnPropertyDescriptor is missing an exception check
     4        https://bugs.webkit.org/show_bug.cgi?id=197693
     5        <rdar://problem/50441784>
     6
     7        Reviewed by Saam Barati.
     8
     9        * stress/proxy-spread.js: Added.
     10        (foo):
     11
    1122019-05-10  Saam barati  <sbarati@apple.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r245239 r245249  
     12019-05-13  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        JSObject::getOwnPropertyDescriptor is missing an exception check
     4        https://bugs.webkit.org/show_bug.cgi?id=197693
     5        <rdar://problem/50441784>
     6
     7        Reviewed by Saam Barati.
     8
     9        The method table call to getOwnPropertySlot might throw, and JSObject::getOwnPropertyDescriptor
     10        must handle the exception before calling PropertySlot::getValue, which can also throw.
     11
     12        * runtime/JSObject.cpp:
     13        (JSC::JSObject::getOwnPropertyDescriptor):
     14
    1152019-05-13  Yusuke Suzuki  <ysuzuki@apple.com>
    216
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r244872 r245249  
    34423442{
    34433443    VM& vm = exec->vm();
     3444    auto scope = DECLARE_THROW_SCOPE(vm);
    34443445    JSC::PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
    3445     if (!methodTable(vm)->getOwnPropertySlot(this, exec, propertyName, slot))
     3446
     3447    bool result = methodTable(vm)->getOwnPropertySlot(this, exec, propertyName, slot);
     3448    EXCEPTION_ASSERT(!scope.exception() || !result);
     3449    if (!result)
    34463450        return false;
    34473451
     
    34893493        if (getterSetter->setter())
    34903494            descriptor.setSetter(getCustomGetterSetterFunctionForGetterSetter(exec, propertyName, getterSetter, JSCustomGetterSetterFunction::Type::Setter));
    3491     } else
    3492         descriptor.setDescriptor(slot.getValue(exec, propertyName), slot.attributes());
     3495    } else {
     3496        JSValue value = slot.getValue(exec, propertyName);
     3497        RETURN_IF_EXCEPTION(scope, false);
     3498        descriptor.setDescriptor(value, slot.attributes());
     3499    }
     3500
    34933501    return true;
    34943502}
  • trunk/Source/WebCore/ChangeLog

    r245242 r245249  
     12019-05-13  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        JSObject::getOwnPropertyDescriptor is missing an exception check
     4        https://bugs.webkit.org/show_bug.cgi?id=197693
     5
     6        Reviewed by Saam Barati.
     7
     8        JSObject::getOwnPropertyDescriptor assumes that getOwnPropertySlot returns false
     9        if an exception is thrown, but that was not true for JSLocation::getOwnPropertySlotCommon.
     10
     11        This is already covered by http/tests/security/cross-frame-access-getOwnPropertyDescriptor.html
     12
     13        * bindings/js/JSLocationCustom.cpp:
     14        (WebCore::getOwnPropertySlotCommon):
     15        (WebCore::JSLocation::getOwnPropertySlot):
     16        (WebCore::JSLocation::getOwnPropertySlotByIndex):
     17
    1182019-05-13  Antti Koivisto  <antti@apple.com>
    219
  • trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp

    r241104 r245249  
    7474    throwSecurityError(state, scope, message);
    7575    slot.setUndefined();
    76     return true;
     76    return false;
    7777}
    7878
    7979bool JSLocation::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
    8080{
     81    VM& vm = state->vm();
     82    auto scope = DECLARE_THROW_SCOPE(vm);
    8183    auto* thisObject = jsCast<JSLocation*>(object);
    8284    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
    8385
    84     if (getOwnPropertySlotCommon(*thisObject, *state, propertyName, slot))
    85         return true;
    86     return JSObject::getOwnPropertySlot(object, state, propertyName, slot);
     86    bool result = getOwnPropertySlotCommon(*thisObject, *state, propertyName, slot);
     87    EXCEPTION_ASSERT(!scope.exception() || !result);
     88    RETURN_IF_EXCEPTION(scope, false);
     89    if (result)
     90        return true;
     91    RELEASE_AND_RETURN(scope, JSObject::getOwnPropertySlot(object, state, propertyName, slot));
    8792}
    8893
    8994bool JSLocation::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
    9095{
     96    VM& vm = state->vm();
     97    auto scope = DECLARE_THROW_SCOPE(vm);
    9198    auto* thisObject = jsCast<JSLocation*>(object);
    9299    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
    93100
    94     if (getOwnPropertySlotCommon(*thisObject, *state, Identifier::from(state, index), slot))
    95         return true;
    96     return JSObject::getOwnPropertySlotByIndex(object, state, index, slot);
     101    bool result = getOwnPropertySlotCommon(*thisObject, *state, Identifier::from(state, index), slot);
     102    EXCEPTION_ASSERT(!scope.exception() || !result);
     103    RETURN_IF_EXCEPTION(scope, false);
     104    if (result)
     105        return true;
     106    RELEASE_AND_RETURN(scope, JSObject::getOwnPropertySlotByIndex(object, state, index, slot));
    97107}
    98108
Note: See TracChangeset for help on using the changeset viewer.