Bug 213075

Summary: RegExp.prototype getters should throw on cross-realm access
Product: WebKit Reporter: Alexey Shvayka <ashvayka>
Component: JavaScriptCoreAssignee: Alexey Shvayka <ashvayka>
Status: RESOLVED FIXED    
Severity: Trivial CC: ews-watchlist, keith_miller, littledan, mark.lam, msaboff, ross.kirsling, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch none

Description Alexey Shvayka 2020-06-11 08:00:25 PDT
RegExp.prototype getters should throw on cross-realm access
Comment 1 Alexey Shvayka 2020-06-11 08:01:49 PDT
Created attachment 401644 [details]
Patch
Comment 2 Saam Barati 2020-06-11 09:19:02 PDT
Comment on attachment 401644 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401644&action=review

> Source/JavaScriptCore/runtime/RegExpPrototype.cpp:242
> +        if (thisValue == globalObject->regExpPrototype())

Which realm is used by the spec? The realm from the object? Or the realm of the static code running? This is using the latter. Is that intentional?
Comment 3 Alexey Shvayka 2020-06-11 09:32:45 PDT
(In reply to Saam Barati from comment #2)
> Comment on attachment 401644 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=401644&action=review
> 
> > Source/JavaScriptCore/runtime/RegExpPrototype.cpp:242
> > +        if (thisValue == globalObject->regExpPrototype())
> 
> Which realm is used by the spec? The realm from the object? Or the realm of
> the static code running? This is using the latter. Is that intentional?

The spec uses realm of static code (of a getter).
Otherwise, the check would never fail: if `object` is a %RegExp.prototype%, `object.realm.RegExp.prototype` is `object` itself.
Comment 4 EWS 2020-06-11 10:24:00 PDT
Committed r262908: <https://trac.webkit.org/changeset/262908>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401644 [details].
Comment 5 Radar WebKit Bug Importer 2020-06-11 10:24:17 PDT
<rdar://problem/64259571>