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.
This commit is contained in:
@@ -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:
|
(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.
|
`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).
|
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
|
- **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.
|
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,
|
- **exec**: sessions run as root before dropping to the user, so the guest helper accepts them only from the host's vsock CID,
|
||||||
|
|||||||
+5
-1
@@ -13,13 +13,17 @@ const STUB_INIT: &str = "#!/.wsbx/busybox sh
|
|||||||
echo 'wsbx: cannot mount host share'; exec /.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.
|
/// Static busybox from the official busybox image; runs PID 1 + helpers in the guest.
|
||||||
fn busybox(h: &Path) -> Result<PathBuf> {
|
fn busybox(h: &Path) -> Result<PathBuf> {
|
||||||
let p = h.join("busybox");
|
let p = h.join("busybox");
|
||||||
if p.exists() {
|
if p.exists() {
|
||||||
return Ok(p);
|
return Ok(p);
|
||||||
}
|
}
|
||||||
let img = oci::pull(h, "busybox:musl", false)?;
|
let img = oci::pull(h, BUSYBOX, false)?;
|
||||||
let tmp = h.join("busybox.tmp");
|
let tmp = h.join("busybox.tmp");
|
||||||
fs::create_dir_all(&tmp)?;
|
fs::create_dir_all(&tmp)?;
|
||||||
let ok = Command::new("tar").arg("-xf").arg(&img.rootfs).arg("-C").arg(&tmp).arg("bin").status()?.success();
|
let ok = Command::new("tar").arg("-xf").arg(&img.rootfs).arg("-C").arg(&tmp).arg("bin").status()?.success();
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ pub fn kernel(h: &Path, update: bool, version: Option<String>) -> Result<PathBuf
|
|||||||
Some(v) => format!("https://api.github.com/repos/{KATA_REPO}/releases/tags/{v}"),
|
Some(v) => format!("https://api.github.com/repos/{KATA_REPO}/releases/tags/{v}"),
|
||||||
None => format!("https://api.github.com/repos/{KATA_REPO}/releases/latest"),
|
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 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}"))?;
|
let tag = rel["tag_name"].as_str().ok_or_else(|| anyhow!("no tag in {api}"))?;
|
||||||
if k.exists() && installed.as_deref() == Some(tag) {
|
if k.exists() && installed.as_deref() == Some(tag) {
|
||||||
|
|||||||
+1
-1
@@ -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
|
/// 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
|
/// 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.
|
/// (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) {
|
if explicit_local(registry) {
|
||||||
return agent().build();
|
return agent().build();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user