Skip to content

fix(minimald): refuse unmatched names for partial allow lists and gate proxy callers (0.7.0 backport) - #2755

Closed
norrietaylor wants to merge 2 commits into
release/0.7.xfrom
fix/net-partial-allow-names-0.7.0
Closed

norrietaylor wants to merge 2 commits into
release/0.7.xfrom
fix/net-partial-allow-names-0.7.0

Conversation

@norrietaylor

Copy link
Copy Markdown
Member

Summary

Backports #2716 (T106) to release/0.7.0. On main it fixes #2693.

  • NET-141: the relay's DNS gate now answers REFUSED for any name outside the box zone that the box's allow_dns_hosts does not match. Before, it did this only for a deny-all box; a box with a partial list still forwarded unmatched names, so the name left the machine in the query. An empty list that admits subnets (--allow-subnets 0.0.0.0/0 alone) still forwards. Each refusal writes one rate-limited warning that names the box and the name, keyed by a bounded hash bucket of the name.
  • NET-070: the hostname proxy now names the box behind a connection from the node's address. It finds the socket's inode, the process holding it, and that process's classifier leaf, then applies that box's egress rules. While a host-address box is live, it refuses a connection whose owner it cannot name. Off-node peers count as no box unless an own-address box is mid-attach. Host launches carry a launch number, so a replaced host's late stop mark is ignored.
  • scripts/session-e2e.sh: the disallowed-name leg for the partial allow list now asserts a resolver refusal inside 5000 ms.

