Skip to content

feat(driver-kubernetes): KubeVirt runtime mode for VM-backed sandboxes - #5715

Draft
jhjaggars wants to merge 24 commits into
ai-openshell:mainfrom
jhjaggars:kubevirt-compute-driver
Draft

jhjaggars wants to merge 24 commits into
ai-openshell:mainfrom
jhjaggars:kubevirt-compute-driver

Conversation

@jhjaggars

@jhjaggars jhjaggars commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a runtime = "kubevirt" mode to the Kubernetes compute driver: each sandbox runs as a kubevirt.io/v1 VirtualMachine instead of an agents.x-k8s.io Sandbox CR reconciled into a pod. The driver still owns what the gateway needs — a per-sandbox egress fence, the boundary bootstrap, a workspace PVC, and one supervisor per sandbox — and the sandbox API, gateway API, and policy model are unchanged. Only where the workload runs changes.

The guest is an ordinary, capability-free sandbox. The driver renders the pod path's boundary artifacts into a cloud-init payload; the guest init stages them on a tmpfs and runs openshell-sandbox launch-capability-free as the guest image's unprivileged account (10001:10001). A KubeVirt sandbox therefore keeps the in-guest posture a pod sandbox has — capability drop, no_new_privs, Landlock, child seccomp — behind the per-sandbox fence, with the supervisor's policy deciding what leaves. Privileged (true guest root) workloads are not part of this PR.

One supervisor per sandbox. A dedicated supervisor Pod per sandbox, reusing the pod path's supervisor Pod, boundary Service, bootstrap Secret, and control-policy renderers with VirtualMachine owner references. supervisor_topology = "gateway" is rejected for this runtime; the config validation says so and the doc comment that claimed otherwise is fixed.

What is in it

  • Runtime dispatch and lifecycle (src/driver.rs, src/kubevirt.rs): create/get/list/watch/stop/start/delete mapped onto VM/VMI state, Halted/Once run-strategy handling, terminal VMI and main-process-exit mapping, the create's in-flight annotation and its deadline, and CPU/memory mapping onto the VM (whole vCPUs for the guest, requests/limits on the virt-launcher container, pod-path resource admission, GPU requests rejected).
  • Boundary delivery (src/kubevirt_boundary.rs): the pod path's render_boundary_bootstrap output plus session TLS, base64-encoded into shell-sourceable userData. No gateway endpoint, no gateway token. The generation's bootstrap Secret is immutable and named <vm>-boot-<generation>.
  • Fence: a per-sandbox NetworkPolicy selecting the virt-launcher Pod and admitting only that sandbox's supervisor, on top of a namespace-wide default-deny floor. The expected fence (UID + rendered spec) is persisted on the VM, verified on every start (drift fails the start), and a 30-second reconciler re-renders and restores a drifted, replaced, or deleted fence. A VM whose generation ends while the guest keeps running is halted.
  • Workspace: a per-sandbox PVC over virtio-fs at /sandbox, idmapped to the workload uid in the guest.
  • Image identity: the launcher's pulled digest is pinned onto the VM spec on the reconcile tick, so a tag move cannot change what a later start boots.
  • Helm: least-privilege RBAC for kubevirt.io and networking.k8s.io objects, the preflight, and unittests.
  • Docs: configuration.mdx (the runtime = "kubevirt" block and the kubevirt table), runtimes.mdx, the crate README's KubeVirt section, and e2e/kubevirt/README.md.
  • e2e: e2e/kubevirt/ — a 10-step acceptance run that creates, execs, exercises L4/L7 policy and the egress block, stops and starts, verifies fence drift handling, checks the dead-runtime Error, and deletes with zero leftovers. This lane is manual and stays that way in this PR: it needs a cluster with nested KVM, a KubeVirt install, and a purpose-built guest image, so nothing in e2e/rust, e2e/run.sh, tasks/, or CI schedules it.

Closes #5714

History note

