Add RFC6761 section 6.3 support (*.localhost -> 127.0.0.1 / ::1)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 18/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- docker, kubernetes, linux, networking, rust
- Lĩnh vực
- networking
Hướng nghiên cứu
Start with PolicyDnsService::answer_query in crates/openshell-supervisor-network/src/policy_dns/mod.rs, where no loopback-name case exists before stage_observation runs, and with observation_eligible in the same file. The issue lists open design questions (AAAA behavior when policy_dns_ipv6_egress is disabled, whether the exact name localhost is included, and the shared classification location), so resolve those with maintainers first. Done means .localhost names return 127.0.0.1 or ::1 without allocating addresses or producing denials, with tests covering the excluded look-alike names.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
User Story
I use OpenShell to run sandboxed agent workloads on a remote machine.
Inside a sandbox I queried myapplication.localhost to reach a service listening in that same sandbox, and the name resolved to
198.18.0.4 instead of loopback, so I could not reach the service by name.
Services like Portless rely on this loopback resolver described in RFC6761 Section 6.3.
(Portless uses dynamically generated *.localhost domains)
Problem Statement
localhost resolves inside a sandbox only because the container runtime's /etc/hosts contains 127.0.0.1 localhost.
A name under .localhost is not in /etc/hosts, so the libc resolver sends it to the mediated policy DNS listener at 127.0.0.53. Policy DNS treats it as an unapproved external hostname: it stages a contract-free observation mapping from the synthetic 198.18.0.0/15 pool and returns that placeholder.
The placeholder is not loopback, so the client cannot reach an in-sandbox service; the following TCP attempt is denied and surfaced as a policy proposal for a destination no policy can usefully allow.
RFC6761 Section 6.3 reserves localhost. and every name under .localhost. and expects resolution APIs to return a loopback address without querying a resolver. Browsers implement this, which is why the same name works on the host.
Impact / Why This Matters
- Host/sandbox parity gap: the host browser and
systemd-resolvedresolveapp.localhostto127.0.0.1; the sandbox does not. Name-based local development inside a sandbox breaks. - Current workarounds are insufficient:
- Connecting to
127.0.0.1:<port>directly loses the hostname, so name-based virtual hosts, cookies, and multi-service setups on loopback cannot be expressed. - Editing
/etc/hostsis unavailable for Docker, Podman, and Kubernetes sandboxes because the runtime bind-mounts a generated file. Only the VM driver preserves a non-empty image-authored file.
- Connecting to
- Every
.localhostquery consumes a synthetic observation identity and produces a denial plus a proposal for a loopback destination. That is noise in telemetry and the policy advisor, and it can never be
satisfied by an endpoint rule. - Fail-closed quarantine turns these names into REFUSED, so even name resolution stops working once policy validation fails.
Proposed Design
Inside every sandbox, localhost and every name ending in a .localhost label resolve to 127.0.0.1, and to ::1 for AAAA queries when the runtime answers AAAA.
- Applies to the whole subtree, case-insensitively, with or without a trailing dot.
- Requires no policy rule, allocates no synthetic address, and sends no upstream query.
- Does not depend on
/etc/hosts; the relay answer is a fallback for images whose hosts file lacks loopback names. - These names stay outside policy: loopback traffic completes inside the sandbox and is not proxied, so the behavior adds no reach.
- Names that merely contain
localhost(mylocalhost,localhost.example.com,app.localhost.example.com) keep today's behavior.
No new command, flag, or configuration. Just make the existing workflow work:
openshell sandbox connect <sandbox>
getent hosts myapplication.localhost # 127.0.0.1
curl -v http://myapplication.localhost:8080/ # should connect to 127.0.0.1
Acceptance Criteria
- In a sandbox, getent hosts app.localhost returns 127.0.0.1 and curl http://app.localhost:/ reaches a service listening on sandbox loopback.
- LOCALHOST, app.localhost., and nested names such as a.b.localhost behave the same.
- AAAA queries return ::1 when the runtime answers AAAA, and stay suppressed when AAAA answers are disabled, so dual-stack clients fall back to A.
- These queries allocate no synthetic address, send no trusted-resolver query, and produce no denial or policy proposal.
- mylocalhost, localhost.example.com, and app.localhost.example.com are unaffected.
- localhost resolves even when the image's /etc/hosts lacks it.
- The behavior holds while the policy engine is fail-closed.
- Documented in the network rules docs.
Alternatives Considered
- Add the name as a policy endpoint. Policy DNS still resolves eligible names through the trusted upstream resolver, and allowed_ips only filters the returned addresses. A .localhost name is not
resolvable upstream, so the query fails. - Add the name to /etc/hosts. Docker, Podman, and Kubernetes replace that file with a runtime-generated one. The VM lane preserves a non-empty image-authored file, which makes the workaround
driver-specific and unavailable for ordinary local sandboxes. - Use host.openshell.internal / host.docker.internal. Those aliases point at the host, not at a service inside the sandbox.
- Use gateway service routing (*.openshell.localhost). That exposes a sandbox service to a host browser. It is the opposite direction and requires the gateway.
- Add a configuration switch. The only DNS-related driver configuration is policy_dns_ipv6_egress. A switch for names that RFC 6761 already reserves adds surface without changing what users can express.
- Refuse instead of answering loopback. This removes the synthetic placeholder but keeps the parity gap and the denied/proposed telemetry.
Agent Investigation
Observed resolver chain:
- Compute drivers write /etc/resolv.conf with nameserver 127.0.0.53 (Docker crates/openshell-driver-docker/src/lib.rs:6541, Podman crates/openshell-driver-podman/src/driver.rs:40, Kubernetes
crates/openshell-driver-kubernetes/src/driver.rs:7487, VM crates/openshell-driver-vm/scripts/openshell-vm-sandbox-init.sh:673). - The seccomp broker's DNS relay (crates/openshell-sandbox/src/network_broker.rs:535, accept_dns at :393) forwards the raw query to the supervisor as a mediated DNS query.
- PolicyDnsService::answer_query (crates/openshell-supervisor-network/src/policy_dns/mod.rs:184) has no loopback-name case. With no matching policy endpoint it calls stage_observation (mod.rs:334) after
observation_eligible (mod.rs:443) excludes only the exact name localhost. - allocate_address (policy_dns/store.rs:626) hands out pool addresses sequentially from the ranges built in policy_dns/runtime.rs:57: 198.18.0.0/15 with 198.18.0.1 reserved for the sandbox-local API, so
198.18.0.2 is the first external identity. 198.18.0.4 is consistent with the third allocation in an epoch-0 pool (inference; not reproduced against a live sandbox in this environment). - Loopback TCP connects complete inside the sandbox through connect_local_tcp (network_broker.rs:1081), never reaching the proxy or policy. Users can already connect to 127.0.0.1 by literal, so answering
*.localhost with loopback grants no new reach. - Proposal generation classifies only the exact hostname localhost as internal/loopback (crates/openshell-supervisor/src/mechanistic_mapper.rs, crates/openshell-sandbox/src/mechanistic_mapper.rs), which is
why .localhost names appear as ordinary proposals today.
Prototype status: a prototype exists only in an uncommitted local working tree from a prior session; it is not accepted work, has no PR, and its tests were not executed here (no network, no cargo cache,
and the sandbox blocks the linker). The spike record does not depend on it.
Open questions:
- For AAAA queries when policy_dns_ipv6_egress answers are disabled, should loopback names still return ::1 (strict RFC 6761), or keep the current suppression so clients fall back to A?
- Should the relay answer the exact name localhost as well, or only names under .localhost, since /etc/hosts normally handles localhost first?
- Gateway service hostnames under the configured openshell.localhost base domain would also become loopback inside a sandbox. Confirm that this side effect is acceptable.
- Where should the shared classification live so proposal generation, policy DNS, and any future resolver path agree?
Checklist
- I've reviewed existing issues and the published docs
- This is a design proposal, not a "please build this" request
- Ngôn ngữ chính
- Rust
- Star
- 21.5k
- Fork
- 2.1k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- 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 NVIDIA/OpenShell
-
state:triage-needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
state:triage-needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug: Ready=False/PodTerminating is treated as a terminal sandbox failureCó thể đã có người làm @TaylorMutch đã nhận 9 ngày trước. Đang mởstate:accepted state:pr-opened
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
state:triage-needed
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
-
state:triage-needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Tất cả issue của NVIDIA/OpenShell
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anomalyco/rune#2432 · 1 bình luận ·
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 72/100
-
[Bug]: Add Data's question says "Link to the file" for a GeoPackage where small tables are copiedĐang mởunconfirmed possible issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jerney-nexus/epikrise#364 ·
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 62/100
Yeachan-Heo/gajae-code#8058 ·
Maintainer thường phản hồi trong vòng 1 ngày