Repository navigation
feat(minimald): refuse unmatched names for partial allow lists and gate proxy callers (T106) - #2716
Conversation
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.
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.
…atched-names-for-partial-allow-lists-a
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Reviewed: no findings; approval withheld, 1 thread unresolved at APPROVE withheld: 1 unresolved thread — minimal-arch[bot] crates/minimald/src/net/dns.rs:1217. Resolving the last thread releases the approval on this head. Resolve the open threads. Resolving the last one releases the approval on this head; no new review is required. Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it. Clobber: none seen. |
…atched-names-for-partial-allow-lists-a
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.
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.
There was a problem hiding this comment.
arch-review: CONDITIONS · 4 conditions · the full ruling
The DNS refusal for partial allow lists conforms to §5.3 line 145. The proxy gate for host-address callers does nothing in production. Only the OwnIp arm of box_actor/naming.rs calls register_caller. A host-address box has no caller facts, so the proxy routes its request without a gate. §7.1 lines 249 and 259 say the :7654 proxy must enforce the source's egress rules now. C1 registers the facts, and C2 refuses a box that the registry does not know. C3 and C4 make the partial-list e2e leg assert a fast refusal and remove the stale spec gap.
Ruled at f3725db against gominimal/arch@109541a48c31 by claude-opus-5-5.
|
Round 1 of 10 on the runtime's review findings, pushed as
Verify Review threads the coder judged:
A box allowed only github.com gets REFUSED at once for example.com, and the query goes to no resolver. A deny-all host-address box's request through the hostname proxy to another box gets 403 Forbidden. While a host-address box is live, the proxy also refuses a connection from the node's address when it cannot name the box that owns it. Notes from the agent: Revise round 1. Threads 1 and 2 report the same fail-open. connecting_box now returns ConnectingOwner (Box, NoBox, Unknown). The proxy names the caller when it accepts the connection, before it reads the head. While a live caller holds no switch lease, an Unknown owner (or a failed lookup task) is refused with 403 and the body 'the proxy cannot tell which box opened this connection'. The warn line 'refused a proxied request' names the peer, the host and the target box, with caller="unknown". A host-side client whose holder the proxy cannot see (for example under a hidepid /proc) is refused too while a host-address box is live. This fails closed on purpose. A box id whose leaf names no live caller still gets no caller, as before. Thread 3: the policy.rs limiter is outside the layers, so the fix is in dns_gate.rs. The key is now one of 256 buckets per box, from a hash with a random per-daemon key. Two names in the same bucket share one line a minute. I added the unit test unmatched_name_refusal_keys_stay_bounded and a fourth case to proxy_host_address_caller_egress_denied, and the net::proxy and net::dns modules pass (122 tests). Deferred: cargo nextest run -p boxes kani_frame_verdict_admits_nothing_undeclared (lane: kani), not run. I did not run just clippy-strict. |
|
/revise Fix the native-daemon-e2e failure, then close arch conditions C1–C4 from the ruling at
Generated by Claude Code |
…atched-names-for-partial-allow-lists-a
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.
Spec lint
Advisory. None of this blocks the merge; the review decides. Advisory, and never a merge gate. Linter: |
|
Round 2 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. Review threads the coder judged:
A box allowed only github.com gets REFUSED at once for example.com, and the e2e now fails unless that lookup fails at resolution inside 5000 ms. A box created with only --allow-subnets 0.0.0.0/0 resolves outside names again. A deny-all host-address box gets its caller facts registered by the session actor, so its request through the hostname proxy to another box is refused with 403. A connection that the kernel names a box for, but that box has no caller facts, is refused too. Notes from the agent: Revise round 2. The directive asked for changes in files outside the task's layers: crates/minimald/src/box_actor/naming.rs (C1, register_caller in the HostNet arm), crates/minimald/src/box_actor/tests.rs (the C1 naming test host_address_box_registers_its_caller_facts), scripts/session-e2e.sh (C3) and docs/specs/18-spec-box-networking/18-spec-box-networking.md (C4). I touched them because the directive names them. The native-daemon-e2e fix: DnsGate::refuses now refuses on the name list only when the box is deny-all or the list is non-empty, with the unit test empty_name_list_with_subnets_forwards_outside_names and the module doc updated. C2: Router::caller_for returns Unattributed when caller_owning is None. The proxy_host_address_caller_egress_denied test gains a leg that expects 403 for a box with no caller facts, and its comment points to the naming test for the production registration. I did not run the session e2e (scripts/session-e2e.sh), so the C3 assertion is unverified on this box. The C3 elapsed time is measured around |
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.
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.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 4 unresolved threads — minimal-arch[bot] crates/minimald/src/net/dns.rs:1086, minimal-arch[bot] crates/minimald/src/net/proxy.rs:323, minimal-arch[bot] crates/minimald/src/net/proxy.rs, minimal-arch[bot] crates/minimald/src/net/proxy.rs:3846. 1 finding, 1 inline.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The proxy side of NET-070 conforms. Unknown owners and lookups without a slot fail closed. Baseline conditions C1, C3 and C4 are met. A new exemption in DnsGate::refuses forwards outside names for a box with only allow_subnets. Section 5.3 line 145 says the relay must refuse those names. The CLI and NET-074 treat that shape as allow-all, so I escalated the question for a design decision. Make the change in C1: record the exemption as a residual in the spec and in the code comments. Do not change the gate behaviour in this round.
Ruled at 9834586 against gominimal/arch@109541a48c31 by claude-opus-5-5.
|
Round 3 of 10 on a failed check suite, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. Review threads the coder judged:
A box allowed only github.com gets REFUSED at once for example.com, and the relay forwards the query to no resolver. A deny-all host-address box's request through the hostname proxy to another box is refused with 403. This round also makes the per-name warning test deterministic, and caps the proxy's /proc owner lookups at four at a time. Notes from the agent: Failed checks: the test-kvm excerpt in the directive holds only the job's cleanup steps, not the step that failed. This box has no /dev/kvm, so I could not run the e2e and could not find the cause. I read the e2e legs that the NET-141 change can affect: the own-IP egress proof's new fast-refusal assertion for example.org, the hostname-only toolchain box, and the undeclared-name leg. Each box declares a non-empty allow_dns_hosts, and the gate code refuses an unmatched name for all of them, as the assertions expect. I changed nothing in scripts/ this round. Someone must read the full test-kvm log to find the failing step. The test (deferred: kani) line, kani_frame_verdict_admits_nothing_undeclared, is still owed by the kani lane, and I ran nothing for it. I added no unit test for the lookup cap. The semaphore is process-wide, and a test that drains it can affect other tests when they share a process under cargo test. |
|
The runtime will not revise this pull request again on its own: the diff is +1786/-199 (1985 lines), past 3x the plan's estimate of 620 lines (est: 260 code, 360 tests, as #2693 reads now), at round 4 (the last trigger was a /revise note). A person decides now. Remove |
There was a problem hiding this comment.
minimal-review — approved
Verdict APPROVE — every review thread is resolved; @norrietaylor closed the last one. The review of 63e1bbcd0ad2 withheld this approval on the threads open then. Posted as a comment: the App cannot approve its own pull request; the check and the label carry it.
There was a problem hiding this comment.
Babysitter review at 63e1bbcd. I read T106's relay gate and proxy owner checks against the plan block and arch's rulings 545, 546, 567, 570 and the PASS at this head.
- Names: the relay gate refuses unmatched names outside the zone for partial allow lists and the deny-all shape (NET-141); a box with only
allow_subnetskeeps forwarding, as the module doc states (owner ruling: superseded by arch PASS). - Proxy owner checks (NET-070): an off-node peer is
OffNodeand is refused as unattributed while an own-address box is attaching; a stopped box no longer turns on the owner lookup, a launching box counts as live, and a replaced host's late stop is ignored by launch number (mark_host_stopped, dns.rs:1873). Multiple socket holders resolve to the box, and two box leaves are refused (owner_of_holders). - Residual: the log bucketing and the lookup-slot DoS are #2745, by the owner's ruling.
- Threads: zero open; I checked each fix in code before resolving it. CI: every lane aggregator is green at this head.
No further findings.
Generated by Claude Code
norrietaylor
left a comment
There was a problem hiding this comment.
Babysitter approval at 63e1bbc: every merge gate passes at this head (arch PASS at 63e1bbc, zero open threads, every lane aggregator green). Squash title feat(minimald): refuse unmatched names for partial allow lists and gate proxy callers (T106) and the squashed message pass commitlint. Queued for squash merge.
Generated by Claude Code
|
@cla-assistant check Generated by Claude Code |
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The merge of main opens a gap in the NET-070 proxy gate. An ended HostNet box whose name another box holds has no caller facts. Destroy then launches its hook host. has_unleased_callers counts only boxes with caller facts, so the proxy passes the hook's request as a host-side client. Section 7.1 line 249 says the proxy must enforce the source's egress rules. Make the change in C1, and the change conforms.
Ruled at a6c3214 against gominimal/arch@42d214dc8ac8 by claude-opus-5-5.
| /// count until [`Self::begin_host_launch`] or [`Self::mark_running`] | ||
| /// (NET-070). | ||
| #[must_use] | ||
| pub fn has_unleased_callers(&self) -> bool { |
There was a problem hiding this comment.
C1 · This predicate counts only ids in self.callers. On the merged head, an ended HostNet box whose name another box holds has no caller facts, and destroy launches its hook host. Its hook requests then get NoBox in caller_for. Section 7.1 line 249 says the proxy must enforce the source's egress rules. Also count an id in self.launching with no own-address entry and no lease. Then caller_owning answers None, and the request is refused.
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).
|
Revise round 3 ran against |
|
/arch-review |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The compare closes the open gap on the hostname proxy. A launching box with no caller facts now turns on the owner lookup. The proxy then refuses its request as unattributed. Section 7.1 lines 244 and 249 require this default-deny, and the new test proves it. The rest of the change keeps the status of the PASS on 63e1bbcd.
Ruled at 90731ef against gominimal/arch@42d214dc8ac8 by claude-opus-5-5.
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The commit closes a gap in the §7.1 proxy gate. An ended box that launches for its destroy hooks without caller facts now turns on the owner lookup. The proxy then refuses its request and does not let it through as a host-side client's. Section 7.1 line 249 says that a routing surface is never a policy bypass, and the change now conforms to that line. The rest of the PR keeps the earlier ruling. There are no conditions.
Ruled at 90731ef against gominimal/arch@42d214dc8ac8 by claude-opus-5-5.
…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)
T106 — Refuse unmatched names for partial allow lists and gate host-address proxy callers
slice: S16
kind: task
covers: NET-141, NET-070
size: L
est: 260 code, 360 tests
executor: agent
difficulty: needs care
model: strongest
diagnostics: the diagnostics bundle's daemon log tail carries the relay's rate-limited line for each refused name, naming the box and the name, and the proxy's refusal line naming the calling box and the target
observability: the relay logs one rate-limited line per name it refuses with the box and the name; the hostname proxy's refusal line names the caller box whether it called from a switch lease or from the node's address
layers:
- dns:
- crates/minimald/src/net/dns_gate.rs: a query from a box with an allow list, for a name the list does not match and outside the box zone, is answered refused and forwarded to no resolver, the same as a deny-all box's; the test gains the partial-allow-list leg and a property over names, patterns and zones
test: cargo nextest run -p minimald unmatched_name_refused_without_upstream_forward
test: cargo nextest run -p minimald unmatched_name_never_forwarded_for_any_allow_set
- proxy:
- crates/minimald/src/net/dns.rs: the caller table answers for a host-address box's connections from the node's address by the box that owns the connecting socket
- crates/minimald/src/net/proxy.rs: a request from a host-address box is decided by that box's egress rules, as a switch-lease caller's is
test: cargo nextest run -p minimald proxy_caller_egress_denied
test: cargo nextest run -p minimald proxy_host_address_caller_egress_denied
test (deferred: kani): cargo nextest run -p boxes kani_frame_verdict_admits_nothing_undeclared
produces: none
consumes: none
proof: A box allowed only github.com fails at once to resolve example.com, and a deny-all host-address box's request through the hostname proxy to another box is refused.
Proof
A box allowed only github.com now gets REFUSED at once from the relay for example.com, and the query never reaches the switch. A deny-all host-address box's request through the hostname proxy to another box now gets 403 Forbidden, and the refusal line names that box as the caller.
Notes from the agent: DNS: the relay's gate now refuses every name outside the box zone that a declared allow_dns_hosts list does not match, not only for deny-all boxes. A box that declared no names is still not refused. A deny-all box keeps its narrower zone match (the apex and x.MIN.INTERNAL are REFUSED). A partial list leaves those zone forms to the existing NXDOMAIN rule. Each refusal writes one warning, rate-limited per box and name, that names the box (session_id) and the name. Existing dns_gate tests that asked an allow-list box for unlisted names now expect REFUSED. The steered-proxy fixtures gained an allowed, non-credentialed name (example.org) so the SERVFAIL-on-mixed-query leg still tests what it did. Proxy: HostnameRegistry::caller_owning plus dns::connecting_box name a host-address caller by the connecting socket: /proc/net/tcp{,6} inode, the holder pid from /proc/*/fd, and the box id from the holder's cgroup leaf boxes/<allow|deny>/. The lookup runs on a blocking thread, and only while some live caller holds no switch lease. HostRoute gained two methods; it has no implementations outside proxy.rs. The proxy test stubs the owner lookup through Router::with_socket_owner, because a test process runs in no box leaf. The kernel half (inode and holder) has its own test against a real connection. The leaf-name-equals-box-id mapping depends on create_box_leaf being called with record.id, as box_actor/host.rs does today. Deferred (lane: kani): cargo nextest run -p boxes kani_frame_verdict_admits_nothing_undeclared. That harness already exists in crates/boxes/src/core/egress.rs, and the proxy reuses the same pure verdict, so nothing in it changed and nothing was run f…[truncated]
Layer exception
These files are outside T106's layers. Round 2 changed them to close arch conditions C1, C3 and C4 at
f3725db8(arch_rulings 500):crates/minimald/src/box_actor/naming.rsandcrates/minimald/src/box_actor/tests.rs(C1): aHostNetbox registers as a caller, so the host-address proxy gate can attribute it, with a naming test for that registration.scripts/session-e2e.sh(C3): the partial-allow-list box's disallowed-name leg now fails unless the name is refused fast, as the deny-all leg does.docs/specs/18-spec-box-networking/18-spec-box-networking.md(C4): the NET-141 note drops its known-gap sentences and states the assertion C3 adds.Tests
cargo nextest run -p minimald unmatched_name_refused_without_upstream_forwardcargo nextest run -p minimald unmatched_name_never_forwarded_for_any_allow_setcargo nextest run -p minimald proxy_caller_egress_deniedcargo nextest run -p minimald proxy_host_address_caller_egress_deniedVerify
min task run agent-verifypassed ([tasks.verify]).Base
The base branch moved while the coder worked; it was merged in before the tests ran.
Deferred
The plan marked these test lines deferred: the executor lacks the lane, so nothing here ran them and they still owe evidence.
cargo nextest run -p boxes kani_frame_verdict_admits_nothing_undeclaredCloses #2693
Generated by Claude Code