Bug 191073 - Calling window.open("", "_self") allows working around restrictions on window.close()
Summary: Calling window.open("", "_self") allows working around restrictions on window...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ali Juma
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-10-30 11:12 PDT by Ali Juma
Modified: 2018-10-30 12:59 PDT (History)
4 users (show)

See Also:


Attachments
Patch (3.67 KB, patch)
2018-10-30 11:14 PDT, Ali Juma
no flags Details | Formatted Diff | Diff
Patch for landing (3.63 KB, patch)
2018-10-30 12:19 PDT, Ali Juma
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ali Juma 2018-10-30 11:12:32 PDT
Windows that haven't been opened by script can't be closed using window.close(). However, calling |window.open("", "_self")| causes the existing window to be treated as if it's been opened by script, since in DOMWindow::createWindow we call |newFrame->page()->setOpenedByDOM();| without checking if this is really a newly-created frame.

This means that script can trivially workaround the restriction on window.close() by instead calling:
window.open("", "_self").close()

Neither Blink nor Gecko allows scripts to close windows this way.
Comment 1 Ali Juma 2018-10-30 11:14:21 PDT
Created attachment 353388 [details]
Patch
Comment 2 Chris Dumez 2018-10-30 11:37:56 PDT
Comment on attachment 353388 [details]
Patch

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

r=me

> LayoutTests/fast/dom/Window/window-open-self-disallow-close.html:5
> +    <div id="log"></div>

Is this really needed?
Comment 3 Ali Juma 2018-10-30 12:19:34 PDT
Created attachment 353396 [details]
Patch for landing
Comment 4 Ali Juma 2018-10-30 12:20:56 PDT
(In reply to Chris Dumez from comment #2)
> Comment on attachment 353388 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=353388&action=review
> 
> r=me
> 
> > LayoutTests/fast/dom/Window/window-open-self-disallow-close.html:5
> > +    <div id="log"></div>
> 
> Is this really needed?

Not needed, removed now.
Comment 5 WebKit Commit Bot 2018-10-30 12:58:59 PDT
Comment on attachment 353396 [details]
Patch for landing

Clearing flags on attachment: 353396

Committed r237598: <https://trac.webkit.org/changeset/237598>
Comment 6 WebKit Commit Bot 2018-10-30 12:59:01 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2018-10-30 12:59:22 PDT
<rdar://problem/45677825>