kewde / electron-sandbox-boilerplate

A simple example for a (more reasonably) secure electron application, by enabling the sandbox and forcing communication over IPC.
MIT License
73 stars 14 forks source link

Experimental feature: require = null in preload #5

Open kewde opened 6 years ago

kewde commented 6 years ago

I've added an experimental feature to the preload script that will set require() = null after it's done importing. Feedback? https://github.com/kewde/electron-sandbox-boilerplate/blob/401b293066aeb185741852f059cdf0a46e70f1bf/sandbox-preload-extended/electron/renderer/preload-extended.js#L13-L23

What I hope it will achieve: disallow the loading of other modules after this line..

kewde commented 6 years ago

This dereferences the code behind the require function, making it potentially eligible for garbage collection? The gc isn't automatically triggered tho, so something like this would be required. https://simonmcmanus.wordpress.com/2013/01/03/forcing-garbage-collection-with-node-js-and-v8/