Skip to content

fix(minimald): record VM refusals on the host and admit RPC only from the host (0.7.0 backport) - #2735

Closed
norrietaylor wants to merge 8 commits into
release/0.7.xfrom
fix/net-vm-refusals-host-rpc-0.7.0
Closed

norrietaylor wants to merge 8 commits into
release/0.7.xfrom
fix/net-vm-refusals-host-rpc-0.7.0

Conversation

@norrietaylor

Copy link
Copy Markdown
Member

Backports #2721 (task T107, #2694) to release/0.7.0. It is a security fix:

  • The in-VM daemon's vsock RPC listener accepts only the host's CID. Any other peer is refused, and the refusal is logged, rate-limited per CID.
  • The VM's egress refusals and expose decisions are recorded in the audit log on the host, outside the VM.

Stacked on #2678; merge that first. #2678 carries the 0.7.3 version bump and the pulldown-cmark advisory fix. Until it merges, this diff also shows #2678's commits.

Commits

It does not compile without the second commit, so squash-merge the pair. All of #2721's tests are kept, with no assertion dropped.

Verification (Linux, Lima)

  • just clippy and just fmt-check are clean.
  • New tests pass: vsock_rpc_refuses_non_host_cid, refused_peer_line_is_rate_limited_per_cid, expose_unenrolled_decision_audited (minimald); expose_decision_recorded_on_host, egress_refusal_logged_on_host (minvmd).
  • minimald: 998 passed, 1 failed, the VM-only cgroup EACCES failure session_host::tests::a_hook_launch_does_not_advise_unenforced_placement seen on the unmodified fix(net): backport the deny-all DNS refusal and the owner-only answerer socket to 0.7.0 #2678 head too. minvmd 536 passed, minimald-rpc 65 passed, minimal-client 104 passed.
  • The scripts/session-e2e.sh change is left to the VM e2e lanes.

gominimal-aw-bot Bot and others added 7 commits October 27, 2026 20:37
* fix(minimal,minvmd): hold the answerer channel socket owner-only

The box-zone answerer's channel socket was world-connectable: the
launchd plist bound it SockPathMode 0666 and the systemd socket unit
SocketMode=0666, leaving the peer-uid gate the only check on who may
connect. Both units now bind it owner-only -- SockPathOwner the
operator, SockPathMode 0600 on launchd; SocketUser the operator,
SocketMode=0600 on systemd -- with the uid gate kept as defence in
depth.

An install whose socket node carries group or other bits -- one that
predates the mode, or a hand that relaxed it -- now fails custody
through a channel_mode fact, so the advisory re-surfaces and a step
re-run re-binds the socket. The accept loop's foreign-refusal warn is
rate-limited to a few lines a second, so a connect storm cannot flood
the log; the refusals themselves are never limited.

* fix(minimal,minimald,minvmd): name the other account on a refused channel connect

A daemon whose connect the owner-only channel socket refuses now says
the host's DNS service belongs to another account, not a bare
Permission denied. The answerer step needs the operator's account to
resolve, with no stand-in uid, and custody fails a channel socket the
operator does not own.

* fix(minimal,minvmd): leave another operator's DNS service alone

A channel socket owned by another existing, non-root account is that
operator's service: the answerer step is now unavailable with the same
sentence the daemons say on a refused connect, instead of a custody
failure whose step would reinstall the unit and take the service over.
A root-owned socket, or one whose uid names no account, still fails
custody so the step re-binds it.

The minvmd tests that take the process-global foreign-refusal slots
now run one at a time and start and end with every slot free, and the
warn-rate test bounds the burst at two windows' worth of lines, so a
slow runner that spreads the burst does not fail it.

* fix(minimal): offer the step over a socket another account left behind

A channel socket another account owns refuses the answerer step only
when a service is installed; with none, the step's install removes the
leftover socket before it loads the unit, so it is offered.

---------

