From b50e846b1147e32a507662ac023113692cb055d4 Mon Sep 17 00:00:00 2001 From: Niklas Haiden Date: Thu, 22 Oct 2026 19:55:23 +0200 Subject: [PATCH] fix(#7): pin busybox by digest, kernel downloads use the filtered agent busybox:musl was a mutable tag re-resolved daily for the binary that runs as PID 1 in every VM. Kernel/GitHub downloads now go through the same public-only resolver as registries. --- README.md | 2 ++ src/disk.rs | 6 +++++- src/kernel.rs | 2 +- src/oci.rs | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d8afc66..2bb638e 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ The VM is the boundary. The guest (including a prompt-injected agent or a malici (token realms and redirects included, IPv6 forms like NAT64/6to4 too). A registry counts as local only by name: `localhost` or a private IP literal (`192.168.1.5:5000`). LAN registries addressed by a DNS name are refused; use the IP. All downloads (registries, kernel) time out after 30 s without progress (connect or any single read). +- **Guest base**: the static busybox (PID 1 in every VM) is pulled pinned by digest. The kernel comes from the Kata release + over the same public-addresses-only client and is sha256-checked against the release's published digest. - **pi config**: allowlisted items only. Symlinks are followed only into `~/.pi/agent` or `~/.agents/skills`, with no cycles and no special files, capped at 256 MB. - **exec**: sessions run as root before dropping to the user, so the guest helper accepts them only from the host's vsock CID, diff --git a/src/disk.rs b/src/disk.rs index e8248ad..f9fa3aa 100644 --- a/src/disk.rs +++ b/src/disk.rs @@ -13,13 +13,17 @@ const STUB_INIT: &str = "#!/.wsbx/busybox sh echo 'wsbx: cannot mount host share'; exec /.wsbx/busybox sh "; +/// busybox:musl pinned by digest: this binary is PID 1 in every VM, so a moved tag must not change it. +/// Bump deliberately (index digest of `docker.io/library/busybox:musl`). +const BUSYBOX: &str = "busybox@sha256:ea2b9914a16a4ac1981994af97b318f7c7d4db76b580c56177f08bf76f4a0be8"; + /// Static busybox from the official busybox image; runs PID 1 + helpers in the guest. fn busybox(h: &Path) -> Result { let p = h.join("busybox"); if p.exists() { return Ok(p); } - let img = oci::pull(h, "busybox:musl", false)?; + let img = oci::pull(h, BUSYBOX, false)?; let tmp = h.join("busybox.tmp"); fs::create_dir_all(&tmp)?; let ok = Command::new("tar").arg("-xf").arg(&img.rootfs).arg("-C").arg(&tmp).arg("bin").status()?.success(); diff --git a/src/kernel.rs b/src/kernel.rs index de6958f..82273f3 100644 --- a/src/kernel.rs +++ b/src/kernel.rs @@ -34,7 +34,7 @@ pub fn kernel(h: &Path, update: bool, version: Option) -> Result format!("https://api.github.com/repos/{KATA_REPO}/releases/tags/{v}"), None => format!("https://api.github.com/repos/{KATA_REPO}/releases/latest"), }; - let agent = oci::agent().build(); + let agent = oci::agent_for("api.github.com"); // public-only resolver, like registries (redirects to the CDN included) let rel: Value = serde_json::from_reader(agent.get(&api).call().with_context(|| format!("GET {api}"))?.into_reader())?; let tag = rel["tag_name"].as_str().ok_or_else(|| anyhow!("no tag in {api}"))?; if k.exists() && installed.as_deref() == Some(tag) { diff --git a/src/oci.rs b/src/oci.rs index a59a6d5..16fc161 100644 --- a/src/oci.rs +++ b/src/oci.rs @@ -89,7 +89,7 @@ fn explicit_local(registry: &str) -> bool { /// HTTP agent for a registry. Public registries get an agent that refuses to connect to non-public /// addresses (covers token realms and blob redirects too); an explicitly local registry /// (e.g. localhost:5000, 192.168.1.5:5000) was chosen by the user and keeps the default agent. -fn agent_for(registry: &str) -> ureq::Agent { +pub fn agent_for(registry: &str) -> ureq::Agent { if explicit_local(registry) { return agent().build(); }