CVE-2026-33056
JSON

5.1medium

tar-rs: unpack_in can chmod arbitrary directories by following symlinks

Severity
5.1medium CVSS:4.0 by GitHub_M
Exploit likelihood
0.39% (higher than 35% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-j4xf-2g29-59phRUSTSEC-2026-0067

Description

tar-rs is a tar archive reading/writing library for Rust. In versions 0.4.44 and below, when unpacking a tar archive, the tar crate's unpack_dir function uses fs::metadata() to check whether a path that already exists is a directory. Because fs::metadata() follows symbolic links, a crafted tarball containing a symlink entry followed by a directory entry with the same name causes the crate to treat the symlink target as a valid existing directory — and subsequently apply chmod to it. This allows an attacker to modify the permissions of arbitrary directories outside the extraction root. This issue has been fixed in version 0.4.45.

Affected

Product or packageVersionsReported by
alexcrichton tar-rs< 0.4.45CVE List
tar (crates.io)before 0.4.45, from 0.0.0-0 before 0.4.45GitHub Advisory Database, RustSec Advisory Database
tar_project tarbefore 0.4.45NVD

All scores

GitHub_M5.1medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N
GitHub6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N
RustSec Advisory DatabaseNot scored CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N
NVD6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N

Classification

CWE-61

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

tar-rs is a tar archive reading/writing library for Rust. In versions 0.4.44 and below, when unpacking a tar archive, the tar crate's unpack_dir function uses fs::metadata() to check whether a path that already exists is a directory. Because fs::metadata() follows symbolic links, a crafted tarball containing a symlink entry followed by a directory entry with the same name causes the crate to treat the symlink target as a valid existing directory — and subsequently apply chmod to it. This allows an attacker to modify the permissions of arbitrary directories outside the extraction root. This issue has been fixed in version 0.4.45.

GitHub Advisory Database

Summary

When unpacking a tar archive, the tar crate's unpack_dir function uses fs::metadata() to check whether a path that already exists is a directory. Because fs::metadata() follows symbolic links, a crafted tarball containing a symlink entry followed by a directory entry with the same name causes the crate to treat the symlink target as a valid existing directory — and subsequently apply chmod to it. This allows an attacker to modify the permissions of arbitrary directories outside the extraction root.

Reproducer

A malicious tarball contains two entries: (1) a symlink foo pointing to an arbitrary external directory, and (2) a directory entry foo/. (or just foo). When unpacked, create_dir("foo") fails with EEXIST because the symlink is already on disk. The fs::metadata() check then follows the symlink, sees a directory at the target, and allows processing to continue. The directory entry's mode bits are then applied via chmod, which also follows the symlink — modifying the permissions of the external target directory.

Fix

The fix is very simple, we now use fs::symlink_metadata() in unpack_dir, so symlinks are detected and rejected rather than followed.

Credit

This issue was reported by @xokdvium - thank you!

RustSec Advisory Database

In versions 0.4.44 and below of tar-rs, when unpacking a tar archive, the tar crate's unpack_dir function uses fs::metadata() to check whether a path that already exists is a directory. Because fs::metadata() follows symbolic links, a crafted tarball containing a symlink entry followed by a directory entry with the same name causes the crate to treat the symlink target as a valid existing directory — and subsequently apply chmod to it. This allows an attacker to modify the permissions of arbitrary directories outside the extraction root.

This issue has been fixed in version 0.4.45.

NVD (es)

tar-rs es una biblioteca de lectura/escritura de archivos tar para Rust. En las versiones 0.4.44 e inferiores, al desempaquetar un archivo tar, la función `unpack_dir` del crate `tar` utiliza `fs::metadata()` para verificar si una ruta que ya existe es un directorio. Debido a que `fs::metadata()` sigue los enlaces simbólicos, un tarball manipulado que contiene una entrada de enlace simbólico seguida de una entrada de directorio con el mismo nombre hace que el crate trate el destino del enlace simbólico como un directorio existente válido y, posteriormente, le aplique `chmod`. Esto permite a un atacante modificar los permisos de directorios arbitrarios fuera de la raíz de extracción. Este problema ha sido solucionado en la versión 0.4.45.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-33056 changed 2026-03-20CVE Terms of Use
GitHub Advisory DatabaseGHSA-j4xf-2g29-59ph changed 2026-09-10CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2026-0067 changed 2026-03-23CC0-1.0
NVDCVE-2026-33056 changed 2026-06-17Public domain