CVE-2018-20482
Description
GNU Tar through 1.30, when --sparse is used, mishandles file shrinkage during read access, which allows local users to cause a denial of service (infinite read loop in sparse_dump_region in sparse.c) by modifying a file that is supposed to be archived by a different user's process (e.g., a system backup running as root).
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Affected products
15- osv-coords13 versionspkg:rpm/opensuse/tar&distro=openSUSE%20Leap%2015.0pkg:rpm/opensuse/tar&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/tar&distro=openSUSE%20Tumbleweedpkg:rpm/suse/tar&distro=SUSE%20Linux%20Enterprise%20Micro%205.0pkg:rpm/suse/tar&distro=SUSE%20Linux%20Enterprise%20Micro%205.1pkg:rpm/suse/tar&distro=SUSE%20Linux%20Enterprise%20Micro%205.2pkg:rpm/suse/tar&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015pkg:rpm/suse/tar&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP3pkg:rpm/suse/tar&distro=SUSE%20Linux%20Enterprise%20Point%20of%20Sale%2011%20SP3pkg:rpm/suse/tar&distro=SUSE%20Linux%20Enterprise%20Real%20Time%2015%20SP2pkg:rpm/suse/tar&distro=SUSE%20Linux%20Enterprise%20Server%2011%20SP4-LTSSpkg:rpm/suse/tar&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP5pkg:rpm/suse/tar&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2012%20SP5
< 1.30-lp150.7.1+ 12 more
- (no CPE)range: < 1.30-lp150.7.1
- (no CPE)range: < 1.34-150000.3.12.1
- (no CPE)range: < 1.34-2.2
- (no CPE)range: < 1.34-150000.3.12.1
- (no CPE)range: < 1.34-150000.3.12.1
- (no CPE)range: < 1.34-150000.3.12.1
- (no CPE)range: < 1.30-3.3.2
- (no CPE)range: < 1.34-150000.3.12.1
- (no CPE)range: < 1.27.1-14.8.1
- (no CPE)range: < 1.34-150000.3.12.1
- (no CPE)range: < 1.27.1-14.8.1
- (no CPE)range: < 1.27.1-15.6.3
- (no CPE)range: < 1.27.1-15.6.3
Patches
Vulnerability mechanics
Root cause
"GNU Tar mishandles file shrinkage during read access when the --sparse option is used."
Attack vector
A local user can trigger this vulnerability by modifying a file that is currently being archived by a different user's process, such as a system backup running as root. This modification involves shrinking the file while GNU Tar is reading it. The vulnerability is triggered when the `sparse_dump_region()` function in `sparse.c` does not properly check for the end of the file after a read operation, leading to an infinite loop. This can occur with both sparse and non-sparse files when the `--sparse` option is enabled [ref_id=1].
Affected code
The vulnerability resides in the `sparse_dump_region()` function within the file `src/sparse.c`. This function is responsible for handling sparse regions of files during the archiving process. The issue arises because it does not adequately check for the end-of-file condition after a `safe_read()` operation, particularly when the file being processed shrinks during the read [ref_id=1].
What the fix does
The advisory indicates that the `sparse_dump_region()` function in `sparse.c` does not check for end-of-file conditions after a `safe_read()` call, which can lead to an infinite loop if the file being processed shrinks. The recommended remediation is to update GNU Tar to a version that addresses this issue. The patch is not provided in the bundle, but the advisory suggests that the fix involves correctly handling the end-of-file condition within `sparse_dump_region()` to prevent the infinite read loop [ref_id=1].
Preconditions
- inputThe target file must be shrunk while GNU Tar is actively reading and archiving it.
- configGNU Tar must be invoked with the `--sparse` option.
- authThe user triggering the file shrinkage must have the ability to modify the file being archived by another user's process (e.g., a root backup process).
Reproduction
The easiest way to reproduce this is under a debugger like GDB. Set a breakpoint on `sparse_dump_region()`. Start creating a tar file with `--sparse`. After the breakpoint triggers, use a tool like `truncate(1)` to shorten the file. `sparse_dump_region()` will then enter an infinite loop. If the file is re-enlarged, the function will recover [ref_id=1].
Generated on Jun 3, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
10- lists.opensuse.org/opensuse-security-announce/2019-04/msg00077.htmlmitrevendor-advisoryx_refsource_SUSE
- security.gentoo.org/glsa/201903-05mitrevendor-advisoryx_refsource_GENTOO
- git.savannah.gnu.org/cgit/tar.git/commit/mitrex_refsource_MISC
- lists.gnu.org/archive/html/bug-tar/2018-12/msg00023.htmlmitrex_refsource_MISC
- www.securityfocus.com/bid/106354mitrevdb-entryx_refsource_BID
- lists.debian.org/debian-lts-announce/2018/12/msg00023.htmlmitremailing-listx_refsource_MLIST
- lists.debian.org/debian-lts-announce/2021/11/msg00025.htmlmitremailing-listx_refsource_MLIST
- news.ycombinator.com/itemmitrex_refsource_MISC
- twitter.com/thatcks/status/1076166645708668928mitrex_refsource_MISC
- utcc.utoronto.ca/~cks/space/blog/sysadmin/TarFindingTruncateBugmitrex_refsource_MISC
News mentions
0No linked articles in our index yet.