Skip to content

Commit 74bb4ba

Browse files
committed
Add section about Buffer global
1 parent aaf2bb2 commit 74bb4ba

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docs/tutorial/security.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ things on top of Electron. Pull requests and contributions supporting this
3636
effort are always very welcome.
3737

3838
## Ignoring Above Advice
39+
3940
A security issue exists whenever you receive code from a remote destination and
4041
execute it locally. As an example, consider a remote website being displayed
4142
inside a browser window. If an attacker somehow manages to change said content
@@ -49,6 +50,7 @@ your application) to execute Node code. To display remote content, use the
4950
`webview` tag and make sure to disable the `nodeIntegration`.
5051

5152
#### Checklist
53+
5254
This is not bulletproof, but at the least, you should attempt the following:
5355

5456
* Only display secure (https) content
@@ -71,3 +73,22 @@ This is not bulletproof, but at the least, you should attempt the following:
7173

7274
Again, this list merely minimizes the risk, it does not remove it. If your goal
7375
is to display a website, a browser will be a more secure option.
76+
77+
## Buffer Global
78+
79+
Node's [Buffer](https://nodejs.org/api/buffer.html) class is currently available
80+
as a global even when `nodeIntegration` is set to `false`. You can delete
81+
this in your app by doing the following in your `preload` script:
82+
83+
```js
84+
delete global.Buffer
85+
```
86+
87+
Deleting it may break Node modules used in your preload script and app since
88+
many libraries expect it to be a global instead of requiring it directly via:
89+
90+
```js
91+
const {Buffer} = require('buffer')
92+
```
93+
94+
The `Buffer` global may be removed in future major versions of Electron.

0 commit comments

Comments
 (0)