The branch merges upstream/main (merge commit, not a rebase), so the PR branch only ever fast-forwards. An earlier revision of this branch added a "sandboxed vs root workload" mode split and then withdrew it four commits later; this revision also drops the root-workload subsystem the branch had accumulated along with it. The net contents of the PR are the runtime mode described above: the supervisor, supervisor-network, supervisor-process, isolation-interface, ocsf, and policy crates are byte-identical to main, and openshell-sandbox differs from main in one file (VM policy identity keys on the shared is_vm_guest() predicate, which now covers both libkrun and KubeVirt guests).

Testing

  • Unit tests: openshell-driver-kubernetes 425 + 2 integration tests, plus the touched crates (openshell-sandbox, openshell-sandbox-backend, openshell-isolation-interface, openshell-ocsf, openshell-policy, openshell-supervisor, openshell-supervisor-network, openshell-supervisor-process).
  • Static checks: cargo fmt --all -- --check, cargo clippy --workspace --all-targets --features experimental -- -D warnings, the sandbox's perf-harness clippy pass, cargo check --workspace --all-targets, markdown lint, SPDX header check, and the Cargo lockfile check.
  • Live, once, by hand: the 10-step acceptance run against a throwaway k3d cluster (k3s v1.35.9) with KubeVirt v1.9.1 and /dev/kvm, using the images built from this branch. Every step passed: create → Ready, fence and its podSelector, exec as uid 10001 with no effective capabilities, clean workload environment, L4 allow/deny and L7 GET-allow/POST-deny through the supervisor, direct egress and raw DNS blocked, stop/start with the VM UID and fence UID unchanged and a rotated, re-claimed supervisor Pod, fence spec drift failing start with the reconciler restoring it, main-process exit → Error (exit code 137), delete with zero leftover managed objects. The cluster and all images built for it were removed afterwards.
  • Branch Checks have not run on this branch yet; workflows on this fork are held until a maintainer vets the account.

Not in this PR

  • Privileged (true guest root) workloads for VM sandboxes.
  • GPU passthrough for VMs, live migration/VMI replacement, operator workspace mode, and arbitrary OCI images as VM disks (the guest image is a purpose-built containerDisk).
  • Wiring the KubeVirt e2e into the automated harness.

Checklist

  • Commits follow Conventional Commits and are DCO signed off.
  • Architecture/user docs updated in the same PR.

…lders

Activity builders (process, network, HTTP, API activity, finding, config)
gain an unmapped-field map so callers can attach OCSF extensions, and the
process builder gains guest_sourced(): a data_origin=guest marking for
events whose payload was reported by an in-guest boundary rather than a
supervisor-verified observation. The shorthand formatter renders the
marker at a fixed position and escapes guest-controlled fields (process
names, command lines) with bracket escaping, so a forged name cannot
render a marker or start a forged line. Process events now require an
actor_process, matching the typestate builder.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
…leged VMs

ResolvedWorkloadIdentity::new refuses UID/GID zero, which is the right
invariant for container and sandboxed-VM workloads. The privileged
root-workload VM class deliberately runs the workload as root — kernel
separation is the boundary — so new_privileged() constructs the identity
for that class. It is gated on the workload mode at the call site.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
restrictive_default_policy_privileged() keeps the restrictive network
posture of restrictive_default_policy() but omits the filesystem,
Landlock, and process-identity sections: in-guest enforcement is
meaningless against a root workload, so the default must not promise
constraints that cannot be enforced. Policies that author those sections
are rejected by supervisor validation in privileged mode.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
…ndaries

Provisioning evidence gains validate_privileged(): a root-workload
boundary honestly reports no seccomp/Landlock/no_new_privs evidence
because none are enforced in that mode — the security boundary is
outside the guest — while kernel release and architecture must still be
present. Resource-claim constants mark KubeVirt guest generations
(kubevirt.generation), the workload mode (kubevirt.workload_mode, with
root selecting the privileged mode), and is_vm_guest() gives VM guests
VM policy-identity semantics (run_as_user/group must be sandbox or the
resolved guest uid/gid). The audit path and runtime records carry the
launch shape a VM boundary reports.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
The in-guest boundary (openshell-sandbox) learns two VM-mode behaviours:

