Skip to content

Commit

Permalink
docs: update nodeIntegration section for new defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak committed Apr 6, 2019
1 parent 235eea6 commit 5567775
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions docs/tutorial/security.md
Expand Up @@ -159,9 +159,11 @@ browserWindow.loadURL('https://example.com')
```


## 2) Disable Node.js Integration for Remote Content
## 2) Do not enable Node.js Integration for Remote Content

It is paramount that you disable Node.js integration in any renderer
_Recommendation is Electron's default_

It is paramount that you do not enable Node.js integration in any renderer
([`BrowserWindow`][browser-window], [`BrowserView`][browser-view], or
[`<webview>`][webview-tag]) that loads remote content. The goal is to limit the
powers you grant to remote content, thus making it dramatically more difficult
Expand All @@ -185,16 +187,20 @@ so-called "Remote Code Execution" (RCE) attack.

```js
// Bad
const mainWindow = new BrowserWindow()
const mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true
}
})

mainWindow.loadURL('https://example.com')
```

```js
// Good
const mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
preload: path.join(app.getAppPath(), 'preload.js')
}
})
Expand Down

0 comments on commit 5567775

Please sign in to comment.