Skip to content

GHSA-j4xf-2g29-59ph CVE-2026-33056 RUSTSEC-2026-0067

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

Medium crates.io
Severity
0.0 / 10
Medium · CVSS 4.0
Exploit chance (EPSS)
0.39%
Chance of exploitation in the next 30 days. Higher than 32.64% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-61 UNIX Symbolic Link (Symlink) Following
Fix
0.4.45
Upgrade tar to this version or later

Description

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!

Affected versions

crates.io

PackageVulnerableFixed in
tar
< 0.4.45
0.4.45
tar
>= 0.0.0-0, < 0.4.45
0.4.45

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

tar crates.io → 0.4.45

cargo
cargo update -p tar --precise 0.4.45

Severity breakdown

CVSS 4.0 0.0

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N

Attack vector
Network
Attack complexity
Low
Attack requirements
None
Privileges required
None
User interaction
Active
Confidentiality (vulnerable system)
None
Integrity (vulnerable system)
Low
Availability (vulnerable system)
None
Confidentiality (subsequent systems)
None
Integrity (subsequent systems)
None
Availability (subsequent systems)
None

CVSS 3.1 6.5

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

Weakness

CWE-61: UNIX Symbolic Link (Symlink) Following

The product, when opening a file or directory, does not sufficiently account for when the file is a symbolic link that resolves to a target outside of the intended control sphere. This could allow an attacker to cause the product to operate on unauthorized files.

How to prevent it
  • Implementation: Symbolic link attacks often occur when a program creates a tmp directory that stores files/links. Access to the directory should be restricted to the program as to prevent attackers from manipulating the files.
  • Architecture and Design: Follow the principle of least privilege when assigning access rights to entities in a software system. Denying access to a file can prevent an attacker from replacing that file with a link to a sensitive file. Ensure good compartmentalization in the system to provide protected areas that can be trusted.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-3pv8-6f4r-ffg2
tar has a PAX header desynchronization issue
Medium Also affects tar
GHSA-gchp-q4r4-x4ff
tar-rs incorrectly ignores PAX size headers if header size is nonzero
High Also affects tar
GHSA-62jx-8vmh-4mcw
Links in archive can create arbitrary directories
High Also affects tar
GHSA-2367-c296-3mp2
Arbitrary file overwrite in tar-rs
High Also affects tar
GHSA-hjqx-j4rw-g7xv
zip: Arbitrary file write outside the extraction directory, because ZipArchive::extract validates symlink targets lexically.
High Same weakness, CWE-61
GHSA-p8v3-89rh-jxc7
Nginx UI: Backup restore follows crafted symlinks into the live Nginx configuration path before restore flags are applied
High Same weakness, CWE-61
GHSA-f794-5jv7-7672
NLTK: Downloader.download follows hardlinks and overwrites outside-root files
High Same weakness, CWE-61
RUSTSEC-2026-0269
Filesystem sandbox escape when paths or symlinks contain trailing slashes
High Same weakness, CWE-61
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor