#1132999 tar: CVE-2026-5704

Package:
src:tar
Source:
src:tar
Submitter:
Salvatore Bonaccorso
Date:
2026-10-31 19:07:02 UTC
Severity:
normal
Tags:
#1132999#5
Date:
2026-04-08 18:34:08 UTC
From:
To:
Hi,

The following vulnerability was published for tar.

Note at time of writing the only reference is the Red Hat bugzilla
entry, so this needs more research.

CVE-2026-5704[0]:
| A flaw was found in tar. A remote attacker could exploit this
| vulnerability by crafting a malicious archive, leading to hidden
| file injection with fully attacker-controlled content. This bypasses
| pre-extraction inspection mechanisms, potentially allowing an
| attacker to introduce malicious files onto a system without
| detection.


If you fix the vulnerability please also make sure to include the
CVE (Common Vulnerabilities & Exposures) id in your changelog entry.

For further information see:

[0] https://security-tracker.debian.org/tracker/CVE-2026-5704
https://www.cve.org/CVERecord?id=CVE-2026-5704
[1] https://bugzilla.redhat.com/show_bug.cgi?id=2455360

Please adjust the affected versions in the BTS as needed.

Regards,
Salvatore

#1132999#12
Date:
2026-10-31 19:05:59 UTC
From:
To:
Hi,

Attached is a debdiff for a 1.35+dfsg-7.1 NMU fixing CVE-2026-5704
(tar -t / tar -x desynchronisation, "hidden file injection"). I have not
uploaded anything; please use as much or as little of it as you like.

Upstream's fix, b8d8a61b ("Fix more -t/-x discrepancies"), is part of a
rework built on post-1.35 changes (its message says it fixes a bug from
b009124f, which is not in 1.35), so it does not apply to 1.35. However
1.35 itself is affected, as the original report says: for symlink,
character/block device and FIFO members with a nonzero size field,
"tar -t" skips the data blocks but "tar -x" parses them as further
headers.

The attached patch is a minimal backport of the same approach to 1.35:

- extract_archive(): after the extractors that never read member data
(SYMTYPE, LNKTYPE, CHRTYPE, BLKTYPE, FIFOTYPE), call skip_member(),
whether extraction succeeded or failed;
- skim_member(): mark the member as skipped, as upstream does, so a
second skip_member() call is harmless;
- read_header(): clear that mark for each new header, as upstream does.
This part matters: without it "tar --delete" loops forever (delete04
hung in my first attempt), because the delete code does not reset
current_stat_info between members.

Regular files and directories keep their 1.35 handling, and LNKTYPE keeps
its 1.35 size-zero treatment (consistent between -t and -x already).
Upstream's regression test extrac32 ("skip file injection") is added to
the 1.35 test suite as extrac26, minus its stray "cp archive.tar /tmp".

Testing (sid chroot, amd64, test suite run as a non-root user):

- test suite: 217 successful, 28 skipped (xattr, big-file and similar
environment-dependent tests), including the new "skip file injection"
test.
- a reproducer that builds an archive with a symlink, FIFO, char device
or hard link member whose size field covers a hidden second member:
1.35+dfsg-7: symlink, FIFO and char device: the hidden file is
created by -x but not listed by -t
1.35+dfsg-7.1: -t and -x agree in all four cases
- regression checks: a normal archive (regular, symlink, hard link, FIFO,
300 kB file) lists and extracts as before, --delete works, and listing
an archive made by 1.35+dfsg-7 gives identical output.
- lintian: source tags identical to 1.35+dfsg-7.

"tar -d" (compare) has a similar pattern for symlinks and special files;
upstream's commit does not change it, so neither does this patch.

Regards,
automationcanadian