Back to results for “Advanced Node.js”
Node.js › Advanced Node.js

What are Node.js's experimental permission model flags, and what problem do they address?

Advanced

Answer

Introduced behind the --experimental-permission flag, Node's permission model lets you restrict what a running process is allowed to do -- for example, denying file system access outside specific directories, or blocking the ability to spawn child processes -- at the process level rather than relying purely on OS-level sandboxing or third-party libraries. This addresses supply-chain risk: if a compromised or malicious npm dependency tries to read arbitrary files or make unexpected network calls, a properly configured permission model can block it outright.
# Only allow file system read access to a specific directory
node --experimental-permission --allow-fs-read=/app/data server.js

# Deny child process spawning entirely
node --experimental-permission --allow-child-process=false server.js
Real-world example A company running third-party plugin code inside their Node.js platform enables the permission model to restrict plugins to read-only access within a designated sandbox directory, containing the blast radius if a malicious or buggy plugin is ever installed.

Common follow-ups: How mature and production-ready is this feature as of the current LTS release, given it's still experimental?;How does this compare to using a full OS-level sandbox like a container or a VM?