diff --git a/common.gypi b/common.gypi index f6002f9349121c..a3aeff7e03d480 100644 --- a/common.gypi +++ b/common.gypi @@ -27,7 +27,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.3', + 'v8_embedder_string': '-node.4', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/bootstrapper.cc b/deps/v8/src/bootstrapper.cc index 35e65e1053df0f..695200172d7b5f 100644 --- a/deps/v8/src/bootstrapper.cc +++ b/deps/v8/src/bootstrapper.cc @@ -5475,6 +5475,11 @@ Genesis::Genesis( if (!InstallDebuggerNatives()) return; } + if (FLAG_disallow_code_generation_from_strings) { + native_context()->set_allow_code_gen_from_strings( + isolate->heap()->false_value()); + } + ConfigureUtilsObject(context_type); // Check that the script context table is empty except for the 'this' binding. diff --git a/deps/v8/src/flag-definitions.h b/deps/v8/src/flag-definitions.h index 4ea5ed6da063a6..607f653cb649a7 100644 --- a/deps/v8/src/flag-definitions.h +++ b/deps/v8/src/flag-definitions.h @@ -766,6 +766,8 @@ DEFINE_BOOL(builtins_in_stack_traces, false, "show built-in functions in stack traces") DEFINE_BOOL(enable_experimental_builtins, true, "enable new csa-based experimental builtins") +DEFINE_BOOL(disallow_code_generation_from_strings, false, + "disallow eval and friends") // builtins.cc DEFINE_BOOL(allow_unsafe_function_constructor, false, diff --git a/deps/v8/test/mjsunit/disallow-codegen-from-strings.js b/deps/v8/test/mjsunit/disallow-codegen-from-strings.js new file mode 100644 index 00000000000000..30d1b967d5f128 --- /dev/null +++ b/deps/v8/test/mjsunit/disallow-codegen-from-strings.js @@ -0,0 +1,9 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --disallow-code-generation-from-strings + +assertThrows("1 + 1", EvalError); +assertThrows(() => eval("1 + 1"), EvalError); +assertThrows(() => Function("x", "return x + 1"), EvalError);