Skip to content

tests: give the runtime adapter's executions their network's settings - #882

Open
Enrique Saurez (esaurez) wants to merge 3 commits into
esaurez/822-pr09-network-policy-plan-20261023from
esaurez/822-pr10-guest-network-settings-20261023
Open

Enrique Saurez (esaurez) wants to merge 3 commits into
esaurez/822-pr09-network-policy-plan-20261023from
esaurez/822-pr10-guest-network-settings-20261023

Conversation

@esaurez

@esaurez Enrique Saurez (esaurez) commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #866; this PR retargets when its parent merges.

Chain: #863 → #867 → #869 → #865 → #864 → #872 → #875 → #878 → #862 → #868 → #870 → #866 → #882 (this PR) → #883.

Part of #822: PR 10 of 11, the guest's settings.

What changed

  • The root configuration gains an optional field, listeners (root::Listeners: published or unpublished), which says whether the sandbox's listeners are published. It is the 17th field, after workload-uid and workload-gid; no other field moves, and the version stays 1. Without it, the listeners are published, as nvx::guest::entry's default has them, which refuses the most to the executions.
  • The worker builds the sandbox of its executions through its one seam, worker::executions::Sandbox::new(identity, publication), with the publication that the configuration names; the hostname stays the entry's default. Executions, and the check of the account of the sandbox's workload identity, enter the root with that publication (worker::Entrance::publication). While the listeners are published, the entry refuses CAP_NET_BIND_SERVICE and CAP_NET_RAW at stage 0, with which a workload could forge the announcements of its listeners.
  • A layered launch names the publication of its network as OpenVMM publishes listeners: LayeredLaunch::with_network puts the network on the plan, with the listeners published when ingress or host-loopback access is allowed, and unpublished otherwise, or without a network.
  • The host gives each execution the URL of a proxy-only network's proxy (SandboxPlan::proxy_url) in the proxy variables of its environment, layered::PROXY_VARIABLES (http_proxy, https_proxy, HTTP_PROXY, and HTTPS_PROXY), after its own entries, with layered::with_proxy; a start that names any of them keeps its own proxy settings. The host program's exec reads the plan that the launch recorded, with LaunchRecord::read_plan. Before it attaches, exec checks that the framing still carries each start with the proxy's variables, and runs none of the executions if one no longer fits.
  • The network device, its addresses, and the announcer of the guest's listeners stay with NVX's /init.
  • The adapter's README and the module docs describe the field, the publication, and the proxy.

Tests

  • src/root.rs: the field's encoding, last, its decoding, and the configurations that the guest refuses for it.
  • tests/guest_session.rs, guest-only: an_execution_enters_the_root_with_the_publication_of_listeners_that_its_configuration_names, without the field, and with each publication: the refusals at stage 0 while listeners are published, the capabilities that the entry still allows, and the account check of a workload identity, which enters with the configuration's publication.
  • tests/layered_launch.rs, host-only: the publication that a launch names for each element of a policy; an_execution_finds_the_url_of_its_network_s_proxy_in_its_environment, for each scheme and with a start that names its own proxy; and the_record_of_a_launch_gives_back_its_plan.
  • tests/vm_layered.rs, on a real hypervisor: executions_take_the_settings_of_a_proxy_only_network, which on Linux also has exec refuse, before it attaches, a batch with a start that the framing carries alone but not with the proxy's URL, none of whose executions runs; and published_listeners_refuse_binding_and_raw_sockets.

Validation

  • Windows (local), in tests/runtime-adapter: cargo fmt --all --check; the protocol-only and host-only configurations' cargo clippy --locked --all-targets [--features host] -- -D warnings, cargo build --locked, cargo test --locked, and cargo +1.89 check --locked --all-targets.
  • Linux (x86_64), in tests/runtime-adapter: the same, plus the guest-only configuration (--features guest --target x86_64-unknown-linux-musl): clippy, build, tests, and the MSRV check; the guest-only library and guest_session tests as root; and a stress run of guest_session, 10 times as root and 10 times as a user, and of the library's tests, 3 times as root.
  • VM tests at tests: enforce the runtime adapter's networks in VMs #883's head, which adds only tests to this PR's code: vm_layered (43 scenarios), vm_restart (3), and vm_steps (3) on WHP (local) and MSHV (Linux x86_64, as root).
  • python scripts/check_markdown_links.py.
  • Left to CI: everything, once this PR targets dev, KVM included; a stacked PR runs no NVX CI.

