Skip to content

feat: Restructure VSOCK code as a starting point for improvements - #11247

Merged
Bownairo merged 11 commits into
masterfrom
eero/vsock-staging
Aug 22, 2026
Merged

feat: Restructure VSOCK code as a starting point for improvements#11247
Bownairo merged 11 commits into
masterfrom
eero/vsock-staging

Conversation

@Bownairo

@Bownairo Bownairo commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

There should be very few real code changes. My goal was to simplify the structure to make the later changes easier to follow. I suggest reviewing by commit.

@Bownairo
Bownairo force-pushed the eero/vsock-staging branch from 75774a4 to c0b6b52 Compare August 20, 2026 19:24
@Bownairo
Bownairo force-pushed the eero/vsock-staging branch from c0b6b52 to 608fa64 Compare August 21, 2026 00:56
@Bownairo Bownairo changed the title Eero/vsock staging feat: Restructure VSOCK code as a starting point for improvements Aug 21, 2026
@github-actions github-actions Bot added the feat label Aug 21, 2026
@Bownairo
Bownairo marked this pull request as ready for review August 21, 2026 00:58
@Bownairo
Bownairo requested a review from a team as a code owner August 21, 2026 00:58
@github-actions github-actions Bot added the @node label Aug 21, 2026
@zeropath-ai

zeropath-ai Bot commented Aug 21, 2026

Copy link
Copy Markdown

1 possible security or compliance issue detected. Reviewed everything up to f2bdd93.

The following issues were found:

  • Issue 1: Improper Authentication
    • Location: rs/ic_os/vsock/src/server/mod.rs:26-95
    • Score: HIGH (78.0)
    • Description: The new VSOCK server accepts JSON commands from any guest VM that can reach the listener and executes powerful HostOS maintenance actions, including downloading an arbitrary upgrade payload, invoking the installer, and scheduling a reboot. The only gate is that the peer CID matches the request's guest_cid and equals the hard-coded first-guest CID; there is no cryptographic authentication, authorization token, or command allowlist beyond this transport-level check. A compromised or malicious guest VM on the same host can therefore issue Upgrade or StartUpgradeGuestVM commands and force HostOS to fetch attacker-chosen content and restart services.

Evidence: In process_connection, after parsing the untrusted request, the server only checks request.guest_cid != VIR_VSOCK_GUEST_CID_MIN and verify_sender_cid(stream, request.guest_cid) before dispatching to upgrade_hostos(upgrade_data) and start_upgrade_guest_vm().

Relevant code:

  • if request.guest_cid != VIR_VSOCK_GUEST_CID_MIN { ... ConnectionRefused ... }
  • if let Err(err) = verify_sender_cid(stream, request.guest_cid) { ... }
  • Command::Upgrade(upgrade_data) => upgrade_hostos(upgrade_data),
  • Command::StartUpgradeGuestVM => start_upgrade_guest_vm(),

upgrade_hostos then downloads from upgrade_data.url and runs /opt/ic/bin/install-upgrade.sh followed by shutdown --reboot.

Security Overview
Detected Code Changes
Change Type Relevant files
Refactor ► rs/ic_os/vsock/vsock_lib/BUILD.bazel
    Rename and adjust VSock library build to reference new paths and targets
Refactor ► rs/ic_os/vsock/BUILD.bazel
    Update VSock library dependency path references
Refactor ► rs/ic_os/vsock/vsock_lib/Cargo.toml
    Move clap dependency to workspace context and adjust path reference for ic-http-utils
Refactor ► rs/ic_os/vsock/vsock_lib/src/guest/... (multiple files moved/renamed from vsock_lib to new vsock path structure)
Refactor ► rs/ic_os/vsock/vsock_lib/src/lib.rs
    Remove old module structure references (guest, host, protocol) and adjust exports
Refactor ► rs/ic_os/vsock/vsock_lib/src/protocol/mod.rs
    Remove module exports (structures, utils) and associated files moved to new location
Refactor ► rs/ic_os/vsock/vsock_lib/src/host/command_utilities.rs
    Rename/move to vsock/src/server/command_utilities.rs
Refactor ► rs/ic_os/vsock/vsock_lib/src/host/hsm.rs
    Rename/move to vsock/src/server/hsm.rs
Refactor ► rs/ic_os/vsock/vsock_lib/src/host/mod.rs
    Remove and relocate host module contents; file deleted
Refactor ► rs/ic_os/vsock/vsock_lib/src/guest/client.rs
    Delete and relocate guest client logic to new path (ladder of changes)
Refactor ► rs/ic_os/vsock/src/server/mod.rs
    New server module with full server implementation (command dispatch, parse, verify, etc.)
Enhancement ► rs/ic_os/vsock/src/server/upgrade.rs
    Add upgrade functionality for host OS upgrade flow
Enhancement ► rs/ic_os/vsock/src/server/misc.rs
    Add host OS version and notify logic, plus miscellaneous helpers
Enhancement ► rs/ic_os/vsock/src/server/command_utilities.rs
    Relocated and renamed command utilities functionality
Enhancement ► rs/ic_os/vsock/src/server/hsm.rs
    Relocated HSM related logic to new server module
Enhancement ► rs/ic_os/vsock/src/lib.rs
    Expose VSock client/server and protocol modules (new structure)
Bug Fix (none explicitly)

@Bownairo Bownairo added the CI_ALL_BAZEL_TARGETS Runs all bazel targets label Aug 21, 2026
@Bownairo
Bownairo enabled auto-merge August 21, 2026 17:17
Comment thread rs/ic_os/vsock/src/server/mod.rs
@Bownairo
Bownairo added this pull request to the merge queue Aug 22, 2026
Merged via the queue into master with commit 0199d9a Aug 22, 2026
40 checks passed
@Bownairo
Bownairo deleted the eero/vsock-staging branch August 22, 2026 00:26
dfinityianblenke added a commit that referenced this pull request Aug 22, 2026
… vsock_lib

Upstream PR #11247 restructured rs/ic_os/vsock/, deleting the separate
vsock_guest and vsock_host crates and folding their binaries into
vsock_lib as src/bin/guest.rs and src/bin/host.rs. Update the spec's
requirement headers and paths to match; behavior is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants