nodejs / nodejs/node

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

Đang mở
#62,222 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

feature request permission
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.3k
Merge trung bình
4 ngày 2 giờ
Pull request đã merge (30 ngày)
283

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách xem xét hành vi hiện tại của --allow-worker, tài liệu về mô hình quyền và ngữ nghĩa tạo Worker. Xác định và xác thực cách một Worker sẽ kế thừa snapshot quyền của tiến trình cha, bao gồm Breaking Change được đề xuất hoặc phương án thay thế --allow-inherit-worker; được xem là hoàn tất khi hành vi và lựa chọn về khả năng tương thích được ghi lại trong tài liệu và được kiểm thử.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, nodejs
Lĩnh vực
security
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.