nodejs / nodejs/node

`net.Socket({ fd })` can abort the Node.js process when iterating invalid file descriptors

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

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

stale
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ả

Version

24.13.1

Platform
Linux KContainer 6.12.86+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.86-1 (2026-05-08) x86_64 x86_64 x86_64 GNU/Linux
Subsystem

net

What steps will reproduce the bug?

Hi,

I found a case where creating net.Socket instances with arbitrary file descriptors can abort the entire Node.js process.

const net = require('net');

let fd = 3;
while (fd < 1000) {
  try {
    const stream = new net.Socket({
      fd: fd,
      readable: false,
      writable: true
    });
    stream.on('error', function () {});
    stream.write('might crash');
  } catch (e) {
    // ignore and continue to next fd
    console.log('caught')
  }
  fd += 1;
}
How often does it reproduce? Is there a required condition?

Reproduces consistently on my system.

What is the expected behavior? Why is that the expected behavior?

Invalid or unsupported file descriptors passed to net.Socket({ fd }) should result in ordinary JS exceptions or socket errors, not process abort.

What do you see instead?

Some file descriptors are handled normally and throw JS exceptions that are caught successfully, but eventually Node aborts the process:

root@KContainer:~/git/run/cerebras/node/OPENAI/gpt5.1/filter/batch_3/cross_runtime/temp_deno/3604# node repro.cjs caught caught caught caught 
caught 
caught 
.... 
caught 
caught 
caught 
caught 
caught 
caught 
caught 
caught
Aborted

The abort bypasses JS exception handling entirely.

Additional information

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 với bản tái hiện JavaScript được cung cấp và đường đi net.Socket({ fd }) trên Linux, tập trung vào cách các descriptor không hợp lệ được xử lý trước stream.write(). Xác nhận rằng việc hủy bỏ có thể tái hiện, sau đó kiểm tra rằng các descriptor không hợp lệ hoặc không được hỗ trợ tạo ra các ngoại lệ JavaScript có thể bắt được hoặc lỗi socket mà không làm tiến trình kết thúc.

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, node.js
Lĩnh vực
networking
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/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.