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 tosymlink()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.

