nodejs / nodejs/node

Permission Inheritance (`--allow-worker` inherits parent permissions)

Open
#62,222 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request permission
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

What is the problem this feature will solve?

Today, --allow-worker is an all-or-nothing escape hatch. The docs state this explicitly as a constraint: "The model does not inherit to a worker thread." This means any code running inside a worker can access the filesystem, spawn child processes, and do anything else without restriction, regardless of what the main thread was allowed to do.

This defeats the purpose of the permission model for any application that uses workers, which is most CPU-intensive Node.js applications.

What is the feature you are proposing to solve the problem?

When the main thread creates a Worker, the worker inherits a snapshot of the parent thread's permission state at the time of creation. The worker starts with exactly the same permissions as its parent — no more, no less.

// Main thread: started with --permission --allow-fs-read=/app --allow-worker
const { Worker } = require('node:worker_threads');
 
const worker = new Worker('./task.js');
// task.js runs with fs.read granted for /app only
// task.js cannot spawn child processes (parent couldn't either)
// task.js cannot read /etc, /home, or anything outside /app

This might be a breaking change. We could then add a --allow-inherit-worker to achieve the same.

What alternatives have you considered?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the current --allow-worker behavior, the permission model documentation, and Worker creation semantics. Define and validate how a worker should inherit the parent's permission snapshot, including the proposed breaking-change or --allow-inherit-worker alternative; done means the behavior and compatibility choice are documented and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.