New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 687844 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Feb 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Bug-Security



Sign in to add a comment

window.external leaks the entire global object by way of the wrapper and also allows cross origin script access

Project Member Reported by esprehn@chromium.org, Feb 2 2017

Issue description

Google Chrome	55.0.2883.105 (Official Build) (64-bit)

We use a static local for the External object:
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/frame/DOMWindow.cpp?type=cs&q=%22external()%22+file:webkit&l=116

but that both leaks the entire global object in the wrapper stored inside the External and also means that doing:

// main page.
window.external.foo = function() { alert(1); }
document.body.innerHTML = "<iframe src='https://example.com'>";

// inside example.com:

window.external.foo() // alert happens!

A static local ScriptWrappable is always wrong since it leaks memory and wrappers across frames.
 
Owner: dcheng@chromium.org
Status: Assigned (was: Untriaged)
It seems like there should be a UXSS by getting the parent page to touch window.external and then doing:

(new window.external.__proto__.constructor.__proto__.constructor("alert(window.location.href)"))()

but something seems to be making that return undefined. Is there an origin check in "new Function" somehow?
Project Member

Comment 3 by bugdroid1@chromium.org, Feb 2 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f2026d03c0b50a54ca5d4845edb64f65a49deff7

commit f2026d03c0b50a54ca5d4845edb64f65a49deff7
Author: dcheng <dcheng@chromium.org>
Date: Thu Feb 02 08:26:34 2017

Make External per-window rather than a static Persistent.

Sharing wrappers between contexts is unsafe.

BUG= 687844 

Review-Url: https://codereview.chromium.org/2671673002
Cr-Commit-Position: refs/heads/master@{#447724}

[modify] https://crrev.com/f2026d03c0b50a54ca5d4845edb64f65a49deff7/third_party/WebKit/Source/core/frame/DOMWindow.cpp
[modify] https://crrev.com/f2026d03c0b50a54ca5d4845edb64f65a49deff7/third_party/WebKit/Source/core/frame/DOMWindow.h

If we have a test that uses window.external(), the memory leak should have been caught by the leak detector (I think).

Will introducing LocalDOMWindow::m_external solve the problem?

Labels: -Type-Bug Restrict-View-SecurityTeam Type-Bug-Security
Labels: -M-57 M-55 Merge-
Status: Fixed (was: Assigned)
Yes, that's what the patch does. Originally I wanted to be clever and save memory for a rarely used attribute, but the resulting behavior is clearly wrong.
Labels: -Merge- Merge-Request-57
Didn't notice you've already fixed it :)

Project Member

Comment 9 by sheriffbot@chromium.org, Feb 2 2017

Labels: -Restrict-View-SecurityTeam Restrict-View-SecurityNotify
Project Member

Comment 10 by sheriffbot@chromium.org, Feb 3 2017

Labels: -Merge-Request-57 Hotlist-Merge-Approved Merge-Approved-57
Your change meets the bar and is auto-approved for M57. Please go ahead and merge the CL to branch 2987 manually. Please contact milestone owner if you have questions.
Owners: amineer@(clank), cmasso@(bling), ketakid@(cros), govind@(desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
We could outlaw ScriptWrappable singletons via a static_assert() in DEFINE_STATIC_LOCAL().

Was the issue discovered by code inspection?
I believe this was discovered via code inspection.
Project Member

Comment 13 by bugdroid1@chromium.org, Feb 3 2017

Labels: -merge-approved-57 merge-merged-2987
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dd371fbefb97e0cb80079b34a7ec69afe759bd29

commit dd371fbefb97e0cb80079b34a7ec69afe759bd29
Author: Daniel Cheng <dcheng@chromium.org>
Date: Fri Feb 03 19:48:19 2017

Make External per-window rather than a static Persistent.

Sharing wrappers between contexts is unsafe.

BUG= 687844 

Review-Url: https://codereview.chromium.org/2671673002
Cr-Commit-Position: refs/heads/master@{#447724}
(cherry picked from commit f2026d03c0b50a54ca5d4845edb64f65a49deff7)

Review-Url: https://codereview.chromium.org/2670763009 .
Cr-Commit-Position: refs/branch-heads/2987@{#296}
Cr-Branched-From: ad51088c0e8776e8dcd963dbe752c4035ba6dab6-refs/heads/master@{#444943}

[modify] https://crrev.com/dd371fbefb97e0cb80079b34a7ec69afe759bd29/third_party/WebKit/Source/core/frame/DOMWindow.cpp
[modify] https://crrev.com/dd371fbefb97e0cb80079b34a7ec69afe759bd29/third_party/WebKit/Source/core/frame/DOMWindow.h

Labels: Merge-Request-56
The InputDeviceCapabilities singletons could run into same, i think -- https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/input/InputDeviceCapabilities.cpp?l=19
Yeah those are wrong too.
Filed  issue 688569  to followup on the others, to make merges easier to track.
Cc: awhalley@chromium.org
+awhalley for evaluating the severity of this.

Since we're already launched to Stable on M56 this may be too late, is this a recent regression or has window.external always persisted across navigations?
Labels: Security_Severity-High
Since this was internally reported I'm ok picking it up in the next stable we ship (be that a 56 update, or 57)
#18, this wasn't a particularly recent regression, so it's definitely in M56. esprehn@ and I haven't been able to find an outright uxss using this, but what the code currently does is certainly various dangerous.

One mitigating factor is that you can "only" uxss the first origin that touches window.external in a given renderer... so if nothing ever touches it, it's "okay".
Project Member

Comment 21 by sheriffbot@chromium.org, Feb 7 2017

Labels: -M-55 M-56
Labels: -Merge-Request-56 Merge-Approved-56
Approving for merge into M56
Project Member

Comment 23 by bugdroid1@chromium.org, Feb 9 2017

Labels: -merge-approved-56 merge-merged-2924
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b2bd86444285956bcd1a516cb49dd1261270c5d9

commit b2bd86444285956bcd1a516cb49dd1261270c5d9
Author: Daniel Cheng <dcheng@chromium.org>
Date: Thu Feb 09 21:10:32 2017

Make External per-window rather than a static Persistent.

Sharing wrappers between contexts is unsafe.

BUG= 687844 

Review-Url: https://codereview.chromium.org/2671673002
Cr-Commit-Position: refs/heads/master@{#447724}
(cherry picked from commit f2026d03c0b50a54ca5d4845edb64f65a49deff7)

Review-Url: https://codereview.chromium.org/2681233004 .
Cr-Commit-Position: refs/branch-heads/2924@{#905}
Cr-Branched-From: 3a87aecc31cd1ffe751dd72c04e5a96a1fc8108a-refs/heads/master@{#433059}

[modify] https://crrev.com/b2bd86444285956bcd1a516cb49dd1261270c5d9/third_party/WebKit/Source/core/frame/DOMWindow.cpp
[modify] https://crrev.com/b2bd86444285956bcd1a516cb49dd1261270c5d9/third_party/WebKit/Source/core/frame/DOMWindow.h

Labels: -Hotlist-Merge-Approved
Labels: Release-0-M57
Project Member

Comment 26 by sheriffbot@chromium.org, May 11 2017

Labels: -Restrict-View-SecurityNotify allpublic
This bug has been closed for more than 14 weeks. Removing security view restrictions.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment