@@ -267,6 +267,53 @@ Examples can be found in the [File System Permissions][] documentation.
267
267
268
268
Relative paths are NOT supported through the CLI flag.
269
269
270
+ ### ` --allow-wasi `
271
+
272
+ <!-- YAML
273
+ added: REPLACEME
274
+ -->
275
+
276
+ > Stability: 1.1 - Active development
277
+
278
+ When using the [ Permission Model] [ ] , the process will not be capable of creating
279
+ any WASI instances by default.
280
+ For security reasons, the call will throw an ` ERR_ACCESS_DENIED ` unless the
281
+ user explicitly passes the flag ` --allow-wasi ` in the main Node.js process.
282
+
283
+ Example:
284
+
285
+ ``` js
286
+ const { WASI } = require (' node:wasi' );
287
+ // Attempt to bypass the permission
288
+ new WASI ({
289
+ version: ' preview1' ,
290
+ // Attempt to mount the whole filesystem
291
+ preopens: {
292
+ ' /' : ' /' ,
293
+ },
294
+ });
295
+ ```
296
+
297
+ ``` console
298
+ $ node --experimental-permission --allow-fs-read=* index.js
299
+ node:wasi:99
300
+ const wrap = new _WASI(args, env, preopens, stdio);
301
+ ^
302
+
303
+ Error: Access to this API has been restricted
304
+ at new WASI (node:wasi:99:18)
305
+ at Object.<anonymous> (/home/index.js:3:1)
306
+ at Module._compile (node:internal/modules/cjs/loader:1476:14)
307
+ at Module._extensions..js (node:internal/modules/cjs/loader:1555:10)
308
+ at Module.load (node:internal/modules/cjs/loader:1288:32)
309
+ at Module._load (node:internal/modules/cjs/loader:1104:12)
310
+ at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:191:14)
311
+ at node:internal/main/run_main_module:30:49 {
312
+ code: 'ERR_ACCESS_DENIED',
313
+ permission: 'WASI',
314
+ }
315
+ ```
316
+
270
317
### ` --allow-worker `
271
318
272
319
<!-- YAML
@@ -895,6 +942,7 @@ following permissions are restricted:
895
942
[ ` --allow-fs-read ` ] [ ] , [ ` --allow-fs-write ` ] [ ] flags
896
943
* Child Process - manageable through [ ` --allow-child-process ` ] [ ] flag
897
944
* Worker Threads - manageable through [ ` --allow-worker ` ] [ ] flag
945
+ * WASI - manageable through [ ` --allow-wasi ` ] [ ] flag
898
946
899
947
### ` --experimental-policy `
900
948
@@ -2533,6 +2581,7 @@ one is included in the list below.
2533
2581
* ` --allow-child-process `
2534
2582
* ` --allow-fs-read `
2535
2583
* ` --allow-fs-write `
2584
+ * ` --allow-wasi `
2536
2585
* ` --allow-worker `
2537
2586
* ` --conditions ` , ` -C `
2538
2587
* ` --diagnostic-dir `
@@ -3040,6 +3089,7 @@ done
3040
3089
[ `--allow-child-process` ] : #--allow-child-process
3041
3090
[ `--allow-fs-read` ] : #--allow-fs-read
3042
3091
[ `--allow-fs-write` ] : #--allow-fs-write
3092
+ [ `--allow-wasi` ] : #--allow-wasi
3043
3093
[ `--allow-worker` ] : #--allow-worker
3044
3094
[ `--build-snapshot` ] : #--build-snapshot
3045
3095
[ `--cpu-prof-dir` ] : #--cpu-prof-dir
0 commit comments