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
Enable permission model and allow file reads
node --permission --allow-fs-read=./config app.js

# Run with restricted permissions and controlled file access.

Allow writes to a path
node --permission --allow-fs-write=./tmp app.js

# Permit writing only to a chosen directory.

Allow outbound network access
node --permission --allow-net=api.example.com app.js

# Permit network access under the permission model.

Allow child processes
node --permission --allow-child-process app.js

# Permit spawning subprocesses.

Disallow eval and string code generation
node --disallow-code-generation-from-strings app.js

# Block code generation from strings.

Enable FIPS mode
node --enable-fips app.js

# Start Node with FIPS-compliant crypto if supported.

Recommended next

No recommendations yet.