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

Unified Diff: extensions/renderer/v8_context_native_handler.cc

Issue 1231803002: extension: Checks the security token of the V8 context at GetModuleSystem(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a comment. Created 5 years, 5 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 | « extensions/renderer/v8_context_native_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/v8_context_native_handler.cc
diff --git a/extensions/renderer/v8_context_native_handler.cc b/extensions/renderer/v8_context_native_handler.cc
index ed915cc423f717a1a5fb6ce04b96947e613db787..086bc4fd2fa23da3ebd0d47ab1544bf508155020 100644
--- a/extensions/renderer/v8_context_native_handler.cc
+++ b/extensions/renderer/v8_context_native_handler.cc
@@ -14,7 +14,6 @@ namespace extensions {
V8ContextNativeHandler::V8ContextNativeHandler(ScriptContext* context,
Dispatcher* dispatcher)
: ObjectBackedNativeHandler(context),
- context_(context),
dispatcher_(dispatcher) {
RouteFunction("GetAvailability",
base::Bind(&V8ContextNativeHandler::GetAvailability,
@@ -33,7 +32,7 @@ void V8ContextNativeHandler::GetAvailability(
CHECK_EQ(args.Length(), 1);
v8::Isolate* isolate = args.GetIsolate();
std::string api_name = *v8::String::Utf8Value(args[0]);
- Feature::Availability availability = context_->GetAvailability(api_name);
+ Feature::Availability availability = context()->GetAvailability(api_name);
v8::Local<v8::Object> ret = v8::Object::New(isolate);
ret->Set(v8::String::NewFromUtf8(isolate, "is_available"),
@@ -51,6 +50,10 @@ void V8ContextNativeHandler::GetModuleSystem(
CHECK(args[0]->IsObject());
v8::Local<v8::Context> v8_context =
v8::Local<v8::Object>::Cast(args[0])->CreationContext();
+ // Returns undefined if it's a cross-domain access.
+ if (v8_context->GetSecurityToken() !=
+ args.GetIsolate()->GetCurrentContext()->GetSecurityToken())
jochen (gone - plz use gerrit) 2015/07/13 12:01:17 i'd rather not duplicate the security check logic,
+ return;
ScriptContext* context =
dispatcher_->script_context_set().GetByV8Context(v8_context);
args.GetReturnValue().Set(context->module_system()->NewInstance());
« no previous file with comments | « extensions/renderer/v8_context_native_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698