Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Issue 1374533002: Null out LocalDOMWindow::m_frame on navigation. (Closed)

Created:
5 years, 2 months ago by dcheng
Modified:
5 years, 2 months ago
CC:
blink-reviews, Nate Chapin, yhirano
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Null out LocalDOMWindow::frame() on navigation. In Blink, LocalDOMWindow::frame() is only set to null when the LocalFrame is destroyed. Multiple LocalDOMWindow objects can hold a reference to the same LocalFrame. It turns out that this is dangerous and a persistent source of XSS bugs. Code that creates scriptable objects for a frame needs to remember to call DOMWindow::isCurrentlyDisplayedInFrame() to verify that the creating context is still active in the frame. If this check is left out, the created object can often trigger XSS. Instead of depending on developers to remember to add this check where needed, Blink now nulls out LocalDOMWindow::frame() as soon as it navigates away from a LocalDOMWindow. Code in Blink already handles the null case, since this is already something that can happen. Code that improperly handles this case will tend to crash (suboptimal but safe), and in general, failures won't result in XSS, since a detached frame cannot be reattached. BUG=525330 Committed: https://crrev.com/a55a83b15a84eb408cd5805c4fb4dcba17d6054a Cr-Commit-Position: refs/heads/master@{#351496}

Patch Set 1 #

Patch Set 2 : Moar assert #

Patch Set 3 : Add comments and fix stack overflow. #

Total comments: 2

Patch Set 4 : Fix tests and add a test #

Total comments: 5

Patch Set 5 : try to fix crash-on-querying-event-path.html #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+130 lines, -106 lines) Patch
A third_party/WebKit/LayoutTests/fast/dom/Window/property-access-in-closure-after-navigation.html View 1 2 3 1 chunk +24 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/fast/dom/Window/property-access-in-closure-after-navigation-expected.txt View 1 2 3 1 chunk +14 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/Window/resources/dom-access-from-closure-iframe-child.html View 1 2 3 2 chunks +9 lines, -5 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/Window/resources/dom-access-from-closure-window-child.html View 1 2 3 2 chunks +9 lines, -5 lines 0 comments Download
A third_party/WebKit/LayoutTests/fast/dom/Window/resources/property-access-in-closure-after-navigation-child.html View 1 2 3 1 chunk +34 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/resources/javascript-url-crash-function-iframe.html View 1 2 3 1 chunk +5 lines, -2 lines 0 comments Download
A + third_party/WebKit/LayoutTests/fast/events/crash-on-querying-event-path.html View 1 2 3 4 2 chunks +6 lines, -12 lines 1 comment Download
A + third_party/WebKit/LayoutTests/fast/events/crash-on-querying-event-path-expected.txt View 1 2 3 4 0 chunks +-1 lines, --1 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/parser/resources/set-parent-to-javascript-url.html View 1 2 3 1 chunk +3 lines, -1 line 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/dom/crash-on-querying-event-path.html View 1 2 3 4 1 chunk +0 lines, -48 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/dom/crash-on-querying-event-path-expected.txt View 1 2 3 4 1 chunk +0 lines, -11 lines 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html View 1 2 3 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/security/resources/xss-eval2.html View 1 2 3 1 chunk +9 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/frame/DOMWindow.cpp View 1 chunk +3 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/frame/LocalDOMWindow.h View 1 chunk +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp View 1 2 3 6 chunks +10 lines, -15 lines 0 comments Download

Messages

