Repository navigation
T74 — Decide a DNS box's destinations on the host from the answers its own queries received - #1811
Conversation
Two admission tables will hold a box's DNS pins, the host-side one NET-081 adds and the in-VM one NET-066 shipped, and each is bounded by the same three numbers: the window an answer holds for, the per-name address cap, and the used-pin retention past the window. They move to the sessions crate, beside the rebinding intersection that produces what the window stores, so neither leg can drift from the other — a pin cannot outlive its window on one leg while it lives on in the other, and one name's cap cannot be a different grant on the two paths a box's frames take. The in-VM gate re-points its three constants there, and its module doc now names the two tables and which copy decides: on a VM-backed host the host-side table is the deciding one, filled from the DNS replies the box's own lookups received, and the in-VM gate stays the precision copy inside the VM. Design §5.3's TTL floor (600 s) and cap (24 h) stay prose: neither gate applies a TTL-bounded window, a departure the in-VM gate records at its constant, and a dead constant would suggest otherwise.
… ran out the coder's uncommitted work as it stood when its 7200s ran out The coder was stopped at the end of its time with these changes not committed. The runtime committed its working tree as it stood so the work is kept: this commit is a snapshot, not a finished step, and may not build or pass its tests.
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
The interrupted snapshot left the gate's DNS table half-threaded: the accept loop, the relay and the verdict all took the pins parameter, but five test call sites never grew it; the first-pin flag was a plain bool behind an entry shared by Arc, and the frame verdict passed its row owned where the table borrows it. The build also carried the failures the failed checks name. The sessions constants introduced by the previous commit tripped duration_suboptimal_units under the CI toolchain, which alone took down every job that compiles the workspace; the registry's dns_hosts read tripped map_clone; the gate's own public spawn exposed a pub(crate) table type. And the window test's two count assertions were written against a per-answer refusal key that contradicts both this limiter's own doc and the in-VM bucket it shares: the shared refusal format rates by box, name and rule, so a repeated answer under a spent key is silent. The assertions now say so, and the burst's silence is what they prove. The two admission counters keep test-facing readers under #[cfg(test)], the pattern the in-VM gate's window-shrinkers set: the counter is table state, maintained at the decision in every build, and no production surface reads a running total yet.
|
Round 1 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. On a VM-backed host, a box that allows github.com by name reaches the addresses its own lookup returned and nothing else, decided outside the VM: with the in-VM relay replaced by a hostile one that carries the box's frames to any subnet, the host gate drops every destination the box's own answers did not pin, refuses an answer that resolved into the row's deny set or the infrastructure set, keeps applying every non-DNS rule to the row, and the bundle's host log shows the decision was the host's — all four behaviours are now demonstrated by passing tests on this branch (dns_box_undeclared_destination_decided_on_host, host_pins_are_the_answers_the_box_received, hostile_relay_reaches_only_the_pinned_answers, host_window_refuses_denied_and_infrastructure_ranges, host_side_rules_applied_outside_vm, dns_pinned_admission_window). The NET-068 toolchain harness named as the regression oracle is not runnable here: hostname_allowlist_toolchain_completes lives only on PR #1771's branch (not on main, so not in this tree) and its real run is VM-lane gated; what this branch offers instead is that the in-VM leg it exercises (dns_gate.rs) carries only module-doc and constant re-pointing with unchanged values, and the frame-level tests above prove the host admits exactly the answers the box's own lookups produced. Notes from the agent: Revise round for PR #1811: all four failed checks (ci-success, unit, native-daemon-e2e, clippy) traced to one root cause — the interrupted snapshot aa7ff9c did not compile (5 test call sites missing the new DnsPins argument, a borrow error at the pin arm, a field written behind &self, plus a lint set). This round finished the refactor and cleared the lints; the branch now builds, the six task tests pass, the unit lane's own nextest invocation passes 769 tests plus doctests, and clippy -D warnings is clean on minvmd, sessions, minimald and minimal. Two judgement calls to flag. (1) host_window_refuses_denied_and_infrastructure_ranges: the s…[truncated] |
|
/revise
|
observe_reply read every ingress datagram through the row lookup and the table's lock before the port check refused it, so the answers to a box's own non-DNS datagrams paid both for a reply that could never pin. The port DNS is served from now turns the datagram away before either: the same fact BoxPins::observe decides the reply's source by, read once more where it is cheapest. No behaviour changes — the resolver's address and every other check stay where they were.
The plan's "dropped with the row" now has a proof for each half. The pure half pins the entry's identity guard: a replacement row at the same switch address — a new record, the shape a re-attachment's re-registration takes — inherits none of the replaced row's pins or established flows, and the replaced record admits nothing either, until the new row's own lookup pins again. The relay half pins the retire the connection's end performs, watched on a row the drainer has not withdrawn yet — the shape a hostile relay would try: close the connection, keep the row, and hope the pin outlives the close. It does not; the re-registered row starts fail-closed too, and its own lookup is what pins again. Both tests fail if the arm they watch is removed: dropping the entry's identity check hands the replacement row the old entry's pins, and dropping the relay's retire lets them ride the reopened connection.
…ns-box-s-destinations-on-the-host-from
|
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. On a VM-backed host, a box that allows github.com by name still reaches only the addresses its own lookup returned, decided outside the VM — and now the plan's promised lifetime is held by tests a person can read: a DNS box's host-side admission table is dropped with the row (a replacement row re-registered at the same switch address inherits none of the replaced row's pins or established flows, and the replaced record admits nothing either) and with the relay connection whose lookups filled it (closing the box's relay connection leaves its pinned destinations refused on the next connection, for the same still-published row, until its own lookups pin again) — and a box's non-DNS ingress UDP no longer pays the admission-table lookup or its lock, refused at the port DNS is served from before either. Notes from the agent: Revise round 2 of the directive, two items, both addressed. Item 1 (tests only): a_replacement_row_inherits_neither_pins_nor_flows (dns_pins.rs, case b) and a_closed_relay_connection_retires_the_pins_it_filled (egress_gate.rs, case a) pin the 'dropped with the row' lifetime. Both sensitivities were verified by mutation and reverted: removing pins.retire(&attributed) in relay_guest_to_switch fails the relay test (the pinned frame reaches the switch where only the marker should), and removing the Arc::ptr_eq(&entry.record, record) guard in DnsPins::entry fails the replacement-row test. The relay test deliberately takes the withdrawal-report receiver without spawning the drainer, so the row stays published after the close and the retire is watched on the very record the entry was built from — the report the test waits for is filed only after the retire runs in relay_guest_to_switch. Item 2 (no behaviour change): observe_reply returns before table.by_source and before the boxes mutex unless pkt.src.port() == DNS_PORT; the resolver-address check and every other check in BoxPins::observe are untouched, and all six plan test lines pass unchanged…[truncated] |
|
/revise These are the architecture review's conditions on T74. They are binding, and they come on top of round 2's asks. Keep every change within this task's layers, plus
|
…ns-box-s-destinations-on-the-host-from
Add the four ranges the answer-side set was missing to the shared constant both admission legs read: this-host space (0.0.0.0/8, where 0.0.0.0 names the host itself), multicast (224.0.0.0/4), broadcast (255.255.255.255/32) and the reserved block it ends in (240.0.0.0/4). Record the set's IPv6 half beside it for the IPv6 epoch — the unspecified address, loopback and the IPv4-mapped space, a record v1 decides nothing with, since AAAA never pins. Hold the host leg's reply-matching bounds here too: the outstanding-query cap and the query expiry, named where the cross-leg numbers live.
The architecture review's conditions on the host-side admission table: - The pin table's single entrance stays outside the VM. A row whose resolver is not the plan's own — the only shape a foreign resolver can take, a drift between the table's plan and the registry's — is refused its entry and says so once, naming both resolvers; and a reply-shaped frame on the guest→switch leg is decided like any other frame and pins nothing, proved at the relay by a forged reply wearing the resolver's own address: it never reaches the switch, and buys no reach. - Only the answer chain pins. The chain starts at the question name and follows the CNAME records in the answer section; an A record pins exactly when its owner is on it. The authority and additional sections and every type but A — AAAA, SVCB, HTTPS — are read past. - Only a reply to the box's own outstanding query pins. The egress leg records each query the gate admitted to the switch — question, transaction id, source port — under the shared cap and expiry the sessions crate now holds, and the reply must match all three to pin; the match consumes the entry, so a replay answers nothing. - The hostile-relay proof is scoped to registered rows, naming #1790 as the owner of the unregistered-source case.
The precision copy's module doc now says what changed at the deciding copy: the host-side table records each of the box's own outstanding queries and a reply pins there only by answering one, consuming the entry, and its entrance is closed where a reply-shaped frame on the guest→switch leg is decided like any other frame. This gate keeps the loose match it always had — no behaviour change — because it adds no per-query state of its own and on a VM-backed host the reach a reply buys is the host's decision to make. And the completed infrastructure deny set is proved on this leg too: an allowed name answering 0.0.0.0 or 224.0.0.1 is refused before the answer can become a pin and each refusal is logged in the shared format, while the connection to each stays the relay's drop.
…mes it The hostile-relay proof was written as hostile_relay_on_a_registered_row_reaches_only_pinned_answers, which the task's test line - cargo nextest run -p minvmd hostile_relay_reaches_only_the_pinned_answers - does not match as a substring filter, so the runner's re-run found no tests and exited 4. Rename the test to the name the plan's test command names; its assertions are unchanged.
|
Round 3 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. On a VM-backed host, a box that allows github.com by name reaches exactly the addresses its own outstanding queries received through the answer chain — decided outside the VM: the host gate records each DNS question the box asks and admits only replies that answer one (same name, transaction id and source port, the match consumed on use), so with the in-VM relay replaced by a hostile one a forged reply on the guest side, a reply to a question the box never asked, a replay of a matched reply, an answer record off the CNAME chain or in the authority/additional sections, an AAAA/SVCB/HTTPS hint, and an answer naming this-host, multicast, broadcast or reserved space all pin nothing and every destination the box's own answers did not pin stays the host's drop, each refusal logged in the shared format naming the box, the name, the answer and the rule. Notes from the agent: All five directive items are done, each inside the task's layers plus the directive's added crates/sessions/src/core/egress.rs. (1) The entrance: item 1(b)'s resolver assertion lives in the gate's row intake, DnsPins::entry — the directive's other allowed site — so crates/minvmd/src/net.rs needed no change this round and is untouched; a row whose resolver is not the plan's own is refused its entry (nothing can ever pin for it) and logged once per row, and item 1(a) is proved at the relay by a_reply_forged_on_the_guest_side_pins_nothing, where a guest→switch frame wearing the resolver's address never reaches the switch and buys no reach. The egress leg's query recording is wired in relay_frames_to_switch after the admitted frame is written to the switch, so only questions the gate admitted to the switch are ever outstanding. (2) The chain walk is a single forward pass over the answer section in reply order — an A before its aliasing CNAME legitimately fails to pin, fail closed. (3) The outstanding-query cap (16) and expiry (30 s) are new constants in sessions::core::egress, named where the c…[truncated] |
|
/revise Round 4. Round 3's architecture conditions are met. Two items remain, both inside this task's layers plus
Do not edit the PR body; it is updated by hand. |
BoxPins::admits inserted one FlowKey per new flow to a pinned destination and nothing reclaimed an entry for 24 h, so a hostile relay holding one pin could grow the host daemon's memory without limit. The per-box bound now lives with the other DNS admission numbers in sessions::core::egress (DNS_MAX_FLOWS_PER_BOX) and is read by the host table alone, whose memory is the host's: at the cap the entries idle past the shared idle cap are swept first, and a new flow that still finds the table full is admitted by the window its first frame is inside and not retained — fail closed at the window's edge, so its retention ends with the window rather than past it, while every flow already recorded keeps refreshing. The local FLOW_SWEEP_AT sweep is gone: the map can no longer cross the cap, so the sweep runs there.
The replay in only_a_reply_to_the_boxs_own_outstanding_query_pins was observed past DNS_QUERY_EXPIRY, so the refusal it asserted held by the expiry even when the match did not consume its entry: the test passed against a non-consuming get. The replay now arrives at now + 10s, while the question is still outstanding, and the refusal is asserted at now + DNS_ADMISSION_WINDOW + 1s, an instant a replay that pinned would have pushed the window past: the test fails if .remove(&key) in BoxPins::observe becomes .get(&key).
…ns-box-s-destinations-on-the-host-from
|
Round 4 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. On a VM-backed host, a box that allows a name by Notes from the agent: Round 4 directive, both items done. (1) Added DNS_MAX_FLOWS_PER_BOX (4096) to crates/sessions/src/core/egress.rs beside the other DNS admission constants — that file is outside the task's layers: file list, but the directive explicitly authorizes it ("plus crates/sessions/src/core/egress.rs for the shared constant"), and it is in the task's consumes: list. The cap is read only by the host table (crates/minvmd/src/net/dns_pins.rs), per the directive; the in-VM gate (crates/minimald/src/net/dns_gate.rs) is untouched and its test line passes unchanged. The local FLOW_SWEEP_AT sweep was removed: with the cap enforced before insert the map can no longer cross 4096 entries, so the old >4096 sweep was dead code; the idle sweep now runs at the cap before insert. The new test the_flow_table_is_bounded_per_box fills the cap with 4096 distinct flows to one pinned address and shows the next new flow admitted inside the window, refused after DNS_ADMISSION_WINDOW (no retention), while a flow recorded before the cap still admits past the window. (2) The replay in only_a_reply_to_the_boxs_own_outstanding_query_…[truncated] |
|
/revise Round 5. The architecture review confirms both substitutions: refusals stay NET-062 silent drops, and at-cap state is an info line plus a counter. A status surface is a separate follow-up task. These are the architecture review's conditions on round 4's flow cap ("admit by window, not retained" is confirmed). Scope:
Do not edit the PR body; it is updated by hand. |
|
That Round 5 of 10 was not counted; #1808 carries the same sentence. |
|
/revise Round 5. The architecture review confirms both substitutions: refusals stay NET-062 silent drops, and at-cap state is an info line plus a counter. A status surface is a separate follow-up task. These are the architecture review's conditions on round 4's flow cap ("admit by window, not retained" is confirmed). Scope:
Do not edit the PR body; it is updated by hand. |
The architecture review's three conditions on the flow cap, all in the host-side admission table; the in-VM gate is untouched. The cap is each box's own: the bounded-per-box test now registers a second DNS box at another lease resolving the same name and proves its flow is retained past the window while the first box's past-cap flow is refused at the same instant. The sweep at the cap now runs at most once per second per box, never once per frame, so a hostile relay holding one pin cannot buy the sweep's walk with every frame it sends. A new test ages one recorded flow past the shared idle cap and proves the next second's sweep frees a slot a new flow is retained in, while a second at-cap frame inside the same second sweeps nothing; a test-facing per-box sweep counter is what shows it, since a sweep that reclaims nothing leaves no other trace. The at-cap state is visible and rate-limited: a per-box counter of the frames the cap admitted without retention, and the per-frame debug line replaced with one info line per box per minute naming the box, the cap and the count. minvmd's default filter is info, so a debug line never reached a bundle's log tail; the state now does.
…ns-box-s-destinations-on-the-host-from
|
Round 5 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. On a VM-backed host a box that allows github.com by name still reaches only the addresses its own lookup returned, decided outside the VM, and after this round the deciding table's flow cap is provably each box's own: a second box at another lease keeps its retained flow past the window while the first box's past-cap flow is refused at the same instant, the cap's sweep runs at most once per second per box (never per frame, so a hostile relay cannot buy the sweep's walk), and a box at its cap now reads in the bundle's host log as one rate-limited info line naming its switch address, namespace, the cap and the count of frames admitted without retention, beside a per-box counter of the same. Notes from the agent: Round 5 directive, all three items done in crates/minvmd/src/net/dns_pins.rs; one commit (033f2da). (1) Per-box cap: the_flow_table_is_bounded_per_box now registers a second DNS box at 100.64.0.10 resolving the same name and asserts its flow is retained at now+window+1s while the first box's past-cap flow is refused at that instant. (2) Sweep throttle: the last sweep instant lives on the box beside the flow map under the same mutex (new FlowTable struct); at the cap a sweep runs only when at least one second has passed since the last, otherwise the frame goes straight to admit-by-window without retention. New test at_the_cap_one_sweep_per_second_reclaims_the_idle_flows ages one recorded flow past DNS_FLOW_IDLE_CAP at the cap, shows the next second's sweep frees a slot the new flow is retained in (it rides past the window), and that a second at-cap frame inside the same second does not sweep — proved by a test-facing per-box sweep counter (AtomicU64 on BoxPins, #[cfg(test)] reader sweeps_of, maintained at the sweep in every build like the table's other counters, since a sweep that reclaims nothing leaves no other trace). (3) At-cap visibility: per-box AtomicU64 at_cap_admitted with #[cfg(test)] reader at_cap_admissions_of, and the per-frame debug!…[truncated] |
|
Approved: no findings at Nothing to do. Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it. Clobber: none: |
norrietaylor
left a comment
There was a problem hiding this comment.
Reviewed at 700c63d: round-5 asks and the architecture conditions are met (per-box cap, swept table, counted admits, NET-062 silent drop); mutation checks fail as expected.
T74 — Decide a DNS box's destinations on the host from the answers its own queries received
Covers NET-081, NET-066, NET-067 (
docs/specs/18-spec-box-networking/18-spec-box-networking.md).Scope. The guarantee holds per registered row. A box whose frames come from the switch address its row holds reaches only the addresses its own lookups returned, even when a hostile in-VM relay carries them. Frames from an allocatable address that no row holds are a separate case: while the unregistered-source phase stays
Announced, they are admitted except to the infrastructure set. Closing that is #1790's job.What changes
crates/minvmd/src/net/dns_pins.rs(new): the host-side DNS admission table, one entry per registered box that declaredallow_dns_hosts. A reply pins only when all of the following hold:DNS_OUTSTANDING_QUERY_CAPandDNS_QUERY_EXPIRY, and a match consumes it, so a replay pins nothing.Only A records on the answer chain pin: the walk starts at the question and follows CNAMEs, and the authority and additional sections are never read. AAAA, SVCB and HTTPS never pin.
At intake, a row whose resolver is not the plan's host-side resolver gets no entry, and the refusal is logged once. A reply-shaped frame on the guest→switch leg is an
egress-unknown-sourcedrop and pins nothing.Answers pass
sessions::core::egress::rebinding_intersectionagainst the row'sdeny_subnetsand the infrastructure set before entry. Each refused answer writes one rate-limited warn line naming the name, the answer and the rule.The window, the per-name cap, the used-pin retention and the per-box flow cap come from
sessions::core::egress. Entries are retired with the relay connection that ends the row, and rebuilt fail-closed for a replacement row.Per-box flow cap. A box holds at most
DNS_MAX_FLOWS_PER_BOX(4096) flows opened through its pins, and the cap is keyed per box, so one box at the cap never affects another's retention. At the cap:DNS_FLOW_IDLE_CAPare swept, at most once per second per box;info, so it reaches a bundle's log tail).crates/minvmd/src/net/egress_gate.rs: the deferral arm is gone. A DNS row's undeclared-destination drop is decided on the host: a live pin, or a flow a pin established, admits the frame; anything else drops it underegress-undeclared-subnet. For every row, the following are still decided before the pin arm:The ingress leg is framed and every frame is passed through verbatim; DNS replies are read on the way. The gate counts frames admitted by a pin and frames refused for want of one.
crates/minvmd/src/net.rs/box_registry.rs: the row carries itsallow_dns_hosts. The run path builds the table and hands it to the gate. The interim "deferred to the guest's gate" line is removed.crates/sessions/src/core/egress.rs:DNS_ADMISSION_WINDOW,DNS_MAX_ADDRESSES_PER_NAME,DNS_FLOW_IDLE_CAP,DNS_OUTSTANDING_QUERY_CAP,DNS_QUERY_EXPIRYandDNS_MAX_FLOWS_PER_BOX(host table only).0.0.0.0/8,224.0.0.0/4,240.0.0.0/4and255.255.255.255/32.::/128,::1/128,::ffff:0:0/96) is recorded for the IPv6 epoch. It decides nothing in v1.crates/minimald/src/net/dns_gate.rs: reads the shared constants (same values) and documents itself as the in-VM precision copy. No behaviour change. It adds a test proving the completed infrastructure set refuses and logs on this leg too.Files outside the plan's
layers:are justified:crates/sessions/src/core/egress.rsholds the shared constants the layer text requires.crates/minvmd/src/box_registry.rslets the row carry its declared names.crates/minvmd/Cargo.tomlandCargo.lockaddhickory-proto, the parser minimald already uses.The admission window is the fixed 5 minutes both legs already used, not a TTL-derived window. The departure from design §5.3's proposed TTL floor and cap is recorded at the constant.
The pin and at-cap counters are maintained in every build. They are read only by tests for now: exposing them through minvmd's control surface needs a new control verb and is a follow-up.
Tests
cargo nextest run -p minvmd dns_box_undeclared_destination_decided_on_hostcargo nextest run -p minvmd host_pins_are_the_answers_the_box_receivedcargo nextest run -p minvmd host_window_refuses_denied_and_infrastructure_rangescargo nextest run -p minvmd hostile_relay_reaches_only_the_pinned_answerscargo nextest run -p minvmd host_side_rules_applied_outside_vmcargo nextest run -p minimald dns_pinned_admission_windowBeside the plan lines, the architecture review's conditions are proved by:
a_reply_forged_on_the_guest_side_pins_nothinga_row_whose_resolver_is_not_the_plans_own_is_refusedonly_a_reply_to_the_boxs_own_outstanding_query_pins(fails if the reply match stops consuming its query)only_the_answers_chain_pinsthe_flow_table_is_bounded_per_box(cap, per-box keying with a second box, at-cap counter, one info line per box per minute)at_the_cap_one_sweep_per_second_reclaims_the_idle_flows(the sweep reclaims an idle flow and runs at most once per second per box)host_window_refuses_this_host_multicast_broadcast_and_reserved_answersa_closed_relay_connection_retires_the_pins_it_filleda_replacement_row_inherits_neither_pins_nor_flowsthis_host_and_multicast_answers_are_refused_and_loggedThe NET-068 toolchain harness landed on main with #1771 (
crates/minvmd/tests/egress_allowlist_integration.rs) and is this path's regression oracle.Closes #1808