@@ -357,6 +357,176 @@ Error: Access to this API has been restricted
357
357
}
358
358
```
359
359
360
+ ### ` --allow-net-tcp-in `
361
+
362
+ <!-- YAML
363
+ added: REPLACEME
364
+ -->
365
+
366
+ > Stability: 1.1 - Active development
367
+
368
+ When using the [ Permission Model] [ ] , the process will not be able to bind to any
369
+ ip or port by default. Attempts to do so will throw an ` ERR_ACCESS_DENIED ` unless
370
+ the user explicitly passes the ` --allow-net-tcp-in ` flag when starting Node.js.
371
+
372
+ The valid arguments for the ` --allow-net-tcp-in ` flag are:
373
+
374
+ * ` * ` - To allow all ` bind ` operations.
375
+ * Multiple addresses can be allowed using multiple ` --allow-net-tcp-in ` flags.
376
+ Example ` --allow-net-tcp-in=127.0.0.1:8080 --allow-net-tcp-in=127.0.0.1:9090 `
377
+
378
+ Example:
379
+
380
+ ``` js
381
+ const net = require (' node:net' );
382
+ net .createServer ().listen (9297 , ' 127.0.0.1' )
383
+ ```
384
+
385
+ ``` console
386
+ $ node --experimental-permission --allow-fs-read=./index.js index.js
387
+ node:net:1840
388
+ err = handle.bind(address, port);
389
+ ^
390
+
391
+ Error: Access to this API has been restricted
392
+ at createServerHandle (node:net:1840:20)
393
+ at Server.setupListenHandle [as _listen2] (node:net:1879:14)
394
+ at listenInCluster (node:net:1961:12)
395
+ at doListen (node:net:2135:7)
396
+ at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
397
+ code: 'ERR_ACCESS_DENIED',
398
+ permission: 'NetTCPIn',
399
+ resource: '127.0.0.1/9297'
400
+ }
401
+ ```
402
+
403
+ ### ` --allow-net-tcp-out `
404
+
405
+ <!-- YAML
406
+ added: REPLACEME
407
+ -->
408
+
409
+ > Stability: 1.1 - Active development
410
+
411
+ When using the [ Permission Model] [ ] , the process will not be able to connect to any
412
+ ip or port by default. Attempts to do so will throw an ` ERR_ACCESS_DENIED ` unless
413
+ the user explicitly passes the ` --allow-net-tcp-out ` flag when starting Node.js.
414
+
415
+ The valid arguments for the ` --allow-net-tcp-out ` flag are:
416
+
417
+ * ` * ` - To allow all ` connect ` operations.
418
+ * Multiple addresses can be allowed using multiple ` --allow-net-tcp-out ` flags.
419
+ Example ` --allow-net-tcp-out=127.0.0.1:8080 --allow-net-tcp-out=127.0.0.1:9090 `
420
+
421
+ Example:
422
+
423
+ ``` js
424
+ const net = require (' node:net' );
425
+ net .connect (9297 , ' 127.0.0.1' );
426
+ ```
427
+
428
+ ``` console
429
+ $ node --experimental-permission --allow-fs-read=./index.js index.js
430
+ node:net:1075
431
+ err = self._handle.connect(req, address, port);
432
+ ^
433
+
434
+ Error: Access to this API has been restricted
435
+ at internalConnect (node:net:1075:26)
436
+ at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
437
+ at node:net:1324:9
438
+ at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
439
+ code: 'ERR_ACCESS_DENIED',
440
+ permission: 'NetTCPOut',
441
+ resource: '127.0.0.1/9297'
442
+ }
443
+
444
+ ```
445
+
446
+ ### ` --allow-net-udp-in `
447
+
448
+ <!-- YAML
449
+ added: REPLACEME
450
+ -->
451
+
452
+ > Stability: 1.1 - Active development
453
+
454
+ When using the [ Permission Model] [ ] , the process will not be able to bind to any
455
+ ip or port by default. Attempts to do so will throw an ` ERR_ACCESS_DENIED ` unless
456
+ the user explicitly passes the ` --allow-net-udp-in ` flag when starting Node.js.
457
+
458
+ The valid arguments for the ` --allow-net-udp-in ` flag are:
459
+
460
+ * ` * ` - To allow all ` bind ` operations.
461
+ * Multiple addresses can be allowed using multiple ` --allow-net-udp-in ` flags.
462
+ Example ` --allow-net-udp-in=127.0.0.1:8080 --allow-net-udp-in=127.0.0.1:9090 `
463
+
464
+ Example:
465
+
466
+ ``` js
467
+ const dgram = require (' node:dgram' );
468
+ dgram .createSocket (' udp4' ).bind (9000 , ' 127.0.0.1' )
469
+ ```
470
+
471
+ ``` console
472
+ $ node --experimental-permission --allow-fs-read=./index.js index.js
473
+ node:dgram:364
474
+ const err = state.handle.bind(ip, port || 0, flags);
475
+ ^
476
+
477
+ Error: Access to this API has been restricted
478
+ at node:dgram:364:32
479
+ at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
480
+ code: 'ERR_ACCESS_DENIED',
481
+ permission: 'NetUDPIn',
482
+ resource: '127.0.0.1/9297'
483
+ }
484
+ ```
485
+
486
+ ### ` --allow-net-udp-out `
487
+
488
+ <!-- YAML
489
+ added: REPLACEME
490
+ -->
491
+
492
+ > Stability: 1.1 - Active development
493
+
494
+ When using the [ Permission Model] [ ] , the process will not be able to connect to any
495
+ ip or port by default. Attempts to do so will throw an ` ERR_ACCESS_DENIED ` unless
496
+ the user explicitly passes the ` --allow-net-udp-out ` flag when starting Node.js.
497
+
498
+ The valid arguments for the ` --allow-net-udp-out ` flag are:
499
+
500
+ * ` * ` - To allow all ` connect ` operations.
501
+ * Multiple addresses can be allowed using multiple ` --allow-net-udp-out ` flags.
502
+ Example ` --allow-net-udp-out=127.0.0.1:8080 --allow-net-udp-out=127.0.0.1:9090 `
503
+
504
+ Example:
505
+
506
+ ``` js
507
+ const dgram = require (' node:dgram' );
508
+ dgram .createSocket (' udp4' ).bind (8000 , ' 127.0.0.1' , function () {
509
+ this .connect (9001 , ' 127.0.0.1' )
510
+ });
511
+ ```
512
+
513
+ ``` console
514
+ $ node --experimental-permission --allow-net-udp-in=127.0.0.1/8000 --allow-fs-read=./index.js index.js
515
+ node:dgram:433
516
+ const err = state.handle.connect(ip, port);
517
+ ^
518
+
519
+ Error: Access to this API has been restricted
520
+ at doConnect (node:dgram:433:30)
521
+ at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
522
+ at afterDns (node:dgram:416:5)
523
+ at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
524
+ code: 'ERR_ACCESS_DENIED',
525
+ permission: 'NetUDPOut',
526
+ resource: '127.0.0.1/9001'
527
+ }
528
+ ```
529
+
360
530
### ` --build-snapshot `
361
531
362
532
<!-- YAML
@@ -1012,6 +1182,8 @@ following permissions are restricted:
1012
1182
* Child Process - manageable through [ ` --allow-child-process ` ] [ ] flag
1013
1183
* Worker Threads - manageable through [ ` --allow-worker ` ] [ ] flag
1014
1184
* WASI - manageable through [ ` --allow-wasi ` ] [ ] flag
1185
+ * Net - manageable through [ ` --allow-net-tcp-in ` ] [ ] , [ ` --allow-net-tcp-out ` ] [ ] ,
1186
+ [ ` --allow-net-udp-in ` ] [ ] and [ ` --allow-net-udp-out ` ] [ ] flags
1015
1187
1016
1188
### ` --experimental-require-module `
1017
1189
@@ -2804,6 +2976,10 @@ one is included in the list below.
2804
2976
* ` --allow-child-process `
2805
2977
* ` --allow-fs-read `
2806
2978
* ` --allow-fs-write `
2979
+ * ` --allow-net-tcp-in `
2980
+ * ` --allow-net-tcp-out `
2981
+ * ` --allow-net-udp-in `
2982
+ * ` --allow-net-udp-out `
2807
2983
* ` --allow-wasi `
2808
2984
* ` --allow-worker `
2809
2985
* ` --conditions ` , ` -C `
@@ -3356,6 +3532,10 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
3356
3532
[ `--allow-child-process` ] : #--allow-child-process
3357
3533
[ `--allow-fs-read` ] : #--allow-fs-read
3358
3534
[ `--allow-fs-write` ] : #--allow-fs-write
3535
+ [ `--allow-net-tcp-in` ] : #--allow-net-tcp-in
3536
+ [ `--allow-net-tcp-out` ] : #--allow-net-tcp-out
3537
+ [ `--allow-net-udp-in` ] : #--allow-net-udp-in
3538
+ [ `--allow-net-udp-out` ] : #--allow-net-udp-out
3359
3539
[ `--allow-wasi` ] : #--allow-wasi
3360
3540
[ `--allow-worker` ] : #--allow-worker
3361
3541
[ `--build-snapshot` ] : #--build-snapshot
0 commit comments