Add RFC6761 section 6.3 support (*.localhost -> 127.0.0.1 / ::1)
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 18/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- docker, kubernetes, linux, networking, rust
- 領域
- networking
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Rust
- スター
- 21.5k
- フォーク
- 2.1k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/OpenShell のほかの issue
-
state:triage-needed
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
state:triage-needed
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
bug: Ready=False/PodTerminating is treated as a terminal sandbox failure対応中かも @TaylorMutch が 9 日前に担当しました。 オープンstate:accepted state:pr-opened
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
state:triage-needed
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
-
state:triage-needed
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
NVIDIA/OpenShell の issue をすべて見る
似ている issue
-
marketing
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
help wanted small extra
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
anomalyco/rune#2432 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
n0-computer/net-tools#282 ·
メンテナーはふだん 2 日以内に返信