OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 19 matching lines...) Expand all Loading... | |
30 | 30 |
31 #include "bindings/core/v8/V8DOMWrapper.h" | 31 #include "bindings/core/v8/V8DOMWrapper.h" |
32 | 32 |
33 #include "bindings/core/v8/V8Binding.h" | 33 #include "bindings/core/v8/V8Binding.h" |
34 #include "bindings/core/v8/V8Location.h" | 34 #include "bindings/core/v8/V8Location.h" |
35 #include "bindings/core/v8/V8ObjectConstructor.h" | 35 #include "bindings/core/v8/V8ObjectConstructor.h" |
36 #include "bindings/core/v8/V8PerContextData.h" | 36 #include "bindings/core/v8/V8PerContextData.h" |
37 #include "bindings/core/v8/V8PerIsolateData.h" | 37 #include "bindings/core/v8/V8PerIsolateData.h" |
38 #include "bindings/core/v8/V8ScriptRunner.h" | 38 #include "bindings/core/v8/V8ScriptRunner.h" |
39 #include "bindings/core/v8/V8Window.h" | 39 #include "bindings/core/v8/V8Window.h" |
40 #include "core/dom/Document.h" | |
41 #include "core/frame/LocalDOMWindow.h" | |
40 | 42 |
41 namespace blink { | 43 namespace blink { |
42 | 44 |
43 v8::Local<v8::Object> V8DOMWrapper::createWrapper(v8::Isolate* isolate, v8::Loca l<v8::Object> creationContext, const WrapperTypeInfo* type) | 45 v8::Local<v8::Object> V8DOMWrapper::createWrapper(v8::Isolate* isolate, v8::Loca l<v8::Object> creationContext, const WrapperTypeInfo* type) |
44 { | 46 { |
45 ASSERT(!type->equals(&V8Window::wrapperTypeInfo)); | 47 ASSERT(!type->equals(&V8Window::wrapperTypeInfo)); |
46 // According to https://html.spec.whatwg.org/multipage/browsers.html#securit y-location, | 48 // According to https://html.spec.whatwg.org/multipage/browsers.html#securit y-location, |
47 // cross-origin script access to a few properties of Location is allowed. | 49 // cross-origin script access to a few properties of Location is allowed. |
48 // Location already implements the necessary security checks. | 50 // Location already implements the necessary security checks. |
49 bool withSecurityCheck = !type->equals(&V8Location::wrapperTypeInfo); | 51 bool withSecurityCheck = !type->equals(&V8Location::wrapperTypeInfo); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 && untrustedWrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink; | 102 && untrustedWrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink; |
101 } | 103 } |
102 | 104 |
103 void V8WrapperInstantiationScope::securityCheck(v8::Isolate* isolate, v8::Local< v8::Context> contextForWrapper) | 105 void V8WrapperInstantiationScope::securityCheck(v8::Isolate* isolate, v8::Local< v8::Context> contextForWrapper) |
104 { | 106 { |
105 if (m_context.IsEmpty()) | 107 if (m_context.IsEmpty()) |
106 return; | 108 return; |
107 // If the context is different, we need to make sure that the current | 109 // If the context is different, we need to make sure that the current |
108 // context has access to the creation context. | 110 // context has access to the creation context. |
109 Frame* frame = toFrameIfNotDetached(contextForWrapper); | 111 Frame* frame = toFrameIfNotDetached(contextForWrapper); |
110 if (!frame) | 112 if (!frame) { |
113 // Sandbox detached frames - they can't create cross origin objects. | |
114 LocalDOMWindow* callingWindow = currentDOMWindow(isolate); | |
115 DOMWindow* targetWindow = toDOMWindow(contextForWrapper); | |
116 if (callingWindow->document()->getSecurityOrigin()->canAccessCheckSubori gins(targetWindow->document()->getSecurityOrigin())) | |
jochen (gone - plz use gerrit)
2016/06/07 08:47:39
here ^^^
| |
117 return; | |
118 | |
119 // TODO(jochen): Currently, Location is the only object for which we can reach this code path. Should be generalized. | |
120 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Loca tion", contextForWrapper->Global(), isolate); | |
121 // We can't create a better message for a detached frame. | |
122 exceptionState.throwSecurityError(String(), String()); | |
123 exceptionState.throwIfNeeded(); | |
111 return; | 124 return; |
125 } | |
112 const DOMWrapperWorld& currentWorld = DOMWrapperWorld::world(m_context); | 126 const DOMWrapperWorld& currentWorld = DOMWrapperWorld::world(m_context); |
113 RELEASE_ASSERT(currentWorld.worldId() == DOMWrapperWorld::world(contextForWr apper).worldId()); | 127 RELEASE_ASSERT(currentWorld.worldId() == DOMWrapperWorld::world(contextForWr apper).worldId()); |
114 if (currentWorld.isMainWorld()) { | 128 if (currentWorld.isMainWorld()) { |
115 RELEASE_ASSERT(BindingSecurity::shouldAllowAccessToFrame(isolate, curren tDOMWindow(isolate), frame, DoNotReportSecurityError)); | 129 RELEASE_ASSERT(BindingSecurity::shouldAllowAccessToFrame(isolate, curren tDOMWindow(isolate), frame, DoNotReportSecurityError)); |
116 } | 130 } |
117 } | 131 } |
118 | 132 |
119 void V8WrapperInstantiationScope::convertException() | 133 void V8WrapperInstantiationScope::convertException() |
120 { | 134 { |
121 v8::Isolate* isolate = m_context->GetIsolate(); | 135 v8::Isolate* isolate = m_context->GetIsolate(); |
122 // TODO(jochen): Currently, Location is the only object for which we can rea ch this code path. Should be generalized. | 136 // TODO(jochen): Currently, Location is the only object for which we can rea ch this code path. Should be generalized. |
123 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Location ", isolate->GetCurrentContext()->Global(), isolate); | 137 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Location ", isolate->GetCurrentContext()->Global(), isolate); |
124 LocalDOMWindow* callingWindow = currentDOMWindow(isolate); | 138 LocalDOMWindow* callingWindow = currentDOMWindow(isolate); |
125 DOMWindow* targetWindow = toDOMWindow(m_context); | 139 DOMWindow* targetWindow = toDOMWindow(m_context); |
126 exceptionState.throwSecurityError(targetWindow->sanitizedCrossDomainAccessEr rorMessage(callingWindow), targetWindow->crossDomainAccessErrorMessage(callingWi ndow)); | 140 exceptionState.throwSecurityError(targetWindow->sanitizedCrossDomainAccessEr rorMessage(callingWindow), targetWindow->crossDomainAccessErrorMessage(callingWi ndow)); |
127 exceptionState.throwIfNeeded(); | 141 exceptionState.throwIfNeeded(); |
128 } | 142 } |
129 | 143 |
130 } // namespace blink | 144 } // namespace blink |
OLD | NEW |