Enrique Saurez and others added 2 commits October 24, 2026 13:36
The root configuration gains an optional listeners field, after the
workload identity, which says whether the guest's listeners are
published. Executions, and the account check of a workload identity,
enter the root with that publication, so that while listeners are
published the entry refuses CAP_NET_BIND_SERVICE and CAP_NET_RAW at
stage 0. A layered launch names the publication of its network as
OpenVMM publishes listeners: with ingress or host-loopback access
allowed, and none without a network.

The host gives an execution's start the URL of a proxy-only network's
proxy in the proxy variables of its environment, with
layered::with_proxy, from the plan that LaunchRecord::read_plan reads
back from the store. The network device, its addresses, and the
announcer of the guest's listeners stay with NVX's /init.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a7c15634-094a-4a66-af59-25a58e732f4b
The host program's exec reads the plan that the launch recorded, and
gives each execution the URL of the proxy of the VM's network, if any,
in its environment with layered::with_proxy, after its --env entries,
unless they name the proxy variables themselves.

The VM scenarios can now give their VM a network, which the launch reads
from a file that the scenario writes. In a proxy-only network, the
executions find the proxy's URL in their environment, and root may hold
CAP_NET_BIND_SERVICE and CAP_NET_RAW. A network with ingress allowed
publishes the guest's listeners, so the guest refuses both at stage 0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a7c15634-094a-4a66-af59-25a58e732f4b

Copilot AI 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.

🟡 Changes recommended

Proxy injection can invalidate a later start after earlier executions have already been sent, so the augmented batch needs validation before submission.

1 open issue
What changed in this PR

This PR connects the runtime adapter’s execution settings to its sandbox network policy, advancing #822’s end-to-end sandbox support.

Changes:

  • Adds listener-publication configuration and passes it into guest capability checks.
  • Supplies proxy environment variables from the recorded launch plan while preserving caller overrides.
  • Adds configuration, host, guest, and VM coverage with updated documentation.
File Description
tests/​runtime-adapter/​tests/​vm_layered.rs Adds proxy and published-listener VM scenarios.
tests/​runtime-adapter/​tests/​layered_launch.rs Tests publication, proxy injection, and plan readback.
tests/​runtime-adapter/​tests/​guest_session.rs Tests publication-dependent capability admission.
tests/​runtime-adapter/​src/​worker/​executions.rs Carries sandbox publication into execution entry.
tests/​runtime-adapter/​src/​worker.rs Applies configured publication to entry and account checks.
tests/​runtime-adapter/​src/​root.rs Defines and validates the optional listeners field.
tests/​runtime-adapter/​src/​lib.rs Documents execution network settings.
tests/​runtime-adapter/​src/​layered.rs Derives publication, injects proxies, and reads recorded plans.
tests/​runtime-adapter/​src/​bin/​runtime-adapter-host.rs Integrates network settings into launch and execution commands.
tests/​runtime-adapter/​README.md Documents configuration, behavior, and test coverage.

Review effort: Balanced

Comment thread tests/runtime-adapter/src/bin/runtime-adapter-host.rs Outdated
The proxy's variables lengthen an execution's start, so a start that the
framing carried when exec parsed its command line may no longer fit once
exec gives it the proxy of the VM's network. exec found out only as it
sent that start, after it had sent the starts before it, and then failed
without collecting their outcomes.

exec now gives every start the proxy's variables, and checks each as it
checked them without the proxy, before it attaches; it runs none of the
executions if one no longer fits. A start takes its key once exec has
attached, and a key's encoding has the same size whatever its value.

On Linux, whose command lines carry a start as long as the framing
allows, the proxy-only VM scenario checks that exec refuses such a batch
before it attaches, that none of its executions ran, and that the VM
still runs the next command's executions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a7c15634-094a-4a66-af59-25a58e732f4b

Copilot AI 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.

🔵 Needs a closer look

Network-dependent capability permissions warrant human review while backend CI, including KVM validation, remains pending.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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.

2 participants