hostnet: a port-0 bind can collide with another listener's guest port under the listener redirect
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 70/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
- 領域
- networking
調査の方向性
Start with the port-0 bind branch and the implicit-bind None branch in src/hostnet.rs, then read guest_port_taken and bind_at_redirect. Reproduce the collision using the issue's two-socket sequence with redirect enabled and port 50000 allowed. Done when the second listener cannot acquire guest port 50000 and both listeners remain addressable or the bind returns EADDRINUSE.
索引モデルが issue の本文から書いたものです。
説明
Follow-up from Copilot's review on #291 (comment 2), which wasn't addressed before merge.
Problem
Under the listener redirect, a listener bound to a non-zero guest port G is assigned a different host port at listen (via bind_at_redirect), so host port G stays free. A later bind(0.0.0.0:0) can then be handed host port G by the OS, giving it guest port G too. Both sockets then report the same guest port, and listen_addr(G) (src/hostnet.rs:980-994) resolves by min_by_key(fd) and exposes only one — the other guest listener becomes unaddressable by the embedder.
The non-zero-port bind path checks guest_port_taken (src/hostnet.rs:662), but the port-0 branch (src/hostnet.rs:655-660) and the implicit-bind path in redirect_listener's None branch (src/hostnet.rs:709) do not.
Severity
Low. Not a security bypass — both sockets sit at the redirect address; nothing is exposed on an unredirected address. It is a bookkeeping/correctness defect. It only triggers when an allowed guest listen port falls in the host ephemeral range (Linux 32768–60999) and the OS picks it — unlikely for 80/443/8080, realistic for high-numbered ports common in test harnesses.
Repro
Redirect on, listen_ports allow 50000.
bind(a, 0.0.0.0:50000); listen(a)→ host port e.g. 37000, guest port 50000.bind(b, 0.0.0.0:0)→ OS assigns host port 50000 →bguest port 50000.getsockname(a) == getsockname(b) == 0.0.0.0:50000; afterlisten(b),listen_addr(50000)returns onlya, sob's listener is unreachable.
Suggested fix
In the port-0 branch (and the None branch at :709), after bind_at_redirect returns the port, call guest_port_taken(fd, port); on collision, rebind the host socket (recreate to avoid leaving it partially bound) and retry for a fresh port, or return EADDRINUSE.
- 主要言語
- Rust
- スター
- 77
- フォーク
- 14
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 27
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hyperlight-dev/hyperlight-unikraft のほかの issue
-
dependencies
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
hyperlight-dev/hyperlight-unikraft#136 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
ci/nightly
難易度 4/5 3〜5日 初心者へのやさしさ 53/100
hyperlight-dev/hyperlight-unikraft#306 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ci/nightly
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
hyperlight-dev/hyperlight-unikraft#305 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ci/nightly
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
hyperlight-dev/hyperlight-unikraft#304 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
hluk run: non-UTF-8 bytes in guest stdout reach the host as U+FFFD対応中かも @enilsen16 が今日担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
hyperlight-dev/hyperlight-unikraft#293 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
hyperlight-dev/hyperlight-unikraft の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
jelmer/buildlog-consultant#364 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
solutionscay/skiff#310 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
valkey-io/valkey-large-object#222 ·
メンテナーはふだん 1 日以内に返信
-
bug user-priority/P1
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信