Skip to content

Instantly share code, notes, and snippets.

@matt-
Last active August 23, 2018 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-/d331de3ca08fe4b850c7c23f3869309f to your computer and use it in GitHub Desktop.
Save matt-/d331de3ca08fe4b850c7c23f3869309f to your computer and use it in GitHub Desktop.
CVE-2018-15685
mainWindow.webContents.on('new-window', e => e.preventDefault())
const enforceInheritance = (topWebContents) => {
const handle = (webContents) => {
webContents.on('new-window', (event, url, frameName, disposition, options) => {
if (!options.webPreferences) {
options.webPreferences = {}
}
Object.assign(options.webPreferences, topWebContents.getLastWebPreferences())
if (options.webContents) {
handle(options.webContents)
}
})
}
handle(topWebContents)
}
enforceInheritance(mainWindow.webContents)
open('about:blank').open('data:text/html,<script>document.write(process.cwd())</script>')
win.webPreferences = {
allowRunningInsecureContent: false,
contextIsolation: true,
nodeIntegration: false,
nativeWindowOpen: true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment