nodejs / nodejs/node

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

オープン
#63,308 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stale
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供された JavaScript の再現コードと Linux 上の net.Socket({ fd }) パスから始め、stream.write() の前に無効なディスクリプターがどのように処理されるかに注目してください。中断が再現可能であることを確認し、その後、無効またはサポートされていないディスクリプターによって、プロセスを終了させることなく捕捉可能な JavaScript 例外またはソケットエラーが発生することを検証してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
networking
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。