- Root-workload mode: the boundary runs the workload as root without
  seccomp-notify interception, Landlock, or process identity; the
  network broker is either constructed as designed-unavailable (no
  pending channels, confirm_healthy succeeds by design) or, with the
  nftables transparent relay, feeds relayed connections through the
  same Mediate accept/decision/bridge flow the seccomp broker uses.
  The loopback DNS relay gains an admit_unregistered mode for the
  relay path (the seccomp broker that registers workload DNS sockets
  is absent).

- network_relay.rs: the nftables transparent TCP relay for privileged
  guests — capture ruleset plus listeners that hand relayed streams to
  the broker, so the supervisor's proxy and policy DNS run unchanged.

Guest-reported process exits are emitted with the OCSF guest-sourced
marker when running privileged.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
The supervisor learns the privileged (root-workload) mode end to end:

- validate_policy_enforceable_in_privileged_mode() rejects policies
  that author filesystem/Landlock/process-identity sections when the
  boundary reported the privileged workload mode — the default must not
  promise in-guest constraints that cannot be enforced.
- Main-process and adopted-exec exits are boundary-reported; in
  privileged mode those OCSF events carry the guest-sourced marker
  (the boundary is untrusted after start).
- The SSH access plane and boundary-access startup thread the
  privileged mode through; the supervisor pool records the topology.
- Policy DNS gains the mapping answers the guest's loopback resolver
  relies on in VM mode.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
A new runtime mode for the Kubernetes compute driver: set
runtime = "kubevirt" and each sandbox becomes a KubeVirt
VirtualMachine instead of a pod. The sandbox API, gateway, and security
model are unchanged; only where the workload runs changes.

The driver creates the VM halted first (to capture its identity for
security claims), plus the companions: a bootstrap Secret delivered to
the guest via cloud-init (one-shot: the guest init reads it once and
removes the PCI function backing the disk), a per-sandbox workspace PVC
shared over virtio-fs, an egress fence (NetworkPolicy admitting only
the supervisor), and — in the default dedicated topology — one
supervisor Pod per sandbox. The VM is only marked Running once the
boundary's session connects; stop/start preserve the VM and fence
identities; the fence is reconciled when it drifts and verified (UID +
spec) on every start.

Two workload modes: sandboxed (workload uid 10001, full in-guest
enforcement) and root (workload uid 0, in-guest enforcement demoted by
design — the fence and the supervisor's policy evaluation are the
boundary; the guest is untrusted after the first workload runs). After
the first boot the VM spec pins the guest image by digest.

Trust model: nothing in-guest is a trust anchor. dm-verity is
deliberately absent (a root workload may rewrite the base disk); the
root disk is wiped on every stop/start (RAM overlay over a read-only
base); guest-reported data is marked data_origin=guest in OCSF logs.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
The gateway role gains the rules the kubevirt runtime needs:
virtualmachines/virtualmachineinstances (get, list, watch, create,
patch, delete) from kubevirt.io, and networkpolicies (get, list, watch,
create, patch, delete) from networking.k8s.io for the egress fence and
its reconciler. RBAC unit tests cover the added rules.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
The PoC's e2e harness for the kubevirt runtime mode, run against a
local k3d cluster with KubeVirt deployed (see e2e/kubevirt/README.md):

- build-guest-image.sh builds the guest containerDisk (Alpine rootfs +
  static musl supervisor + guest init + kernel, repacked initramfs).
- demo.sh starts a host gateway against the cluster; --demo runs
  run-demo.sh, the 10-step acceptance demo (create/Ready, exec,
  L4/L7 policy, bypass blocked, stop/start identity, fence
  verification, dead-runtime Error, zero leftovers); --probes runs
  run-probes.sh, the root-workload attack-surface probes (in-guest
  reset, fake qemu-guest-agent, virtiofsd privileged operations,
  launcher-netns listener audit, and the config-disk eject limit:
  a root PCI rescan re-enumerates the ejected disk — the eject is
  hygiene, not a control).
- demo-policy.yaml / demo-policy-root.yaml: the policies the demo and
  probes run under.
- supervisor-values.yaml: shared-supervisor topology values for the
  gateway-topology variant.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
Describe the runtime = "kubevirt" selection, its kubevirt.* TOML table
(guest image, pull policy, cores, memory, workload mode), the
supervisor topology options, and the security posture the mode
guarantees (enforced outside the guest; the guest is untrusted after
the first workload runs in root mode).

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
@copy-pr-bot

