-
-
Notifications
You must be signed in to change notification settings - Fork 35k
Description
What is the problem this feature will solve?
The current Permission Model (--allow-fs-read, --allow-fs-write, --allow-child-process, --allow-worker, --experimental-permission) is all-or-nothing at startup. You declare the full set of permissions when launching the process, and they remain fixed for its entire lifetime.
This makes it impossible to implement a common and well-established security pattern: start with the permissions you need for initialization, then drop the ones you no longer need before entering the main event loop.
Real-world Node.js applications routinely need broad permissions at startup (reading config files, loading TLS certificates, binding to privileged ports, spawning setup workers) but then operate in a much narrower scope for the rest of their lifetime. Today, there is no way to tighten the permission boundary after initialization.
What is the feature you are proposing to solve the problem?
const fs = require('node:fs');
// Startup: read config and certs (needs broad fs read)
const config = JSON.parse(fs.readFileSync('/etc/myapp/config.json', 'utf8'));
const cert = fs.readFileSync(config.tlsCertPath);
const key = fs.readFileSync(config.tlsKeyPath);
// Drop permissions we no longer need
process.permission.drop('fs.read', '/etc/myapp');
process.permission.drop('child');
process.permission.drop('worker');
// From here on, the process can no longer read /etc/myapp,
// spawn child processes, or create workers.
// Any attempt to do so throws ERR_ACCESS_DENIED.A drop() call removes the specified permission from the internal allow-list. It cannot be reversed through process.permission or any other Node.js API. This narrows the set of resources reachable through standard Node.js APIs (fs, child_process, net, etc.), which is where path traversal and similar attacks operate.
As with the rest of the Permission Model, drop() is not a hard process-level security boundary. It does not protect against malicious code with arbitrary V8 access that bypasses Node.js APIs entirely (see Security model).
What alternatives have you considered?
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status