Node.js CLI Security & Permissions

Node.js CLI security cheat sheets for the permission model, network and filesystem restrictions, eval hardening, and TLS/crypto settings.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Security and Permissions

Run Node with explicit access controls and safer defaults.

Enable permission model and allow file reads

Run with restricted permissions and controlled file access.

bashANYnodepermissionssecurity
bash
node --permission --allow-fs-read=./config app.js
Notes

Useful for defense-in-depth in local, CI, and service environments.

Allow writes to a path

Permit writing only to a chosen directory.

bashANYnodepermissionsfilesystem
bash
node --permission --allow-fs-write=./tmp app.js
Notes

Restricts write access under the permission model.

Allow outbound network access

Permit network access under the permission model.

bashANYnodepermissionsnetwork
bash
node --permission --allow-net=api.example.com app.js
Notes

Recent Node versions expose network permissions as part of the permission model.

Allow child processes

Permit spawning subprocesses.

bashANYnodepermissionschild-process
bash
node --permission --allow-child-process app.js
Notes

Needed when the program uses child_process under permission restrictions.

Disallow eval and string code generation

Block code generation from strings.

bashANYnodesecurityeval
bash
node --disallow-code-generation-from-strings app.js
Notes

Useful in security-sensitive environments to reduce reliance on eval-like behavior.

Enable FIPS mode

Start Node with FIPS-compliant crypto if supported.

bashANYnodefipscrypto
bash
node --enable-fips app.js
Notes

Requires a compatible Node and OpenSSL build.

Recommended next

No recommendations yet.