Backport notes

  • Commit 1 is git cherry-pick -x 302edaf09. The subject changed from feat( to fix( so scripts/next-version.sh --check stays on 0.7.x.
  • The box actor and box runtime hunks land in session.rs and session_host.rs.
  • dns_gate.rs carries only T106's hunks. Release has no BEP steering, so T106's edits to the steering tests are left out.
  • The NET spec hunk is dropped, because release's NET-141 text differs from main's.
  • Commit 2 maps main's names to release's: sessions/sandbox2/session_host, SessionPolicy, SessionKeyPredicate, tokio::spawn in place of crate::traced, and no quic443 field.

Test plan

  • just fmt-check, just clippy (Linux, Lima)
  • cargo nextest run -p minimald: 1016/1017 pass. The one failure is the VM-only session_host::tests::a_hook_launch_does_not_advise_unenforced_placement (cgroup EACCES), which this change does not cause.
  • The 18 new or changed T106 tests pass by name, including the proptest unmatched_name_never_forwarded_for_any_allow_set.
  • bash -n scripts/session-e2e.sh
  • Session e2e (the CI KVM/macOS lanes)

minimal-foundry Bot and others added 2 commits October 29, 2026 18:18
…e proxy callers (T106) (#2716)

* fix(minimald): refuse names a partial allow list does not match

The relay's DNS gate answered REFUSED only for a deny-all box. A box
with a partial allow_dns_hosts list still forwarded a name that no
entry matched, so the name left the machine in the query (NET-141).

The gate now refuses, at the relay and before any onward query, every
name outside the box zone that a declared list does not match. Each
refusal writes one rate-limited warning that names the box and the
name. A property test covers lists, names and zones.

* fix(minimald): gate host-address callers of the hostname proxy

A host-address box holds no switch lease, so its request reached the
hostname proxy from the node's address and the proxy named no caller.
Its egress rules were never applied (NET-070).

The caller table now names the box that owns the connecting socket:
the socket's inode in the kernel's tables, its holder, and that
process's classifier leaf. The proxy puts the request to that box's
egress rules, and the refusal line names it as the caller.

* fix(minimald): bound the refused-name warning's rate-limit keys

The key held the name the box asked for, and the limiter never evicts
a key. A hash bucket of the name keeps the keys at a fixed count.

* fix(minimald): refuse proxied connections no box can be named for

Name the caller when the proxy accepts the connection, before it reads
the head. While a host-address box is live, a connection from the
node's address whose owner the kernel cannot name is refused, not
left ungated.

* fix(minimald): refuse names only for deny-all or listed boxes

An empty allow_dns_hosts list with subnets admitted (--allow-subnets
0.0.0.0/0 alone) keeps its forwarding. Register caller facts for
host-address boxes, and refuse a proxied connection whose owning box
has no caller facts.

* test(e2e): assert the partial allow list refuses names fast

* docs(spec): drop the NET-141 partial allow list gap

* test(minimald): pick a second refused name in another bucket

The refusal warning keys a bucket of the name under a per-process
random hasher, so the fixed second name shared the first one's bucket
on one run in 256 and its line was suppressed.

* fix(minimald): cap concurrent socket owner lookups in the proxy

Each connection from the node's address walks /proc on the blocking
pool. Allow four walks at once, daemon-wide. A connection that waits
more than five seconds for a slot is refused as unattributed.

* test(minimald): keep the steered host set's doc on its const

* fix(minimald): treat an off-node proxy peer as no box

A host-address box shares the node's network namespace, so its
connections come from an address the node holds. A peer at any other
address, such as a VM host's request forwarded through the switch's
gateway, is never in the node's socket tables. Its owner lookup found
nothing, and the proxy refused every such request while a host-address
box was live.

* fix(minimald): refuse off-node proxy peers while a lease is unreported

An own-address box registers its caller facts at finalize and reports its
switch lease at the end of its attach. In that window an off-node peer can
be that box. connecting_box() now answers OffNode for such a peer, and the
proxy maps it to no box only while no own-address caller waits for its
lease report. Otherwise the peer is unattributed and refused.

* fix(minimald): count only attaching boxes as waiting for a lease

An own-address box that registered at finalize but never attached, or
whose attach failed, or whose box stopped, made the hostname proxy refuse
every off-node peer while a host-address box was live. The registry now
marks a box when its attach plans a lease, and clears the mark when the
lease is reported, when the attach fails or is abandoned, when the box
stops, and when it is destroyed.

* fix(minimald): skip stopped boxes and read every socket holder

A stopped host-address box keeps its caller facts until destroy, so
has_unleased_callers now skips stopped boxes. The proxy then runs no
owner lookup for them, and a host client that closes its socket early
is not refused.

connecting_box now reads every process that holds the client socket.
The socket is a box's when any holder runs in that box's leaf. Holders
in two box leaves, or a pid that stops holding the socket after its
cgroup read, answer Unknown, so the proxy refuses the connection.

* fix(minimald): count a launching stopped box as a live caller

A resumed host-address box stays stopped until its host loop calls
mark_running, after the launch starts its processes. launch_host now
sets a launching mark before Host::spawn, so the hostname proxy looks
up the owner of a connection from the node's address in that window.
mark_running, mark_stopped, forget_own_address and a failed spawn
clear the mark (NET-070).

* fix(minimald): ignore a replaced host's late stop mark

begin_host_launch now returns a per-box launch number, and the registry
keeps each box's current number. NameMarker carries the number and
stops the box through mark_host_stopped, which does nothing for an
older launch. A late loop of a replaced host can no longer mark the new
running box stopped, so a deny-all host-address box's requests from the
node's address stay under its egress rules (NET-070).

* fix(minimald): count a launching box with no caller facts as unleased

An ended box brought up for its destroy hooks can launch with no caller
facts, when another box holds its name and the actor skips
register_hostname. has_unleased_callers iterated only the caller facts,
so the launch did not turn the owner lookup on, and the hook's proxied
request passed as no box's. A launching box with no own address and no
lease now counts whether or not it has caller facts, so the proxy
refuses its connections as unattributed (NET-070, design §7.1).

---------

Backport to release/0.7.0: the NET spec hunk is dropped, since the release
branch's NET-141 text differs from main's. The box actor and box runtime
hunks land in session.rs and session_host.rs.

Co-authored-by: minimal-foundry[bot] <327719912+minimal-foundry[bot]@users.noreply.github.com>
Co-authored-by: Norrie Taylor <91171431+norrietaylor@users.noreply.github.com>
(cherry picked from commit 302edaf)
The release branch names the crates and helpers the cherry-pick uses
differently: sessions for boxes, sandbox2 for sandbox, session_host for
box_runtime, sessions::SessionKeyPredicate for the box manager's
predicate, and SessionPolicy for BoxPolicy. It has no crate::traced, so
the proxy spawns with tokio::spawn and tokio::task::spawn_blocking, and
its policy has no quic443 field.
@norrietaylor
norrietaylor requested a review from a team as a code owner October 30, 2026 01:22
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: c20e38dd-772c-4ef8-be23-11b5d5730b13

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@minimal-foundry

minimal-foundry Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Approved: no findings at bcec62882d34.

Nothing to do.

Clobber: not found in the hunks read. If that was not intentional, restore the earlier change.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approved

Verdict APPROVE — No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 30, 2026

@bryan-minimal bryan-minimal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared hunk by hunk against #2716's merge: the same change, with only the adaptations release/0.7.0 forces (no crate::traced, no quic443, no BEP-062 steering so warn_refused sits straight after decide(), the session_* names, and the spec hunk dropped because release's NET-141 is a different requirement). The proptest and the bucket-collision fix are both present; all required checks pass. One follow-up for the release branch only, not this PR: dns_gate.rs cites NET-141 for the DNS refusal while release's spec uses NET-141 for the userns activation check, a collision this backport widens.

norrietaylor pushed a commit that referenced this pull request Nov 4, 2026
…e proxy callers (#2716)

T106. NET-141: the relay's DNS gate answers REFUSED, before any onward query, for every
name outside the box zone that a declared allow_dns_hosts list does not match. It did this
only for a deny-all box, so a box with a partial list still sent the name off the machine.
An empty list that admits subnets keeps forwarding. Each refusal writes one rate-limited
warning, keyed by a bounded hash bucket of the name.

NET-070: the hostname proxy names the box behind a connection from the node's address
through the socket's inode, its holder and that process's classifier leaf, and applies that
box's egress rules. While a host-address box is live, a connection whose owner cannot be
named is refused. Owner lookups are capped at four at once, and a wait over five seconds
is refused as unattributed. session-e2e.sh asserts the partial allow list refuses fast.

Backport of #2716, folded from #2755.

Adapted to the line:
- Box actor and box runtime hunks land in session.rs and session_host.rs.
- boxes, sandbox and box_runtime read sessions, sandbox2 and session_host, with
  SessionPolicy and SessionKeyPredicate. crate::traced becomes tokio::spawn and
  tokio::task::spawn_blocking, and the line's policy has no quic443 field.
- register_host_net keeps #2749's dial at the guest's 127.0.0.1 beside the host_net record.

Dropped: the edits to the BEP steering tests in dns_gate.rs, since the line has no BEP
steering, and the NET spec hunk, since the line's NET-141 text differs from main's.

(cherry picked from commit 302edaf)
norrietaylor pushed a commit that referenced this pull request Nov 5, 2026
…e proxy callers (#2716)

T106. NET-141: the relay's DNS gate answers REFUSED, before any onward query, for every
name outside the box zone that a declared allow_dns_hosts list does not match. It did this
only for a deny-all box, so a box with a partial list still sent the name off the machine.
An empty list that admits subnets keeps forwarding. Each refusal writes one rate-limited
warning, keyed by a bounded hash bucket of the name.

NET-070: the hostname proxy names the box behind a connection from the node's address
through the socket's inode, its holder and that process's classifier leaf, and applies that
box's egress rules. While a host-address box is live, a connection whose owner cannot be
named is refused. Owner lookups are capped at four at once, and a wait over five seconds
is refused as unattributed. session-e2e.sh asserts the partial allow list refuses fast.

Backport of #2716, folded from #2755.

Adapted to the line:
- Box actor and box runtime hunks land in session.rs and session_host.rs.
- boxes, sandbox and box_runtime read sessions, sandbox2 and session_host, with
  SessionPolicy and SessionKeyPredicate. crate::traced becomes tokio::spawn and
  tokio::task::spawn_blocking, and the line's policy has no quic443 field.
- register_host_net keeps #2749's dial at the guest's 127.0.0.1 beside the host_net record.

Dropped: the edits to the BEP steering tests in dns_gate.rs, since the line has no BEP
steering, and the NET spec hunk, since the line's NET-141 text differs from main's.

(cherry picked from commit 302edaf)
@norrietaylor

Copy link
Copy Markdown
Member Author

Folded into #3019, which landed on release/0.7.x as ac7491e84.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants