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

Unified Diff: src/runtime.cc

Issue 294073002: filter cross context eval (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 6 years, 7 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 | « src/generator.js ('k') | src/v8natives.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 1aaa3cd92a70b10d8521ffde464cec500aecd393..90c52833b92df07278b936b0c5a42341316f00c6 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -9784,6 +9784,21 @@ bool CodeGenerationFromStringsAllowed(Isolate* isolate,
}
+static Handle<JSFunction> FirstJSFunctionOnStack(Isolate* isolate) {
+ for (StackTraceFrameIterator it(isolate); !it.done(); it.Advance()) {
+ StackFrame* raw_frame = it.frame();
+ if (!raw_frame->is_java_script()) continue;
+ JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame);
+ List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
+ frame->Summarize(&frames);
+ for (int i = frames.length() - 1; i >= 0; i--) {
Toon Verwaest 2014/05/27 15:15:43 Why is this a for-loop? :)
dcarney 2014/05/27 15:45:11 originally, i was filtering stuff out
+ return frames[i].function();
+ }
+ }
+ return Handle<JSFunction>();
Toon Verwaest 2014/05/27 15:15:43 If you can return an empty handle, it should be a
+}
+
+
RUNTIME_FUNCTION(Runtime_CompileString) {
HandleScope scope(isolate);
ASSERT(args.length() == 2);
@@ -9793,6 +9808,14 @@ RUNTIME_FUNCTION(Runtime_CompileString) {
// Extract native context.
Handle<Context> context(isolate->context()->native_context());
+ // Filter cross security context calls.
+ {
+ Handle<JSFunction> fun = FirstJSFunctionOnStack(isolate);
+ if (fun.is_null() || !context->HasSameSecurityTokenAs(fun->context())) {
+ return isolate->heap()->undefined_value();
+ }
+ }
+
// Check if native context allows code generation from
// strings. Throw an exception if it doesn't.
if (context->allow_code_gen_from_strings()->IsFalse() &&
« no previous file with comments | « src/generator.js ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698