hostnet: a port-0 bind can collide with another listener's guest port under the listener redirect
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 70/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- networking
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Rust
- Star
- 77
- Fork
- 14
- Merge trung bình
- 1 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 27
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của hyperlight-dev/hyperlight-unikraft
-
dependencies
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
hyperlight-dev/hyperlight-unikraft#136 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ci/nightly
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 53/100
hyperlight-dev/hyperlight-unikraft#306 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ci/nightly
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
hyperlight-dev/hyperlight-unikraft#305 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ci/nightly
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
hyperlight-dev/hyperlight-unikraft#304 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
hluk run: non-UTF-8 bytes in guest stdout reach the host as U+FFFDCó thể đã có người làm @enilsen16 đã nhận hôm nay. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 78/100
hyperlight-dev/hyperlight-unikraft#293 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của hyperlight-dev/hyperlight-unikraft
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jelmer/buildlog-consultant#364 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
solutionscay/skiff#310 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
valkey-io/valkey-large-object#222 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[优化]数据库表清单这个地方希望增加一个Ctrl+A全选的功能Đang mởbug user-priority/P1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày