REDHAT-BUG-2513087: Path Traversal
GNU cpio contains a Path Traversal vulnerability in its tar archive extraction functionality. When extracting a tar archive in copy-in mode with the --no-absolute-filenames option, the extracted file name is normalized but the tar hard-link target is passed to the linktoname function without equivalent sanitization before calling link function. A tar archive provided by an attacker, containing a hard-link entry whose linkname is set to an absolute path outside the extraction directory, can cause cpio to create a hard link to an existing file outside the intended extraction directory, breaking the expected guarantee of --no-absolute-filenames and allowing archive-controlled linkage to external files.
This issue has been fixed in commit e2b9cbdd3354d2b1569b7390d1bc15c1930559ad
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch e2b9cbdd3354d2b1569b7390d1bc15c1930559ad
Event History
Frequently Asked Questions
Who is exposed to this issue?
Systems that use GNU cpio to extract attacker-controlled tar archives in copy-in mode with the --no-absolute-filenames option are exposed. The issue specifically involves hard-link entries whose link targets reference absolute paths outside the extraction directory.
What must an attacker provide to exploit it?
An attacker needs to supply a tar archive containing a hard-link entry with an absolute-path linkname targeting an existing file outside the intended extraction directory. During extraction, cpio can create a hard link to that external file.
Is the --no-absolute-filenames option sufficient protection?
No. Although extracted file names are normalized with this option, the hard-link target was not equivalently sanitized before the link operation, so an absolute hard-link target could bypass the expected restriction.
How can I tell whether an archive may have triggered the issue?
Review tar archives processed by GNU cpio for hard-link entries with absolute link targets, and inspect extracted output for hard links that reference files outside the intended extraction directory. The provided data does not identify affected GNU cpio versions.