Skip to content

Commit

Permalink
Disable freezing V8 flags on initialization (#141)
Browse files Browse the repository at this point in the history
Node still changes flags after initializationg; either because tests
need to set their own flags (which V8 tests also still allow), or
because it's explicitly requested via the "v8.setFlagsFromString" method
that Node provides.
  • Loading branch information
backes authored and victorgomes committed Aug 11, 2022
1 parent 58c878c commit 680f678
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,11 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
// used in diagnostic reports.
per_process::cli_options->cmdline = *argv;

// Node provides a "v8.setFlagsFromString" method to dynamically change flags.
// Hence do not freeze flags when initializing V8. In a browser setting, this
// is security relevant, for Node it's less important.
V8::SetFlagsFromString("--no-freeze-flags-after-init");

#if defined(NODE_V8_OPTIONS)
// Should come before the call to V8::SetFlagsFromCommandLine()
// so the user can disable a flag --foo at run-time by passing
Expand Down
5 changes: 5 additions & 0 deletions test/cctest/node_test_fixture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ void NodeTestEnvironment::SetUp() {
#endif
cppgc::InitializeProcess(
NodeZeroIsolateTestFixture::platform->GetPageAllocator());

// Before initializing V8, disable the --freeze-flags-after-init flag, so
// individual tests can set their own flags.
v8::V8::SetFlagsFromString("--no-freeze-flags-after-init");

v8::V8::Initialize();
}

Expand Down

0 comments on commit 680f678

Please sign in to comment.