@@ -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
@@ -927,6 +974,7 @@ following permissions are restricted:
927
974
[ ` --allow-fs-read ` ] [ ] , [ ` --allow-fs-write ` ] [ ] flags
928
975
* Child Process - manageable through [ ` --allow-child-process ` ] [ ] flag
929
976
* Worker Threads - manageable through [ ` --allow-worker ` ] [ ] flag
977
+ * WASI - manageable through [ ` --allow-wasi ` ] [ ] flag
930
978
931
979
### ` --experimental-require-module `
932
980
@@ -2693,6 +2741,7 @@ one is included in the list below.
2693
2741
* ` --allow-child-process `
2694
2742
* ` --allow-fs-read `
2695
2743
* ` --allow-fs-write `
2744
+ * ` --allow-wasi `
2696
2745
* ` --allow-worker `
2697
2746
* ` --conditions ` , ` -C `
2698
2747
* ` --diagnostic-dir `
@@ -3241,6 +3290,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
3241
3290
[ `--allow-child-process` ] : #--allow-child-process
3242
3291
[ `--allow-fs-read` ] : #--allow-fs-read
3243
3292
[ `--allow-fs-write` ] : #--allow-fs-write
3293
+ [ `--allow-wasi` ] : #--allow-wasi
3244
3294
[ `--allow-worker` ] : #--allow-worker
3245
3295
[ `--build-snapshot` ] : #--build-snapshot
3246
3296
[ `--cpu-prof-dir` ] : #--cpu-prof-dir
0 commit comments