@@ -269,6 +269,53 @@ Examples can be found in the [File System Permissions][] documentation.
269
269
270
270
Relative paths are NOT supported through the CLI flag.
271
271
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
+
272
319
### ` --allow-worker `
273
320
274
321
<!-- YAML
@@ -925,6 +972,7 @@ following permissions are restricted:
925
972
[ ` --allow-fs-read ` ] [ ] , [ ` --allow-fs-write ` ] [ ] flags
926
973
* Child Process - manageable through [ ` --allow-child-process ` ] [ ] flag
927
974
* Worker Threads - manageable through [ ` --allow-worker ` ] [ ] flag
975
+ * WASI - manageable through [ ` --allow-wasi ` ] [ ] flag
928
976
929
977
### ` --experimental-require-module `
930
978
@@ -2738,6 +2786,7 @@ one is included in the list below.
2738
2786
* ` --allow-child-process `
2739
2787
* ` --allow-fs-read `
2740
2788
* ` --allow-fs-write `
2789
+ * ` --allow-wasi `
2741
2790
* ` --allow-worker `
2742
2791
* ` --conditions ` , ` -C `
2743
2792
* ` --diagnostic-dir `
@@ -3293,6 +3342,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
3293
3342
[ `--allow-child-process` ] : #--allow-child-process
3294
3343
[ `--allow-fs-read` ] : #--allow-fs-read
3295
3344
[ `--allow-fs-write` ] : #--allow-fs-write
3345
+ [ `--allow-wasi` ] : #--allow-wasi
3296
3346
[ `--allow-worker` ] : #--allow-worker
3297
3347
[ `--build-snapshot` ] : #--build-snapshot
3298
3348
[ `--cpu-prof-dir` ] : #--cpu-prof-dir
0 commit comments