Total messages: 30 (9 generated)
dcheng
This change has a few implications for backwards compatibility: if a page captures a reference ...
5 years, 2 months ago (2015-09-28 06:44:15 UTC) #2
dcheng
https://codereview.chromium.org/1374533002/diff/40001/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp File third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp (left): https://codereview.chromium.org/1374533002/diff/40001/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp#oldcode670 third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp:670: if (!isCurrentlyDisplayedInFrame() && (!m_navigator || m_navigator->frame())) { I tested ...
5 years, 2 months ago (2015-09-28 06:45:09 UTC) #3
haraken
I'll defer the decision to jochen@. On 2015/09/28 06:44:15, dcheng wrote: > This change has ...
5 years, 2 months ago (2015-09-28 06:57:21 UTC) #4
dcheng
On 2015/09/28 at 06:57:21, haraken wrote: > I'll defer the decision to jochen@. > > ...
5 years, 2 months ago (2015-09-28 08:05:17 UTC) #5
jochen (gone - plz use gerrit)
Toon, can you comment on this?
5 years, 2 months ago (2015-09-28 11:34:35 UTC) #7
jochen (gone - plz use gerrit)
(anyway, matching firefox seems fine, so I'd go ahead and update the layout tests)
5 years, 2 months ago (2015-09-28 11:34:58 UTC) #8
dcheng
OK, I fixed the layout tests (generally, by capturing any variables into the closure rather ...
5 years, 2 months ago (2015-09-29 07:50:38 UTC) #9
jochen (gone - plz use gerrit)
lgtm
5 years, 2 months ago (2015-09-29 07:51:57 UTC) #10
dcheng
https://codereview.chromium.org/1374533002/diff/60001/third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html File third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html (right): https://codereview.chromium.org/1374533002/diff/60001/third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html#newcode4 third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html:4: f[0].location = "http://127.0.0.1:8000/security/frameNavigation/resources/fail.html"; Incidentally... this test was actually failing ...
5 years, 2 months ago (2015-09-29 07:53:25 UTC) #11
haraken
LGTM
5 years, 2 months ago (2015-09-29 07:54:41 UTC) #12
Nate Chapin
https://codereview.chromium.org/1374533002/diff/60001/third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html File third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html (right): https://codereview.chromium.org/1374533002/diff/60001/third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html#newcode4 third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html:4: f[0].location = "http://127.0.0.1:8000/security/frameNavigation/resources/fail.html"; On 2015/09/29 07:53:25, dcheng wrote: > ...
5 years, 2 months ago (2015-09-29 21:49:00 UTC) #14
dcheng
https://codereview.chromium.org/1374533002/diff/60001/third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html File third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html (right): https://codereview.chromium.org/1374533002/diff/60001/third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html#newcode4 third_party/WebKit/LayoutTests/http/tests/security/frameNavigation/resources/popup-ready-to-navigate-child.html:4: f[0].location = "http://127.0.0.1:8000/security/frameNavigation/resources/fail.html"; On 2015/09/29 at 21:49:00, Nate Chapin ...
5 years, 2 months ago (2015-09-29 21:53:53 UTC) #15
haraken
On 2015/09/28 08:05:17, dcheng wrote: > On 2015/09/28 at 06:57:21, haraken wrote: > > I'll ...
5 years, 2 months ago (2015-09-29 23:41:28 UTC) #17
dcheng
On 2015/09/29 at 23:41:28, haraken wrote: > On 2015/09/28 08:05:17, dcheng wrote: > > On ...
5 years, 2 months ago (2015-09-30 00:37:55 UTC) #18
dcheng
PTAL at the test changes for crash-on-querying-event-path.html. I found some concerning things during my investigation, ...
5 years, 2 months ago (2015-09-30 00:46:18 UTC) #20
haraken
On 2015/09/30 00:37:55, dcheng wrote: > On 2015/09/29 at 23:41:28, haraken wrote: > > On ...
5 years, 2 months ago (2015-09-30 01:33:41 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1374533002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1374533002/80001
5 years, 2 months ago (2015-09-30 02:26:04 UTC) #24
commit-bot: I haz the power
Try jobs failed on following builders: win_chromium_rel_ng on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/114117)
5 years, 2 months ago (2015-09-30 04:03:25 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1374533002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1374533002/80001
5 years, 2 months ago (2015-09-30 04:05:21 UTC) #28
commit-bot: I haz the power
Committed patchset #5 (id:80001)
5 years, 2 months ago (2015-09-30 05:05:01 UTC) #29
commit-bot: I haz the power
5 years, 2 months ago (2015-09-30 05:06:02 UTC) #30
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/a55a83b15a84eb408cd5805c4fb4dcba17d6054a
Cr-Commit-Position: refs/heads/master@{#351496}

Powered by Google App Engine
This is Rietveld 408576698