copy-pr-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the state:accepted A maintainer decided OpenShell should pursue this issue label Nov 18, 2026
…trol

Guest configuration — the nftables relay, the seccomp broker's
steering, the config-disk eject — is required for networking to
function and is never relied on for security, because the guest
grants root. Every security property is enforced outside the guest:
the NetworkPolicy fence (only the supervisor is reachable), the
supervisor's policy (decides what leaves), and the driver's checks
of the VM UID and fence spec.

Reword the four places that counted the relay as a protection: the
demo's egress-fencing item (blocked 'at both the boundary and the
pod network'), the trust-model list ('NetworkPolicy + the nftables
relay's fail-closed deny'), the outside-boundary reliance ('the
fence and the relay's deny'), and the relay module's UDP-drop
comment ('defence in depth matching the fence'). State the principle
explicitly in the trust-model section and drop a stale plan-document
reference from the relay module doc comment.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
…guest class

Every KubeVirt guest is what root mode was: the workload runs as root
and the guest — including the in-guest openshell-sandbox boundary — is
untrusted. The security boundary is everything outside the guest: the
NetworkPolicy fence, the supervisor's policy, and the driver's
Kubernetes checks. Guest configuration (the nftables relay, the seccomp
broker's steering, the config-disk eject) is required for networking to
function and is never relied on for security.

The mode is gone as a concept: KubeVirtWorkloadMode, the workload
config key, the kubevirt.workload_mode claim, and the sandboxed guest
launch path are removed. The guest class is keyed on the
kubevirt.generation claim (is_kubevirt_guest): the driver renders a
uid-0 identity for every guest, the guest init always launches the
privileged boundary, and libkrun VM guests keep the trusted-boundary
model.

Supervisor gates that previously keyed on the privileged mode now key
on the untrusted-guest class, and none may trust the boundary:

- image policy discovery is disabled for untrusted guests (a policy
  planted at /etc/openshell/policy.yaml in the guest can never become
  the enforcement baseline or be synced to the gateway; the baseline is
  the gateway's policy or the restrictive default), with a regression
  test
- per-binary/ancestor/cmdline rules are rejected and the OPA engine is
  built with require_binary_identity=false
- provider files and environment are refused supervisor-side
- backend_audit validation requires only kernel release and
  architecture and is never treated as proof of enforcement
- every guest-reported event carries the OCSF guest-sourced mark
  (data_origin=guest), including network allow/deny events built from
  boundary-supplied identity; the mark is process-wide under the
  dedicated supervisor an untrusted guest requires

The kubevirt runtime now requires the dedicated supervisor topology
(a shared supervisor would let a parser bug reached by a hostile root
guest cross tenants).

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
The e2e harness and docs drop the sandboxed lane and the gateway-shared
supervisor topology (invalid for the kubevirt runtime):

- demo.sh renders one gateway config (dedicated supervisor, root
  workload); the OPENSHELL_KVPOC_WORKLOAD and OPENSHELL_KVPOC_TOPOLOGY
  switches and supervisor-values.yaml are removed
- demo-policy.yaml is now the root-class acceptance policy (network
  rules only); the sandboxed variant is deleted
- run-demo.sh's checks are single-path: exec as root, L4/L7 through the
  transparent relay, the fail-closed fence test after root deletes the
  relay ruleset, and the launcher-netns fence proof
- guest-init.sh always launches the privileged boundary and rejects any
  non-zero workload identity
- the README documents the single trust model, the rule that guest
  configuration is functional routing and never a security control,
  and that the boundary's confirmation claims are a consistency check
  anchored by the driver's Kubernetes reads; the transcript is refreshed
  from a live single-mode run
- the gateway configuration docs describe the dedicated-only topology
  and the untrusted-guest model

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
…ed objects

H5 (review finding): lifecycle checks fenced lookups but not the writes
that followed. Start checked the VM UID once at lookup and then patched
by name; create's read-modify-write helper re-read without rechecking
the UID; stop and the watch's auto-halt patched by name; delete used a
UID precondition on the VM but deleted companions by name. A VM
replaced under the same name between the check and the write was
booted, halted, or stripped by the wrong operation.

Every mutation is now pinned to the object that was checked:

- every VM patch (create's release, start's run-strategy patches,
  stop's halt, the watch's auto-halt) re-reads the VM, refuses a UID
  change (the checked object is gone — a Precondition abort, never a
  name-only fallback), and carries the expected metadata.uid and the
  resourceVersion from the same read, so the API server rejects a
  replaced or concurrently modified object; a resourceVersion conflict
  is retried from a fresh read
- the guest bootstrap Secret is read before start rewrites it: its
  ownerReference UID must be the checked VM, and the patch carries the
  Secret's UID and resourceVersion (a foreign object under the derived
  name is refused, not rewritten)
- the fence is re-verified immediately before the patch that boots the
  VM, so a fence widened or replaced during start's provisioning fails
  the start instead of releasing the guest
- companion deletes (bootstrap Secret, workspace PVC, egress fence)
  read the object first, require the VM's ownerReference UID, and carry
  the read UID as a DeleteOptions precondition; the supervisor Secret
  replace path and the stale-generation Secret cleanup delete with the
  read UID as a precondition

The fake API used by the unit tests now enforces the same contract as
the real API server: a patch whose pinned metadata.uid or
metadata.resourceVersion does not match the stored object is a 409
Conflict, and a delete whose DeleteOptions.preconditions.uid does not
match is refused. Four regression tests cover the finding: a VM
replaced between check and start is refused with no VM write landing;
a foreign-owned bootstrap Secret is refused and never rewritten; a
fence widened before release fails the start before the boot patch;
and a resourceVersion conflict retries from a fresh read and completes.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
H6 (review finding): the KubeVirt path never read the sandbox's
resource_requirements — every VM got the global kubevirt.cpu_cores and
kubevirt.memory with no limits, create skipped resource admission, and
capabilities() advertised GPU selection.

The sandbox's typed CPU and memory requests and limits now map onto the
VM (validated at admission, before anything is created):

- vCPU cores: the effective CPU (limit, else request, else the global
  kubevirt.cpu_cores) rounded up to whole vCPUs — a VM's vCPU count is
  integral; a fractional limit keeps its exact value on the
  virt-launcher container, so the guest sees the rounded count while
  the launcher is throttled to the fraction
- guest memory: the effective memory (limit, else request, else the
  global kubevirt.memory) as domain.memory.guest
- virt-launcher requests/limits: the sandbox's requests and limits
  verbatim on domain.resources (mirroring the pod path's rule that an
  omitted request defaults to the limit), so the launcher container is
  enforceable and KubeVirt's overhead lands on top
- validation: a limit below its request, memory below the safe guest
  minimum (256Mi), or an unparsable quantity is an InvalidArgument at
  admission

KubeVirt mode now runs the same resource admission as the pod path
(driver-config policy, workspace namespace rules, referenced-resource
admission) before anything is created. GPU requests are rejected at
admission with a clear message (GPU passthrough is not supported for VM
sandboxes yet; use the pod runtime), and capabilities() reports GPU
selection as unsupported in KubeVirt mode while the pod runtime keeps
it. CPU and memory limits are reported as supported in both modes.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
H4 (review finding) plus the M1 Helm mismatches. The KubeVirt driver
never searches: the VM is the record of what belongs to it.

The bootstrap Secret is now immutable per generation
(<vm>-boot-<generation>, the same generation normalization the
supervisor Secret uses): a start creates the new generation's Secret,
points the VM's cloudInitNoCloud volume at it through the release
patch, and deletes the previous generation's Secret by exact name with
a UID precondition taken from the VM's companions annotation
(openshell.ai/kubevirt-companions records each created companion's
exact name and UID). The driver never reads, lists, or patches a
Secret in a sandbox namespace. Teardown deletes the recorded Secrets
by name and UID without reading them; the list-by-label companion
cleanup and the stale supervisor-Secret sweep are removed in favour of
owner-reference garbage collection and the recorded names.

Resulting sandbox-namespace rights (shared-mode Role and the
managed-mode ClusterRole): Secrets create/delete only; pods
create/delete/get/patch/watch (no list); Services and PVCs
create/get/delete (no list); NetworkPolicies create/get/delete (the
fence reconciler restores drift with delete-and-recreate, never
patch); VMs and VMIs unchanged (the enumeration APIs). Source TLS and
image-pull Secrets stay covered by the existing
workspace-secret-source Role's exact resourceNames.

Managed workspace mode now works for the KubeVirt runtime (previously
rejected at validation): create resolves the per-workspace namespace,
and every other entry point discovers the sandbox's namespace from the
VM carrying its label (cluster-wide list, granted by the managed-mode
ClusterRole); the watch and the reconcile tick group by namespace.

Helm fixes (M1): the runtime value is normalized once
(openshell.kubernetesRuntime, accepting the kube-virt alias) and
reused by the Role, RoleBinding, and preflight; the sandbox
RoleBinding is emitted whenever the KubeVirt Role is; and the Agent
Sandbox preflight no longer blocks a KubeVirt-only install.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
A KubeVirt VM reports `printableStatus: ErrorUnschedulable` from the moment
its launcher Pod is rejected while the workspace PVC binds — the ordinary
`pod has unbound immediate PersistentVolumeClaims` wait, seconds long on a
storage class that provisions late. The driver mapped that status straight to
a terminal `VMFailed`, so `sandbox create` landed in `Error` while the VMI was
`Running` and `Ready` moments later; on hypc-ibm-106 every create failed that
way and only a `stop` + `start` recovered it.

Split "not yet" from "failed":

- `not_yet_printable_status` names the in-progress states: `Provisioning`,
  `Starting`, `WaitingForVolumeBinding`, `ErrorUnschedulable`,
  `ErrorPvcNotFound`. They no longer fail a create on sight.
- `stuck_not_yet_status` fails one only after `NOT_YET_TERMINAL_AFTER_MS`
  (ten minutes, the same window the create deadline allows), measured from the
  VMI's `Ready` transition or, before there is a VMI, the VM's creation time.
  A missing timestamp fails open: timing never isolates.
- `terminal_vm_failure` keeps the statuses that really do not recover:
  `CrashLoopBackOff` and `DataVolumeError`, plus a `Failed`/`Succeeded` VMI
  under a not-ready VM.

Tests cover the mapping table, the timeout boundary (fresh, exactly at the
window, stale, no timestamp, and statuses outside the set), and the snapshot
the bug produced: a fresh `ErrorUnschedulable` keeps `Ready=False` with the
transient `Starting` reason, and only an outlived one becomes `VMFailed`.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
Factor the nested VMI-phase map into a type alias and collapse a
match-to-unwrap_or_else in the reconcile tick; behaviour unchanged.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
Brings the branch (a824ea4, 130 commits behind) up to upstream/main at
6fd6b72. Four files conflicted:

- crates/openshell-driver-kubernetes/src/config.rs: both sides appended
  one validator call; keep both (ipv6_egress_config first, then the
  KubeVirt settings).
- crates/openshell-supervisor-network/src/opa.rs,
  crates/openshell-supervisor-network/src/proxy.rs,
  crates/openshell-supervisor/src/lib.rs: resolved to upstream/main.
  Every hunk here is privileged (root-workload) supervision, which the
  next commit removes from the branch entirely.
- crates/openshell-policy/src/lib.rs: upstream's SandboxPolicy gained
  cedar_policy, provider_credential_rules, and endpoint_settings; the
  branch's privileged default literal gains the empty values so the
  workspace compiles.

This merge commit is not independently green in openshell-supervisor:
the root-workload plumbing that main's PolicyBackend refactor (ai-openshell#5006)
breaks is still present here, and the commit that removes it is the one
that makes the tree build again.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
The KubeVirt runtime boots OpenShell's existing capability-free boundary
instead. The guest init runs launch-capability-free as the guest image's
unprivileged account (10001:10001), so a KubeVirt sandbox keeps the
in-guest posture a pod sandbox has — capability drop, no_new_privs,
Landlock, child seccomp — behind the per-sandbox egress fence. The
privileged (true guest root) workload class is a separate effort and is
not part of this branch.

Removed, because nothing else used them:

- the in-guest root mode: the nftables transparent relay
  (sandbox/src/network_relay.rs), the no-op child-hardening program, the
  privileged workload launcher, launch-privileged and
  RuntimeQualification::privileged, the unavailable/relay network broker,
  and the mode-gated landlock/seccomp skips in the boundary and process
  paths;
- the untrusted-guest trust verdicts: is_kubevirt_guest() and the
  validate_untrusted_guest() audit path, the zero-uid workload identity
  (ResolvedWorkloadIdentity::new_privileged and its decoding branch), the
  descriptor_matches_config privileged comparison, and the supervisor's
  untrusted-guest admission (image-discovery suppression, per-binary rule
  rejection, provider-material refusal, require_binary_identity=false);
- the OCSF guest-sourced markers (BaseEventBuilder::guest_sourced, the
  process-wide data_origin flag, the shorthand marker and its escaping);
- the privileged restrictive default policy;
- the driver's root plumbing: the workload-mode config key and claim, and
  the privileged workload identity the bootstrap rendered.

Kept, because a capability-free VM guest needs them: the kubevirt.generation
claim, the shared is_vm_guest() predicate (VM policy-identity semantics now
cover both libkrun and KubeVirt guests), and the descriptor/config
consistency helper the driver's tests pin.

The supervisor, supervisor-network, supervisor-process, isolation-interface,
ocsf, and policy crates are byte-identical to upstream/main again; the
sandbox crate differs from upstream in boundary_server.rs only, where
validate_vm_policy_identity keys on is_vm_guest().

Verified: cargo check --workspace --all-targets.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
The acceptance lane now exercises the capability-free guest: exec asserts
the unprivileged workload identity and no effective capabilities, the
direct-egress step proves the workload cannot reconfigure in-guest
networking instead of deleting a relay ruleset that no longer exists, and
the summary states the capability-free posture.

Housekeeping while the lane was open:

- de-PoC naming: the cluster is openshell-kubevirt, the images are
  openshell/sandbox-vm and openshell/supervisor, the namespace is
  kubevirt-sandboxes, the gateway is kubevirt, the demo sandbox is
  kubevirt-demo, and the environment variables are OPENSHELL_KUBEVIRT_*.
- drop the attack-surface probe lane (run-probes.sh, port-io.c). It
  probed in-guest root escapes, which this guest does not have.
- idmap-mount.c stays: the capability-free workload needs the virtiofs
  workspace idmapped to its uid.
- the README says plainly that nothing schedules this lane: no e2e/rust,
  no e2e/run.sh, no workflow.

Verified: bash -n and sh -n on every script; the live run is reported
separately.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
- configuration.mdx: the kubevirt block no longer reads as a proof of
  concept and no longer describes a root workload, the nftables relay, or
  provider-refusal semantics that this branch does not have. It states the
  guest boots the capability-free boundary, names the one supported
  supervisor topology, and points at the manual acceptance lane.
- configuration.mdx: restore the unrelated supervisor-to-gateway JWT line
  under provider_spiffe_workload_api_socket_path that an earlier commit on
  this branch deleted by accident (f11b70d).
- runtimes.mdx: say the KubeVirt guest keeps the pod sandbox's
  capability-free posture and gets its own supervisor.
- The crate README gains the KubeVirt Runtime Mode section: object model
  per generation, boundary delivery, the capability-free workload identity,
  the fence and its reconciler, image digest pinning, workspace, and the
  manual acceptance lane.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
The supervisor matches the kernel-resolved executable path and this guest
runs with require_binary_identity on, so a network policy with no binaries
list allows nothing. The demo policy names /usr/bin/busybox for both
policies (every guest applet resolves to it) and the README records the
gotcha; the README's sample run is the output of a clean live run against
KubeVirt v1.9.1 on k3d.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
Two leftovers from the earlier commits: one line the formatter splits, and
one identifier clippy wants in backticks. No behaviour change.

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:accepted A maintainer decided OpenShell should pursue this issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: KubeVirt runtime mode for the Kubernetes compute driver (VM-backed sandboxes)

1 participant