QA
Senior LevelNode JS

How does the experimental Node.js Permission Model (--permission) sandbox file and process access?

❓ Interview Prompt: Explain Node.js Permission Model, `--permission` flag, `--allow-fs-read`, `--allow-fs-write`, `--allow-child-process`, and preventing supply chain attacks.

Node 20+ introduces an experimental Permission Model ('--permission') that restricts what resources the Node.js process can access at runtime:

Security Flags:

•
'--allow-fs-read=/tmp/': Restricts file reading to '/tmp/' directory.
•
'--allow-fs-write=/var/log/': Restricts file writing to log directory.
•
'--allow-child-process': Grants or revokes permission to spawn child processes.

Benefit: Prevents malicious compromised 'npm' dependencies from stealing SSH keys or reading '/etc/passwd'!

Code Implementation Example

bash
# Run Node.js with strict file reading permissions sandbox
node --permission --allow-fs-read=/var/www/app/ server.js
💡Running Node.js with the experimental Permission Model sandbox flags.
🎯 Interview Key Takeaway

Use the Node.js Permission Model (--permission) to sandbox process capabilities and defend against supply chain attacks.

#Permission Model#Security#Sandbox#Supply Chain#Senior
Back to all Node JS Questions→

More Node JS Interview Questions

Beginner LevelNode JS

How does the Node.js Event Loop work? Explain the 6 execution phases (Timers, Pending, Poll, Check, Close).

Beginner LevelNode JS

What does 'Single-Threaded, Event-Driven, Non-Blocking I/O' mean in Node.js?

Beginner LevelNode JS

What is the difference between process.nextTick() and setImmediate()?