{"id":"RUSTSEC-2026-0450","aliases":["RUSTSEC-2026-0450"],"related":[],"kind":"vulnerability","state":"published","title":"`ocipkg`: unpacking an OCI archive can write and delete files outside the local image store (path traversal)","summary":"When `ocipkg` unpacks an OCI archive, the destination directory is derived from the\nimage name, which `ocipkg` reads from the archive's **own** `index.json`\n(`org.opencontainers.image.ref.name`). That name is attacker-controlled, and\n`ImageName::parse` accepts a hostname of `..`, so the computed destination escapes the\nlocal image store. A \"zip-slip\"-style path traversal (CWE-22 / CWE-23). This is esclatable to code execution.\n\nIn `Artifact::unpack` (`src/image/artifact.rs`), the destination is\n`image_dir(name) = data_dir().join(name.as_path())` (`src/local/mod.rs:31`), where the\nname comes from `get_name_from_index` (`src/image/layout.rs:114-124`):\n\n```rust\nlet image_name = self.base.get_name()?;   // from the archive's index.json ref.name\nlet dest = image_dir(&image_name)?;        // data_dir().join(name.as_path()); hostname \"..\" escapes\nif dest.exists() {\n    if overwrite {\n        fs::remove_dir_all(&dest)?;        // deletes a directory OUTSIDE the store\n    }\n}\nfs::create_dir_all(&dest)?;\n// ... each tar layer is then unpacked under `dest` (also outside the store)\n```\n\n## The fix\n\nFixed in `ocipkg` 0.4.1 by [PR #223](https://github.com/termoshtt/ocipkg/pull/223). The leading\nreference component is validated against the `org.opencontainers.image.ref.name` grammar from OCI\nImage Specification 1.1.1 on parse and deserialization, and `local::image_dir` revalidates the name\nand rejects any non-normal path component (e.g. `..`) before any filesystem mutation, so a crafted\narchive can no longer escape the local image store.","summaryFormat":"markdown","summarySource":"rustsec","descriptions":[{"lang":"en","text":"When `ocipkg` unpacks an OCI archive, the destination directory is derived from the\nimage name, which `ocipkg` reads from the archive's **own** `index.json`\n(`org.opencontainers.image.ref.name`). That name is attacker-controlled, and\n`ImageName::parse` accepts a hostname of `..`, so the computed destination escapes the\nlocal image store. A \"zip-slip\"-style path traversal (CWE-22 / CWE-23). This is esclatable to code execution.\n\nIn `Artifact::unpack` (`src/image/artifact.rs`), the destination is\n`image_dir(name) = data_dir().join(name.as_path())` (`src/local/mod.rs:31`), where the\nname comes from `get_name_from_index` (`src/image/layout.rs:114-124`):\n\n```rust\nlet image_name = self.base.get_name()?;   // from the archive's index.json ref.name\nlet dest = image_dir(&image_name)?;        // data_dir().join(name.as_path()); hostname \"..\" escapes\nif dest.exists() {\n    if overwrite {\n        fs::remove_dir_all(&dest)?;        // deletes a directory OUTSIDE the store\n    }\n}\nfs::create_dir_all(&dest)?;\n// ... each tar layer is then unpacked under `dest` (also outside the store)\n```\n\n## The fix\n\nFixed in `ocipkg` 0.4.1 by [PR #223](https://github.com/termoshtt/ocipkg/pull/223). The leading\nreference component is validated against the `org.opencontainers.image.ref.name` grammar from OCI\nImage Specification 1.1.1 on parse and deserialization, and `local::image_dir` revalidates the name\nand rejects any non-normal path component (e.g. `..`) before any filesystem mutation, so a crafted\narchive can no longer escape the local image store.","format":"markdown","source":"rustsec"}],"published":"2026-10-30T12:00:00.000Z","modified":"2026-11-06T14:45:02.837Z","severity":{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H","score":7.1,"rating":"HIGH"},"severities":[{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H","score":7.1,"rating":"HIGH"}],"cwes":[],"affected":[{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"0.4.1"}],"ecosystem":"crates.io","package":"ocipkg","purl":"pkg:cargo/ocipkg","source":"rustsec"}],"references":[{"url":"https://crates.io/crates/ocipkg","tags":["package"],"sources":["rustsec"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2026-0450.html","tags":["advisory"],"sources":["rustsec"]},{"url":"https://github.com/termoshtt/ocipkg/issues/222","tags":["report"],"sources":["rustsec"]},{"url":"https://github.com/termoshtt/ocipkg/pull/223","tags":["web"],"sources":["rustsec"]}],"credits":[],"sources":[{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2026-0450","url":"https://rustsec.org/advisories/RUSTSEC-2026-0450.html","licence":"CC0-1.0","modified":"2026-11-06T14:45:02.837Z"}],"updatedAt":"2026-11-25T22:56:43.469Z"}