@@ -106,8 +106,8 @@ format, where each line is an object with the following keys:
106106- ` value ` : the value that the permission was accessed with, or ` null ` if it was
107107 accessed with no value
108108
109- A schema for this can be found
110- [ here ] ( https://github.com/denoland/deno/blob/main/cli/schemas/permission-audit.v1.json ) .
109+ A schema for this can be found in
110+ [ permission-audit.v1.json ] ( https://github.com/denoland/deno/blob/main/cli/schemas/permission-audit.v1.json ) .
111111
112112In addition, this env var can be combined with the above-mentioned
113113` DENO_TRACE_PERMISSIONS ` , which then adds a new ` stack ` field to the entries
@@ -458,11 +458,11 @@ code from. This is true for both static and dynamic imports.
458458
459459If you want to dynamically import code, either using the ` import() ` or the
460460` new Worker() ` APIs, additional permissions need to be granted. Importing from
461- the local file system [ requires ` --allow-read ` ] ( #file-system-read- access ) , but
462- Deno also allows to import from ` http: ` and ` https: ` URLs. In such case you will
463- need to specify an explicit ` --allow-import ` flag:
461+ the local file system [ requires ` --allow-read ` ] ( #file-system-access ) , but Deno
462+ also allows to import from ` http: ` and ` https: ` URLs. In such case you will need
463+ to specify an explicit ` --allow-import ` flag:
464464
465- ```
465+ ``` sh
466466# allow importing code from `https://example.com`
467467$ deno run --allow-import=example.com main.ts
468468```
@@ -476,12 +476,12 @@ By default Deno allows importing sources from following hosts:
476476- ` raw.githubusercontent.com `
477477- ` gist.githubusercontent.com `
478478
479- ** Imports are only allowed using HTTPS**
479+ Imports are only allowed using HTTPS.
480480
481481This allow list is applied by default for static imports, and by default to
482482dynamic imports if the ` --allow-import ` flag is specified.
483483
484- ```
484+ ``` sh
485485# allow dynamically importing code from `https://deno.land`
486486$ deno run --allow-import main.ts
487487```
@@ -515,3 +515,63 @@ using all of these when executing arbitrary untrusted code:
515515- Use OS provided sandboxing mechanisms like ` chroot ` , ` cgroups ` , ` seccomp ` ,
516516 etc.
517517- Use a sandboxed environment like a VM or MicroVM (gVisor, Firecracker, etc).
518+
519+ ## Permission broker
520+
521+ For centralized and policy-driven permission decisions, Deno can delegate all
522+ permission checks to an external broker process. Enable this by setting the
523+ ` DENO_PERMISSION_BROKER_PATH ` environment variable to a path that Deno will use
524+ to connect to the broker:
525+
526+ - On Unix-like systems: a Unix domain socket path (for example,
527+ ` /tmp/deno-perm.sock ` ).
528+ - On Windows: a named pipe (for example, ` \\.\pipe\deno-perm-broker ` ).
529+
530+ When a permission broker is active:
531+
532+ - All ` --allow-* ` and ` --deny-* ` flags are ignored.
533+ - Interactive permission prompts are not shown (equivalent to non-interactive
534+ mode).
535+ - Every permission check is sent to the broker; the broker must reply with a
536+ decision for each request.
537+
538+ If anything goes wrong during brokering (for example: Deno cannot connect to the
539+ socket/pipe, messages are malformed, arrive out of order, IDs do not match, or
540+ the connection closes unexpectedly), Deno immediately terminates the process to
541+ preserve integrity and prevent permission escalation.
542+
543+ The request/response message shapes are versioned and defined by JSON Schemas:
544+
545+ - Request schema:
546+ [ permission-broker-request.v1.json] ( https://github.com/denoland/deno/blob/main/cli/schemas/permission-broker-request.v1.json )
547+ - Response schema:
548+ [ permission-broker-response.v1.json] ( https://github.com/denoland/deno/blob/main/cli/schemas/permission-broker-response.v1.json )
549+
550+ Each request contains a version (` v ` ), the Deno process ID (` pid ` ), a unique
551+ monotonic request ` id ` , a timestamp (` datetime ` , RFC 3339), the ` permission `
552+ name, and an optional ` value ` depending on permission type. The response must
553+ echo the ` id ` and include a ` result ` of either ` "grant" ` or ` "deny" ` . When
554+ denied, a human-readable ` reason ` may be included.
555+
556+ Example message flow:
557+
558+ ``` text
559+ -> req {"v":1,"pid":10234,"id":1,"datetime":"2025-01-01T00:00:00.000Z","permission":"read","value":"./run/permission_broker/scratch.txt"}
560+ <- res {"id":1,"result":"grant"}
561+ -> req {"v":1,"pid":10234,"id":2,"datetime":"2025-01-01T00:00:01.000Z","permission":"read","value":"./run/permission_broker/scratch.txt"}
562+ <- res {"id":2,"result":"grant"}
563+ -> req {"v":1,"pid":10234,"id":3,"datetime":"2025-01-01T00:00:02.000Z","permission":"read","value":"./run/permission_broker/log.txt"}
564+ <- res {"id":3,"result":"grant"}
565+ -> req {"v":1,"pid":10234,"id":4,"datetime":"2025-01-01T00:00:03.000Z","permission":"write","value":"./run/permission_broker/log.txt"}
566+ <- res {"id":4,"result":"grant"}
567+ -> req {"v":1,"pid":10234,"id":5,"datetime":"2025-01-01T00:00:04.000Z","permission":"env","value":null}
568+ <- res {"id":5,"result":"deny","reason":"Environment access is denied."}
569+ ```
570+
571+ :::caution Advanced use only
572+
573+ Using a permission broker changes Deno’s decision authority: CLI flags and
574+ prompts no longer apply. Ensure your broker process is resilient, audited, and
575+ available before enabling ` DENO_PERMISSION_BROKER_PATH ` .
576+
577+ :::
0 commit comments