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

Issue 22829002: Throw an exception when denying access to 'Frame's 'location' setter. (Closed)

Created:
7 years, 4 months ago by Mike West
Modified:
7 years, 4 months ago
CC:
blink-reviews, Nils Barth (inactive), kojih, jsbell+bindings_chromium.org, eae+blinkwatch, marja+watch_chromium.org, dglazkov+blink, adamk+blink_chromium.org, haraken, Nate Chapin, do-not-use, jochen (gone - plz use gerrit)
Visibility:
Public.

Description

Throw an exception when denying access to 'Frame's 'location' setter. Currently, we write an access-denied message to the console when we deny a page's attempt to set a frame's location to a 'javascript:' URL. This patch changes our behavior to throw an exception. Firefox currently does not throw an exception, but silently denies access to set the property cross-origin. I don't believe that's behavior we should seek to replicate. This patch removes the one-off 'BindingSecurity::allowSettingFrameSrcToJavascriptUrl', moving the guts of the protocol check into the custom bindings, and delegating the security aspects to 'allowAccessToFrame'. 'allowAccessToFrame' can now accept an 'ExceptionState' rather than a reporting enum, and that's piped through to a new 'canAccessDocument' method. This has the happy effect of beginning to put the pieces in place for future patches which will migrate other 'allowAccessToFrame' calls to the new, exception-throwing model. The patch also adds 'ExceptionState::throwSecurityError', which accepts two strings: a sanitized string, and an unsanitized optional string. Those values get piped through V8ThrowException, and are stored on 'DOMException' which tunnels through V8 and pops out in 'V8Initializer'. There, I set the unsanitized message on the 'ErrorEvent' object that's handed off to the exception reporting code in 'ScriptExecutionContext'. BUG=17325 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=156151

Patch Set 1 #

Patch Set 2 : Rebase. #

Total comments: 9

Patch Set 3 : Less insecurity. #

Total comments: 1

Patch Set 4 : Sanitization. #

Patch Set 5 : Uncaught. #

Total comments: 13

Patch Set 6 : Feedback. #

Patch Set 7 : Off by one. #

Total comments: 3

Patch Set 8 : abarth feedback. #

Patch Set 9 : drop the assert. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+233 lines, -66 lines) Patch
M LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom.html View 1 2 3 4 5 1 chunk +27 lines, -28 lines 0 comments Download
M LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt View 1 2 3 1 chunk +6 lines, -3 lines 0 comments Download
A LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught.html View 1 2 3 4 5 1 chunk +39 lines, -0 lines 0 comments Download
A LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt View 1 2 3 4 5 6 1 chunk +13 lines, -0 lines 0 comments Download
M Source/bindings/v8/BindingSecurity.h View 1 2 chunks +2 lines, -2 lines 0 comments Download
M Source/bindings/v8/BindingSecurity.cpp View 1 2 3 3 chunks +27 lines, -10 lines 0 comments Download
M Source/bindings/v8/ExceptionState.h View 1 2 3 4 5 2 chunks +2 lines, -0 lines 0 comments Download
M Source/bindings/v8/ExceptionState.cpp View 1 2 3 4 5 2 chunks +12 lines, -0 lines 0 comments Download
M Source/bindings/v8/ExceptionStatePlaceholder.h View 1 2 3 4 5 2 chunks +2 lines, -0 lines 0 comments Download
M Source/bindings/v8/ExceptionStatePlaceholder.cpp View 1 2 3 4 5 1 chunk +5 lines, -0 lines 0 comments Download
M Source/bindings/v8/V8Initializer.cpp View 1 2 3 4 2 chunks +12 lines, -1 line 0 comments Download
M Source/bindings/v8/V8ThrowException.h View 1 2 3 1 chunk +10 lines, -2 lines 0 comments Download
M Source/bindings/v8/V8ThrowException.cpp View 1 2 3 4 5 2 chunks +8 lines, -5 lines 0 comments Download
M Source/bindings/v8/custom/V8HTMLFrameElementCustom.cpp View 2 chunks +6 lines, -1 line 0 comments Download
M Source/core/dom/DOMException.h View 1 2 3 4 5 6 7 8 1 chunk +10 lines, -4 lines 0 comments Download
M Source/core/dom/DOMException.cpp View 1 2 3 4 2 chunks +11 lines, -4 lines 0 comments Download
M Source/core/dom/ErrorEvent.h View 1 2 3 4 5 6 7 8 1 chunk +9 lines, -2 lines 0 comments Download
M Source/core/dom/ErrorEvent.cpp View 1 2 3 3 chunks +8 lines, -2 lines 0 comments Download
M Source/core/dom/ScriptExecutionContext.cpp View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/page/DOMWindow.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/page/DOMWindow.cpp View 1 2 3 4 5 6 7 1 chunk +21 lines, -0 lines 0 comments Download

Messages