Co-authored-by: gominimal-aw-bot[bot] <281738952+gominimal-aw-bot[bot]@users.noreply.github.com>
(cherry picked from commit 746770d)
…er (#2300)

* fix(net): refuse out-of-zone names at a guest deny-subtree DNS listener

A deny-all host-address box on a VM-backed guest resolved out-of-zone
names at the switch gateway: the interim NET-079 carve-out admitted the
gateway's port 53 whole, UDP and TCP, so a box that admits no destination
could still ask a resolver beyond the machine — and DNS over TCP could
retry past the verdict.

The guest's deny subtree now steers its UDP-53 lookups onto a loopback
listener on the answerer's port (NET-141 slice 2): deny_out admits the
listener beside the reply direction, the dstnat match carries no
destination address (the box asks the gateway like every other
host-address box; the steer is the carve-out), and the listener itself
answers REFUSED for every name outside the box zone — apex and a
non-lowercase zone suffix among them — NODATA for an in-zone non-A
question, and forwards the zone's A questions to the switch gateway
alone. DNS over TCP is neither steered nor admitted.

The guest daemon starts the listener after its classifier table loads;
the daemon's own lookups are untouched (cgroup-keyed match, deny path
only). The interim --gateway-resolver installer flag and every test,
digest and pin that spelled the interim carve-out follow the new shape.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(net): bound and pin the guest DNS listener's forwards

Connect each forward socket to the gateway so a datagram from any other
sender is dropped, cap forwards in flight so a flood cannot exhaust the
daemon's descriptors, and drop the needless to_string calls clippy
rejects in the guest classifier integration test.

* fix(net): refuse questionless and non-QUERY messages at the guest DNS listener

decide() forwarded a message with no question, and an UPDATE or NOTIFY
whose zone section named an in-zone A, because every per-question check
passed vacuously. Answer the first REFUSED and the rest NOTIMP, so the
forward path carries only standard lookups.

Bind the listener directly so its log does not read as the box-zone
answerer, pin the integration test's boot-log check to the exact
example.com REFUSED line, and cite NET-079 (the deny-all case) rather
than NET-141 at the lines this change added.

---------

