Skip to content

fix(krun): air-gap guests by default; opt-in TSI inet hijack#53

Merged
toksdotdev merged 1 commit intokrunfrom
toks/disable-inet-hijack
Apr 30, 2026
Merged

fix(krun): air-gap guests by default; opt-in TSI inet hijack#53
toksdotdev merged 1 commit intokrunfrom
toks/disable-inet-hijack

Conversation

@toksdotdev
Copy link
Copy Markdown
Member

@toksdotdev toksdotdev commented Apr 30, 2026

problem

when no virtio-net device was configured, configure_vsock auto-enabled TsiFlags::HIJACK_INET so the guest's inet socket calls were transparently bridged to the host through vsock. that's a sensible default for "no network attached, give me something usable," but it silently defeated true air-gap setups: the guest had no network interface, yet its tcp/udp traffic still reached the outside world.

reported downstream in superradcompany/microsandbox#645 where msb run --no-net ... nc 1.1.1.1 80 returned a cloudflare 301 even though ip a showed only lo.

fix

flipped the default so guests with no virtio-net are air-gapped, and added MachineBuilder::enable_inet_hijack(bool) for callers that still want the TSI fallback. covered by unit tests.

breaking: callers that previously relied on the implicit TSI fallback (no virtio-net configured) must now call .machine(|m| m.enable_inet_hijack(true)) to keep that behavior.

test plan

  • cargo build -p msb_krun (no features)
  • cargo build -p msb_krun --features net
  • cargo test -p msb_krun
  • cargo test -p msb_krun --features net api::vm
  • cargo clippy -p msb_krun --features net --tests -- -D warnings
  • cargo fmt -p msb_krun --check

@toksdotdev toksdotdev changed the title feat(krun): MachineBuilder::disable_inet_hijack to opt out of TSI fallback fix(krun): support air-gapped guests by disabling TSI inet hijack Apr 30, 2026
when no virtio-net device was configured, configure_vsock auto-enabled
TsiFlags::HIJACK_INET so the guest's inet socket calls were transparently
bridged to the host through vsock. that silently defeated air-gap setups:
the guest had no network interface, yet its tcp/udp traffic still reached
the outside world.

flipped the default so guests with no virtio-net are air-gapped, and
added MachineBuilder::enable_inet_hijack(bool) for callers that still
want the TSI fallback.

reported in superradcompany/microsandbox#645.

BREAKING CHANGE: callers that previously relied on the implicit TSI
fallback (no virtio-net configured) must now call
.machine(|m| m.enable_inet_hijack(true)) to keep that behavior.
@toksdotdev toksdotdev force-pushed the toks/disable-inet-hijack branch from 35a199f to 35be9f4 Compare April 30, 2026 19:00
@toksdotdev toksdotdev changed the title fix(krun): support air-gapped guests by disabling TSI inet hijack fix(krun): air-gap guests by default; opt-in TSI inet hijack Apr 30, 2026
@toksdotdev toksdotdev merged commit f18a383 into krun Apr 30, 2026
8 checks passed
@toksdotdev toksdotdev deleted the toks/disable-inet-hijack branch April 30, 2026 19:21
appcypher pushed a commit that referenced this pull request Apr 30, 2026
bumped all msb_krun_* workspace crates and their internal
path-dependency version refs from 0.1.11 to 0.1.12, and refreshed both
lockfiles. the libkrun C-API crate (1.17.3) and the example crates are
unchanged.

changes since 0.1.11:

- fix(krun): air-gap guests by default; opt-in TSI inet hijack (#53)
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