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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.cpp

Issue 2042743002: Sandbox detached iframes a bit more (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.cpp b/third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.cpp
index 3266b460f6b2b922111f0f54af636cead3cbecbb..7230fd47489ab190808e540940f2222835b1fe14 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.cpp
@@ -37,6 +37,8 @@
#include "bindings/core/v8/V8PerIsolateData.h"
#include "bindings/core/v8/V8ScriptRunner.h"
#include "bindings/core/v8/V8Window.h"
+#include "core/dom/Document.h"
+#include "core/frame/LocalDOMWindow.h"
namespace blink {
@@ -107,8 +109,20 @@ void V8WrapperInstantiationScope::securityCheck(v8::Isolate* isolate, v8::Local<
// If the context is different, we need to make sure that the current
// context has access to the creation context.
Frame* frame = toFrameIfNotDetached(contextForWrapper);
- if (!frame)
+ if (!frame) {
+ // Sandbox detached frames - they can't create cross origin objects.
+ LocalDOMWindow* callingWindow = currentDOMWindow(isolate);
+ DOMWindow* targetWindow = toDOMWindow(contextForWrapper);
+ if (callingWindow->document()->getSecurityOrigin()->canAccessCheckSuborigins(targetWindow->document()->getSecurityOrigin()))
jochen (gone - plz use gerrit) 2016/06/07 08:47:39 here ^^^
+ return;
+
+ // TODO(jochen): Currently, Location is the only object for which we can reach this code path. Should be generalized.
+ ExceptionState exceptionState(ExceptionState::ConstructionContext, "Location", contextForWrapper->Global(), isolate);
+ // We can't create a better message for a detached frame.
+ exceptionState.throwSecurityError(String(), String());
+ exceptionState.throwIfNeeded();
return;
+ }
const DOMWrapperWorld& currentWorld = DOMWrapperWorld::world(m_context);
RELEASE_ASSERT(currentWorld.worldId() == DOMWrapperWorld::world(contextForWrapper).worldId());
if (currentWorld.isMainWorld()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698