Co-authored-by: gominimal-aw-bot[bot] <281738952+gominimal-aw-bot[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 2c2f8cc)
crate::traced landed on main after the release branch was cut, so the
cherry-pick of #2300 did not compile here.
v0.7.2 is tagged at the branch head, so the version check requires the
next patch release.
… the host (T107) (#2721)

* fix(minimald): refuse vsock RPC peers other than the host CID

The in-VM daemon's vsock listener now drops a peer at any CID but 2 at
accept, before reading a byte, and writes one rate-limited audited line
naming the CID (NET-139).

* feat(minvmd): keep the guest's expose and egress audit on the host

The in-VM daemon reports each expose decision and each refused
own-address egress flow over the guest door. The VM host daemon appends
them to its audit log, one record per flow, capped per box with a line
that counts the suppressed records (NET-046).

* test(e2e): expect the box's deny on the host audit (T107)

The VM lane asserted that a deny decided in the box left no host audit
line (T84). NET-046 now reports every expose decision to the host, so
assert exactly one expose_decision line with decision deny, decided_by
box-policy and outcome refused. The T94 empty runtime check stays.

* test(e2e): match the gate drop line, expect the relay's host audit

The no-lane check matched the host audit record that minvmd::control writes
for a relay refusal. Match only the gate's rule_matched field, and assert the
relay's refused-egress record for e2e-cred-nolane is on the host.

* test(e2e): match only the gate drop line in the proxy-views group

The laneless box check in the proxy-views group matched the host audit
record that minvmd::control writes for a relay refusal. Match only the
gate's rule_matched field, and assert the relay's refused-egress record
for e2e-psba-nolane is on the host.

* fix(minvmd): give expose audit its own cap and flush on withdraw

A flood of refused egress flows no longer uses up the records an expose
decision needs. A withdrawn box's window ends and writes its suppressed
count, so a box that goes quiet still leaves the count in the log.

* fix(minvmd): mark guest-reported host audit records reported_by guest

The host copies an expose decision and a refused egress from the
in-VM daemon's report and does not observe them. Each record and its
log line now carry reported_by=guest, and the unit tests and the e2e
checks assert it.

* fix(minvmd): rotate the host audit log at a fixed size

box-admissions.log rotates to one kept generation (.1) at 1 MiB, the
same bound the in-VM daemon's audit log uses, so a guest cannot grow
it without end. The per-box caps bound only the rate.

---------

Co-authored-by: minimal-foundry[bot] <327719912+minimal-foundry[bot]@users.noreply.github.com>

(cherry picked from commit abe99f7)
…ease/0.7.0

The cherry-picked change names main's types and crates. Release/0.7.0
predates the box renames and the Box Egress Proxy's host-side verbs, so
the backport uses the release's own names:

- boxes::DynamicIngress is sessions::DynamicIngress in the audit report
  path (net/listeners.rs) and in the minimald and minvmd tests.
- minvmd has no serde_json dependency here, so the host audit tests
  parse the log with serde_json_lenient, as the release's other minvmd
  tests do.

The cherry-pick's conflicts were resolved to the same shape:

- The release has no ProxyListening verb or reply, so the new
  ReportExposeDecision, ReportRefusedEgress and Audited arms stand
  without it, and the minvmd test panics name the audit report's
  answer.
- crate::traced does not exist here, so the listen watcher still spawns
  with tokio::spawn; the audit route is registered before the spawn and
  removed after the watcher's withdraw_all, as on main.
- The release keeps the server tests inline in server.rs, so the vsock
  peer-CID refusal tests join that module.

The behaviour is #2721's: the in-VM daemon's vsock RPC listener serves
only CID 2 (NET-139), and the guest's expose decisions and refused
egress flows are recorded in the host's audit log under per-box caps
(NET-046).
@norrietaylor
norrietaylor requested a review from a team as a code owner October 28, 2026 21:13
@coderabbitai

coderabbitai Bot commented Oct 28, 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: ef68cd1a-9027-4bec-960d-8b2c109bf0df

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 28, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed: 1 finding, none blocking at a0785e9a94fc.

Address the comments on the diff.

Clobber: none seen.

@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 — advisory review

Verdict COMMENT — 1 finding, 1 inline.

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

/// rotated before it, and starts a fresh file. One kept generation bounds
/// the log at about twice this size. The same bound and shape as the in-VM
/// daemon's own audit log (`minimald`'s `audit::MAX_LOG_BYTES`).
const MAX_AUDIT_LOG_BYTES: u64 = 1024 * 1024;

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.

MEDIUM · correctness · confidence 0.50 · in append_audit_line_capped

The host audit log rotates at 1 MiB and keeps one generation. Guest-reported records go into the same file as the host's own admission and ask records. A box that reports many distinct refused flows (30 per minute per box) pushes older admission records out of the log, and the loss cannot be undone. Consider a separate file or a larger bound for guest-reported records, so a box cannot age out the host's own records.

What the reviewer checked

const MAX_AUDIT_LOG_BYTES: u64 = 1024 * 1024; append_audit_line_capped renames path to path.1, replacing the older generation

Hand this to an agent
Act on a code-review finding.

File:       crates/minvmd/src/control.rs
Lines:      2261-2261
Category:   correctness
Severity:   medium (reviewer confidence 0.50)

Finding:
The host audit log rotates at 1 MiB and keeps one generation. Guest-reported records go into the same file as the host's own admission and ask records. A box that reports many distinct refused flows (30 per minute per box) pushes older admission records out of the log, and the loss cannot be undone. Consider a separate file or a larger bound for guest-reported records, so a box cannot age out the host's own records.

First verify this against the code yourself. It is model output and
may be wrong. If it is wrong, or the tradeoff was deliberate, say so
and change nothing.

👍 useful · 👎 noise — react to tell the reviewer. Replying works too, and says more.

…efusals-host-rpc-0.7.0

# Conflicts:
#	scripts/install-host-classifier.sh
@norrietaylor norrietaylor reopened this Oct 30, 2026
norrietaylor pushed a commit that referenced this pull request Nov 5, 2026
… the host (#2721)

T107. The in-VM daemon's vsock listener drops a peer at any CID but 2 at accept, before
reading a byte, and writes one rate-limited audited line naming the CID (NET-139). The
in-VM daemon reports each expose decision and each refused own-address egress flow over
the guest door, and the VM host daemon appends them to its audit log under per-box caps,
with a line counting suppressed records (NET-046). Expose decisions keep their own cap, a
withdrawn box flushes its window, guest-reported records carry reported_by=guest, and
box-admissions.log rotates to one kept generation at 1 MiB. The session e2e script expects
the new host audit records.

Backport of #2721, folded from #2735.

Adapted to the line:
- boxes::DynamicIngress becomes sessions::DynamicIngress.
- The line has no ProxyListening verb or reply, so ReportExposeDecision,
  ReportRefusedEgress and Audited stand without it.
- The listen watcher keeps tokio::spawn, since crate::traced is absent. The audit route
  is registered before the spawn and removed after the watcher's withdraw_all.
- minvmd has no serde_json here, so its host audit tests parse with serde_json_lenient.
- The vsock peer-CID tests join the inline tests in server.rs.

Dropped: ask_audit_line_spells_box_id_as_32_hex, which reached the cherry-pick as conflict
context from main's proxy work and is not part of #2721.

(cherry picked from commit abe99f7)
@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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant