From 771266f5783dca3f23ad04867cf6c81b4cbdfb31 Mon Sep 17 00:00:00 2001 From: TheGoddessInari Date: Thu, 23 Aug 2018 22:34:38 -0700 Subject: [PATCH] Ensure that no webviews can be created with nodeIntegration. --- electron/main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/electron/main.js b/electron/main.js index b99dc415..bae9e9e5 100644 --- a/electron/main.js +++ b/electron/main.js @@ -325,7 +325,6 @@ const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => { if (shouldQuit) { app.quit(); - return; } // Code for downloading images as temporal files @@ -471,3 +470,11 @@ app.on('activate', function () { app.on('before-quit', function () { isQuitting = true; }); + +// Prevent the ability to create webview with nodeIntegration. +app.on('web-contents-created', (event, contents) => { + contents.on('will-attach-webview', (event, webPreferences, params) => { + // Always prevent node integration + webPreferences.nodeIntegration = false; + }); +});