Total messages: 20 (0 generated)
Mike West
Hi Adam, Jochen, This patch adjusts 'Frame''s location setter to throw an exception when a ...
7 years, 4 months ago (2013-08-12 12:36:53 UTC) #1
jochen (gone - plz use gerrit)
I defer to Adam on this one
7 years, 4 months ago (2013-08-12 12:57:23 UTC) #2
abarth-chromium
LGTM with some minor comments. https://codereview.chromium.org/22829002/diff/5001/Source/bindings/v8/BindingSecurity.cpp File Source/bindings/v8/BindingSecurity.cpp (right): https://codereview.chromium.org/22829002/diff/5001/Source/bindings/v8/BindingSecurity.cpp#newcode59 Source/bindings/v8/BindingSecurity.cpp:59: static bool canAccessDocument(Document* targetDocument, ...
7 years, 4 months ago (2013-08-12 19:57:03 UTC) #3
abarth-chromium
https://codereview.chromium.org/22829002/diff/5001/Source/bindings/v8/BindingSecurity.cpp File Source/bindings/v8/BindingSecurity.cpp (right): https://codereview.chromium.org/22829002/diff/5001/Source/bindings/v8/BindingSecurity.cpp#newcode64 Source/bindings/v8/BindingSecurity.cpp:64: es.throwDOMException(SecurityError, targetDocument->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow())); Wait a minute. not lgtm. This leaks ...
7 years, 4 months ago (2013-08-12 19:58:25 UTC) #4
abarth-chromium
https://codereview.chromium.org/22829002/diff/5001/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt File LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt (right): https://codereview.chromium.org/22829002/diff/5001/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt#newcode3 LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt:3: CONSOLE MESSAGE: line 34: Caught exception while setting frame's ...
7 years, 4 months ago (2013-08-12 19:59:18 UTC) #5
Mike West
Thanks Adam. That was dumb of me. Mind taking another look? -mike https://codereview.chromium.org/22829002/diff/5001/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt File LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt ...
7 years, 4 months ago (2013-08-13 08:30:50 UTC) #6
abarth-chromium
https://codereview.chromium.org/22829002/diff/14001/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt File LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt (left): https://codereview.chromium.org/22829002/diff/14001/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt#oldcode3 LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt:3: CONSOLE MESSAGE: Blocked a frame with origin "http://127.0.0.1:8000" from ...
7 years, 4 months ago (2013-08-13 20:09:30 UTC) #7
Use mkwst_at_chromium.org plz.
On 2013/08/13 20:09:30, abarth wrote: > It's a shame that the console message itself is ...
7 years, 4 months ago (2013-08-13 20:56:08 UTC) #8
arv (Not doing code reviews)
On 2013/08/13 20:56:08, mkwst wrote: > On 2013/08/13 20:09:30, abarth wrote: > > It's a ...
7 years, 4 months ago (2013-08-13 23:15:17 UTC) #9
Use mkwst_at_chromium.org plz.
On 2013/08/13 23:15:17, arv wrote: > What does the inspector get? Does it have access ...
7 years, 4 months ago (2013-08-13 23:28:59 UTC) #10
abarth-chromium
On 2013/08/13 23:28:59, mkwst wrote: > Adam, are the cross-origin messages the only ones you're ...
7 years, 4 months ago (2013-08-14 06:08:55 UTC) #11
Mike West
The latest patch adds 'ExceptionState::throwSecurityError', which accepts two strings: a sanitized string, and an unsanitized ...
7 years, 4 months ago (2013-08-14 12:52:20 UTC) #12
arv (Not doing code reviews)
Overall this looks like a good approach. A few minor issues. https://codereview.chromium.org/22829002/diff/27001/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt File LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt (right): ...
7 years, 4 months ago (2013-08-14 13:43:02 UTC) #13
Use mkwst_at_chromium.org plz.
Thank you, latest patchset addresses these comments. https://codereview.chromium.org/22829002/diff/27001/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt File LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt (right): https://codereview.chromium.org/22829002/diff/27001/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt#newcode8 LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt:8: This test ...
7 years, 4 months ago (2013-08-14 13:57:20 UTC) #14
arv (Not doing code reviews)
LGTM but please let Adam have a final look. https://codereview.chromium.org/22829002/diff/27001/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt File LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt (right): https://codereview.chromium.org/22829002/diff/27001/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt#newcode8 LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-uncaught-expected.txt:8: ...
7 years, 4 months ago (2013-08-14 15:14:09 UTC) #15
abarth-chromium
LGTM modulo the issue below. https://codereview.chromium.org/22829002/diff/39001/Source/core/dom/ErrorEvent.h File Source/core/dom/ErrorEvent.h (right): https://codereview.chromium.org/22829002/diff/39001/Source/core/dom/ErrorEvent.h#newcode69 Source/core/dom/ErrorEvent.h:69: const String& message() const ...
7 years, 4 months ago (2013-08-14 19:42:07 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mkwst@chromium.org/22829002/52001
7 years, 4 months ago (2013-08-15 12:41:53 UTC) #17
commit-bot: I haz the power
Change committed as 156151
7 years, 4 months ago (2013-08-15 12:42:24 UTC) #18
Use mkwst_at_chromium.org plz.
On 2013/08/15 12:42:24, I haz the power (commit-bot) wrote: > Change committed as 156151 Reverted ...
7 years, 4 months ago (2013-08-15 19:25:47 UTC) #19
Use mkwst_at_chromium.org plz.
7 years, 4 months ago (2013-08-15 19:27:22 UTC) #20
Message was sent while issue was closed.
On 2013/08/15 19:25:47, mkwst wrote:
> On 2013/08/15 12:42:24, I haz the power (commit-bot) wrote:
> > Change committed as 156151
> 
> Reverted here: https://codereview.chromium.org/22887017
> 
> Seeing renderer crashes on Windows, and only on Windows. *sigh*
>
http://build.chromium.org/p/chromium.webkit/builders/WebKit%2520Win7%2520%252...

Hrm. And these failures were visible on the win_layout bot here. I'm a bit
surprised that it landed with those failures. Ah well.

Powered by Google App Engine
This is Rietveld 408576698