@@ -269,6 +269,53 @@ Examples can be found in the [File System Permissions][] documentation.
269269
270270Relative paths are NOT supported through the CLI flag.
271271
272+ ### ` --allow-wasi `
273+
274+ <!-- YAML
275+ added: REPLACEME
276+ -->
277+
278+ > Stability: 1.1 - Active development
279+
280+ When using the [ Permission Model] [ ] , the process will not be capable of creating
281+ any WASI instances by default.
282+ For security reasons, the call will throw an ` ERR_ACCESS_DENIED ` unless the
283+ user explicitly passes the flag ` --allow-wasi ` in the main Node.js process.
284+
285+ Example:
286+
287+ ``` js
288+ const { WASI } = require (' node:wasi' );
289+ // Attempt to bypass the permission
290+ new WASI ({
291+ version: ' preview1' ,
292+ // Attempt to mount the whole filesystem
293+ preopens: {
294+ ' /' : ' /' ,
295+ },
296+ });
297+ ```
298+
299+ ``` console
300+ $ node --experimental-permission --allow-fs-read=* index.js
301+ node:wasi:99
302+ const wrap = new _WASI(args, env, preopens, stdio);
303+ ^
304+
305+ Error: Access to this API has been restricted
306+ at new WASI (node:wasi:99:18)
307+ at Object.<anonymous> (/home/index.js:3:1)
308+ at Module._compile (node:internal/modules/cjs/loader:1476:14)
309+ at Module._extensions..js (node:internal/modules/cjs/loader:1555:10)
310+ at Module.load (node:internal/modules/cjs/loader:1288:32)
311+ at Module._load (node:internal/modules/cjs/loader:1104:12)
312+ at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:191:14)
313+ at node:internal/main/run_main_module:30:49 {
314+ code: 'ERR_ACCESS_DENIED',
315+ permission: 'WASI',
316+ }
317+ ```
318+
272319### ` --allow-worker `
273320
274321<!-- YAML
@@ -925,6 +972,7 @@ following permissions are restricted:
925972 [ ` --allow-fs-read ` ] [ ] , [ ` --allow-fs-write ` ] [ ] flags
926973* Child Process - manageable through [ ` --allow-child-process ` ] [ ] flag
927974* Worker Threads - manageable through [ ` --allow-worker ` ] [ ] flag
975+ * WASI - manageable through [ ` --allow-wasi ` ] [ ] flag
928976
929977### ` --experimental-require-module `
930978
@@ -2738,6 +2786,7 @@ one is included in the list below.
27382786* ` --allow-child-process `
27392787* ` --allow-fs-read `
27402788* ` --allow-fs-write `
2789+ * ` --allow-wasi `
27412790* ` --allow-worker `
27422791* ` --conditions ` , ` -C `
27432792* ` --diagnostic-dir `
@@ -3293,6 +3342,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
32933342[ `--allow-child-process` ] : #--allow-child-process
32943343[ `--allow-fs-read` ] : #--allow-fs-read
32953344[ `--allow-fs-write` ] : #--allow-fs-write
3345+ [ `--allow-wasi` ] : #--allow-wasi
32963346[ `--allow-worker` ] : #--allow-worker
32973347[ `--build-snapshot` ] : #--build-snapshot
32983348[ `--cpu-prof-dir` ] : #--cpu-prof-dir
0 commit comments