Repository navigation
fix(minimald): refuse unmatched names for partial allow lists and gate proxy callers (0.7.0 backport) - #2755
norrietaylor wants to merge 2 commits into
Conversation
…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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Approved: no findings at Nothing to do. Clobber: not found in the hunks read. If that was not intentional, restore the earlier change. |
bryan-minimal
left a comment
There was a problem hiding this comment.
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.
…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)
…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)
|
Folded into #3019, which landed on |
Summary
Backports #2716 (T106) to
release/0.7.0. On main it fixes #2693.allow_dns_hostsdoes 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/0alone) 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.scripts/session-e2e.sh: the disallowed-name leg for the partial allow list now asserts a resolver refusal inside 5000 ms.Backport notes
git cherry-pick -x 302edaf09. The subject changed fromfeat(tofix(soscripts/next-version.sh --checkstays on 0.7.x.session.rsandsession_host.rs.dns_gate.rscarries only T106's hunks. Release has no BEP steering, so T106's edits to the steering tests are left out.sessions/sandbox2/session_host,SessionPolicy,SessionKeyPredicate,tokio::spawnin place ofcrate::traced, and noquic443field.Test plan
just fmt-check,just clippy(Linux, Lima)cargo nextest run -p minimald: 1016/1017 pass. The one failure is the VM-onlysession_host::tests::a_hook_launch_does_not_advise_unenforced_placement(cgroup EACCES), which this change does not cause.unmatched_name_never_forwarded_for_any_allow_set.bash -n scripts/session-e2e.sh