Skip to content

fix(security): enforce read-only virtiofs at hypervisor level#454

Merged
DorianZheng merged 2 commits into
mainfrom
fix/virtiofs-readonly-enforcement
Apr 29, 2026
Merged

fix(security): enforce read-only virtiofs at hypervisor level#454
DorianZheng merged 2 commits into
mainfrom
fix/virtiofs-readonly-enforcement

Conversation

@DorianZheng

Copy link
Copy Markdown
Member

Summary

Fixes GHSA-g6ww-w5j2-r7x3 (CVSS 10.0) — read-only virtiofs volume mounts could be bypassed by malicious guest code.

Three-layer fix:

  • Hypervisor-level read-only enforcement: Use krun_add_virtiofs3 (libkrun v1.18.0) which enforces read-only at the virtio-fs device level, before requests reach the guest kernel
  • Capability restriction: Replace all-capabilities grant (41 caps including CAP_SYS_ADMIN) with Docker-default set (14 caps), preventing guests from remounting filesystems read-write
  • TSI network isolation: When NetworkSpec::Disabled, explicitly disable implicit vsock and add vsock with zero TSI features, preventing guest network escape via AF_INET/AF_UNIX socket forwarding

Dependency upgrades:

  • libkrun: v1.16.0 → v1.18.0
  • libkrunfw: v5.1.0 → v5.3.0
  • Versioned build cache paths to prevent stale artifact reuse

Test plan

  • Verify read-only volume mount cannot be remounted rw inside guest
  • Verify container processes run with Docker-default capabilities only
  • Verify network-disabled boxes cannot reach host via TSI
  • Run full test suite: cargo test -p boxlite --features krun,gvproxy
  • Verify clean build on macOS ARM64 with prebuilt libkrunfw v5.3.0

…6ww-w5j2-r7x3)

Addresses a critical vulnerability where read-only volume mounts could be
bypassed by malicious guest code via `mount -o remount,rw` due to three
compounding flaws:

1. **Hypervisor enforcement** — Upgrade vendored libkrun to v1.18.0 which
   provides `krun_add_virtiofs3()` with a `read_only` parameter. The
   `VolumeSpec.read_only` flag is now enforced at the device level by the
   hypervisor, not just as a guest-side mount option.

2. **Capability restriction** — Replace the all-41-capabilities grant with
   Docker's default capability set (14 capabilities). This drops
   `CAP_SYS_ADMIN`, `CAP_NET_ADMIN`, `CAP_SYS_MODULE`, `CAP_BPF`, and
   other dangerous capabilities, preventing `remount` attacks entirely.

3. **TSI network isolation** — When `disable_network` is set, replace the
   implicit vsock device (which enables TSI socket hijacking) with an
   explicit vsock using `TsiFeatures::None`, preventing guest processes
   from routing outbound sockets through the host.

Additional changes:
- Upgrade vendored libkrunfw to v5.3.0 (kernel 6.12.76)
- Update prebuilt download URLs and SHA256 checksums
- Version cache paths to prevent stale artifact reuse across upgrades
- Remove deprecated `krun_disable_tsi` FFI binding
- Refactor build.rs init binary compilation (now handled by libkrun's
  devices/build.rs via CC_LINUX env var)
…fixes

Cover all three security layers: TsiFeatures bitmask correctness,
Docker-default capability set enforcement, and hypervisor-level
read-only virtiofs with TSI isolation when network is disabled.
@DorianZheng DorianZheng merged commit 2c26968 into main Apr 29, 2026
30 checks passed
@DorianZheng DorianZheng deleted the fix/virtiofs-readonly-enforcement branch April 29, 2026 12:13
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