VYPR
Unrated severityNVD Advisory· Published Dec 26, 2018· Updated Aug 5, 2024

CVE-2018-20482

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

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

News mentions

0

No linked articles in our index yet.