/

CVE-2026-42496

Severity:

CRITICAL RISK

(9.1)

Path Traversal via Symlink (CWE-59) in Archive::Tar

CVE-2026-42496

Modified

Vulnerability type

Category:

Path Traversal / Symlink Handling

CWE:

CWE-59, CWE-22

Impact:

Arbitrary File Read/Write via Symlink Traversal

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Archive::Tar extracts attacker-controlled symlinks that can point outside the intended extraction directory, allowing access to arbitrary filesystem paths.

When a victim later opens files through these extracted names, the operation may read from or write to attacker-chosen locations on the host system, becoming dangerous wherever untrusted tar archives are processed.

Affected context

This vulnerability appears when Perl applications use Archive::Tar to extract tar archives that include symbolic links, especially in contexts where the archive content is influenced by untrusted or partially trusted sources.

The extraction process does not sufficiently constrain symlink targets to remain within the designated extraction directory, and the secure-extract checks that cover regular files do not apply to symlink linknames.

As a result, any subsequent file operations that follow these symlinks can interact with unintended paths in the broader filesystem, depending on the permissions of the extracting process.

Exploit preconditions

  • Attack surface: Any Perl-based application or script that uses Archive::Tar to unpack tar files, such as backup systems, installers, or upload/import workflows.
  • Required access: Ability to supply or influence a tar archive consumed by the vulnerable extraction logic (e.g., uploaded archive, downloaded package, or pipeline artifact).
  • Trigger point: Invocation of extraction on a crafted tar containing symlinks whose linkname points to sensitive or external locations (absolute paths or .. segments).
  • Why exploitation is possible: _make_special_file() passes the tar header's linkname directly to symlink() without restricting the target to the extraction root, and the secure-extract mode does not validate or normalize symlink paths, allowing symlink-based path traversal.

Why this happens

The underlying issue is improper validation of file system paths associated with symbolic links during archive extraction.

Archive::Tar's _make_special_file() treats the tar header's linkname as trusted input and forwards it to symlink() without enforcing that the target resides within the intended extraction directory or is free of absolute paths and .. traversal segments.

This is a classic manifestation of CWE-59: Improper Link Resolution Before File Access, closely related to CWE-22: Path Traversal, where path components from untrusted archives are resolved against the host filesystem in a way that bypasses directory boundaries and safety checks.

Potential impact

  • Attackers could cause reads from sensitive files (e.g., configuration, keys, logs) via symlinked paths.
  • Archive extraction may overwrite or truncate important system or application files that the process can write.
  • Backup, restore, or deployment operations could be redirected to attacker-chosen locations, corrupting data or configuration.
  • Applications relying on Archive::Tar for sandboxed extraction may unintentionally expose or modify data outside their intended workspace.

General mitigation guidance

Effective mitigation focuses on constraining how paths and symlinks from archives are interpreted by the extraction logic.

Common defensive patterns include:

  • Enforcing a strict extraction root, rejecting or rewriting symlink targets that resolve outside this directory when normalized.
  • Normalizing and validating all paths (including linknames) before creating filesystem objects, disallowing absolute paths and .. components.
  • Treating symlinks from untrusted archives as unsafe by default: either skipping them or converting them to safe metadata representations rather than live filesystem links.
  • Running archive extraction under least-privilege accounts and isolated directories so that, even if traversal occurs, available damage is minimized.
  • Designing higher-level APIs that expose a "safe extract" mode where symlink creation is disabled or heavily constrained by default.

How teams detect issues like this

Organizations can identify this class of issue by:

  • Static analysis rules that flag direct use of filesystem APIs (e.g., symlink, link, open) with unvalidated paths derived from archive metadata.
  • Code reviews that scrutinize archive extraction routines for path normalization, root confinement, and symlink handling, especially checking that secure-extract logic applies uniformly to all file types.
  • Security testing with intentionally malicious tar archives containing nested directories, absolute paths, and symlinks pointing outside the extraction tree.
  • Policy-based enforcement that requires archive-processing libraries to support safe extraction semantics and bans raw path usage from tar headers without validation.

Sources

SourceLink
github.comgithub.com/jib/archive-tar-new/commit/17c873492a05eddc0de18c1485e0b2cccd5a9158.patch
metacpan.orgmetacpan.org/release/BINGOS/Archive-Tar-3.08/changes
cve.orgcve.org/CVERecord?id=CVE-2026-42497
access.redhat.comaccess.redhat.com/errata/RHSA-2026:30851
access.redhat.comaccess.redhat.com/errata/RHSA-2026:30852
access.redhat.comaccess.redhat.com/errata/RHSA-2026:30856
access.redhat.comaccess.redhat.com/errata/RHSA-2026:30857
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-42496
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2481314
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-42496.json

Frequently asked

questions

Exploitability depends on where Archive::Tar is used. Any workflow that extracts tar archives influenced by untrusted parties—such as user uploads, external packages, or CI artifacts—can be affected if symlinks are honored and later followed.

An attacker must be able to supply or modify a tar file processed by the vulnerable code. No direct filesystem access is required; the archive acts as the vehicle for specifying symlink targets, while the application's own permissions determine what can ultimately be read or written.

The safest approach is to treat symlink entries as untrusted and either disable their creation entirely for untrusted archives or strictly validate and normalize their targets to ensure they remain within the extraction root. Path validation should apply consistently to all archive entry types, not just regular files.

Future archive-handling code should adopt a "constrained filesystem" model, where all extracted paths are resolved relative to a single root after normalization, and symlinks, hard links, and special files are either prohibited or tightly controlled. Integrating path validation checks, least-privilege execution, and automated tests using malicious archives can help prevent reintroduction of this class of bug.

Find out what's already
exploitable in your codebase.