CVE-2026-33056: tar-rs: unpack_in can chmod arbitrary directories by following symlinks
Summary
When unpacking a tar archive, the tar crate's unpackdir 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, createdir("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::symlinkmetadata() in unpackdir, so symlinks are detected and rejected rather than followed.
Credit
This issue was reported by @xokdvium - thank you!
Other sources
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 unpackdir 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.
— MITRE
tar-rs: unpackin can chmod arbitrary directories by following symlinks
— Microsoft
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2026-33056?
CVE-2026-33056 has a critical severity rating due to its potential to allow arbitrary directory permissions changes.
How do I fix CVE-2026-33056?
To fix CVE-2026-33056, upgrade the tar-rs library to version 0.4.45 or later.
What versions of tar-rs are affected by CVE-2026-33056?
CVE-2026-33056 affects all versions of tar-rs up to and including 0.4.44.
What is the impact of CVE-2026-33056?
The impact of CVE-2026-33056 is that it can allow an attacker to modify permissions of arbitrary directories when unpacking a tar archive.
Is it safe to use tar-rs version 0.4.44 for sensitive applications?
Using tar-rs version 0.4.44 for sensitive applications is not safe due to the vulnerabilities outlined in CVE-2026-33056.