Skip to content

Commit 40ac3e3

Browse files
chore: update ref to docs (🤖) (#891)
Co-authored-by: electron-website-docs-updater[bot] <166660481+electron-website-docs-updater[bot]@users.noreply.github.com>
1 parent 37bdf21 commit 40ac3e3

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

‎docs/latest/.sha‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5e29e21a6019d5e222f8e67c7b5f7b51538b0125
1+
d14320748df1c868437b413083846302660c5804

‎docs/latest/api/structures/web-preferences.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ hide_title: false
2828
associated with the window, making it compatible with the Chromium
2929
OS-level sandbox and disabling the Node.js engine. This is not the same as
3030
the `nodeIntegration` option and the APIs available to the preload script
31-
are more limited. Read more about the option [here](../../tutorial/sandbox.md).
31+
are more limited. Default is `true` since Electron 20. The sandbox will
32+
automatically be disabled when `nodeIntegration` is set to `true`.
33+
Read more about the option [here](../../tutorial/sandbox.md).
3234
* `session` [Session](../session.md#class-session) (optional) - Sets the session used by the
3335
page. Instead of passing the Session object directly, you can also choose to
3436
use the `partition` option instead, which accepts a partition string. When

‎docs/latest/tutorial/sandbox.md‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ the GPU service and the network service.
2020
See Chromium's [Sandbox design document][sandbox] for more information.
2121

2222
Starting from Electron 20, the sandbox is enabled for renderer processes without any
23-
further configuration. If you want to disable the sandbox for a process, see the
23+
further configuration.
24+
25+
Sandboxing is tied to Node.js integration. _Enabling Node.js integration_ for a
26+
renderer process by setting `nodeIntegration: true` _disables the sandbox_ for the
27+
process.
28+
29+
If you want to disable the sandbox for a process, see the
2430
[Disabling the sandbox for a single process](#disabling-the-sandbox-for-a-single-process)
2531
section.
2632

@@ -105,7 +111,8 @@ app.whenReady().then(() => {
105111
```
106112

107113
Sandboxing is also disabled whenever Node.js integration is enabled in the renderer.
108-
This can be done through the BrowserWindow constructor with the `nodeIntegration: true` flag.
114+
This can be done through the BrowserWindow constructor with the `nodeIntegration: true` flag
115+
or by providing the respective HTML boolean attribute for a `webview`.
109116

110117
```js title='main.js'
111118
app.whenReady().then(() => {
@@ -118,6 +125,10 @@ app.whenReady().then(() => {
118125
})
119126
```
120127

128+
```html title='index.html (Renderer Process)'
129+
<webview nodeIntegration src="page.html"></webview>
130+
```
131+
121132
### Enabling the sandbox globally
122133

123134
If you want to force sandboxing for all renderers, you can also use the

‎docs/latest/tutorial/security.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ to enable this behavior.
254254
Even when `nodeIntegration: false` is used, to truly enforce strong isolation
255255
and prevent the use of Node primitives `contextIsolation` **must** also be used.
256256

257+
Beware that _disabling context isolation_ for a renderer process by setting
258+
`nodeIntegration: true` _also disables process sandboxing_ for that process.
259+
See section below.
260+
257261
:::info
258262

259263
For more information on what `contextIsolation` is and how to enable it please
@@ -263,6 +267,18 @@ see our dedicated [Context Isolation](context-isolation.md) document.
263267

264268
### 4. Enable process sandboxing
265269

270+
:::info
271+
272+
This recommendation is the default behavior in Electron since 20.0.0.
273+
274+
Additionally, process sandboxing can be enforced for all renderer processes
275+
application wide: [Enabling the sandbox globally](sandbox.md#enabling-the-sandbox-globally)
276+
277+
_Disabling context isolation_ (see above) _also disables process sandboxing_,
278+
regardless of the default, `sandbox: false` or globally enabled sandboxing!
279+
280+
:::
281+
266282
[Sandboxing](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/design/sandbox.md)
267283
is a Chromium feature that uses the operating system to
268284
significantly limit what renderer processes have access to. You should enable

0 commit comments

Comments
 (0)