CVE-2022-1271 Path traversal in gzip, xz-utils

High 8.8 Published Updated

An attacker can exploit insufficient filename validation in zgrep to overwrite arbitrary files on the system via crafted multi-line filenames.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2022-1271?

CVE-2022-1271 is a high-severity path traversal vulnerability in Debian Debian Linux, published on 31 Aug 2022. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

An arbitrary file write vulnerability was found in GNU gzip's zgrep utility. When zgrep is applied on the attacker's chosen file name (for example, a crafted file name), this can overwrite an attacker's content to an arbitrary attacker-selected file. This flaw occurs due to insufficient validation when processing filenames with two or more newlines where selected content and the target file names are embedded in crafted multi-line file names. This flaw allows a remote, low privileged attacker to force zgrep to write arbitrary files on the system.

Weakness: CWE-20, CWE-179

Which versions are affected by CVE-2022-1271?

It affects 4 products.

Linux distribution packages (40)
gzip AlmaLinux:8All versions1.9-13.el8_5
xz AlmaLinux:8All versions5.2.4-4.el8_6
xz-devel AlmaLinux:8All versions5.2.4-4.el8_6
xz-libs AlmaLinux:8All versions5.2.4-4.el8_6
xz-lzma-compat AlmaLinux:8All versions5.2.4-4.el8_6
xz AlmaLinux:9All versions5.2.5-8.el9_0
xz-devel AlmaLinux:9All versions5.2.5-8.el9_0
xz-libs AlmaLinux:9All versions5.2.5-8.el9_0
xz-lzma-compat AlmaLinux:9All versions5.2.5-8.el9_0
gzip Red Hat:enterprise_linux:7::clientAll versions0:1.5-11.el7_9
gzip-debuginfo Red Hat:enterprise_linux:7::clientAll versions0:1.5-11.el7_9
xz Red Hat:enterprise_linux:7::clientAll versions0:5.2.2-2.el7_9
xz-compat-libs Red Hat:enterprise_linux:7::clientAll versions0:5.2.2-2.el7_9
xz-debuginfo Red Hat:enterprise_linux:7::clientAll versions0:5.2.2-2.el7_9
xz-devel Red Hat:enterprise_linux:7::clientAll versions0:5.2.2-2.el7_9
xz-libs Red Hat:enterprise_linux:7::clientAll versions0:5.2.2-2.el7_9
xz-lzma-compat Red Hat:enterprise_linux:7::clientAll versions0:5.2.2-2.el7_9
xz-compat-libs Red Hat:enterprise_linux:7::computenodeAll versions0:5.2.2-2.el7_9
xz-debuginfo Red Hat:enterprise_linux:7::computenodeAll versions0:5.2.2-2.el7_9
xz-devel Red Hat:enterprise_linux:7::computenodeAll versions0:5.2.2-2.el7_9
xz-lzma-compat Red Hat:enterprise_linux:7::computenodeAll versions0:5.2.2-2.el7_9
gzip Red Hat:enterprise_linux:7::serverAll versions0:1.5-11.el7_9
gzip-debuginfo Red Hat:enterprise_linux:7::serverAll versions0:1.5-11.el7_9
xz Red Hat:enterprise_linux:7::serverAll versions0:5.2.2-2.el7_9
xz-compat-libs Red Hat:enterprise_linux:7::serverAll versions0:5.2.2-2.el7_9
xz-debuginfo Red Hat:enterprise_linux:7::serverAll versions0:5.2.2-2.el7_9
xz-devel Red Hat:enterprise_linux:7::serverAll versions0:5.2.2-2.el7_9
xz-libs Red Hat:enterprise_linux:7::serverAll versions0:5.2.2-2.el7_9
xz-lzma-compat Red Hat:enterprise_linux:7::serverAll versions0:5.2.2-2.el7_9
gzip Red Hat:enterprise_linux:7::workstationAll versions0:1.5-11.el7_9
gzip-debuginfo Red Hat:enterprise_linux:7::workstationAll versions0:1.5-11.el7_9
xz Red Hat:enterprise_linux:7::workstationAll versions0:5.2.2-2.el7_9
xz-compat-libs Red Hat:enterprise_linux:7::workstationAll versions0:5.2.2-2.el7_9
xz-debuginfo Red Hat:enterprise_linux:7::workstationAll versions0:5.2.2-2.el7_9
xz-devel Red Hat:enterprise_linux:7::workstationAll versions0:5.2.2-2.el7_9
xz-libs Red Hat:enterprise_linux:7::workstationAll versions0:5.2.2-2.el7_9
xz-lzma-compat Red Hat:enterprise_linux:7::workstationAll versions0:5.2.2-2.el7_9
gzip Red Hat:enterprise_linux:8::baseosAll versions0:1.9-13.el8_5
gzip-debuginfo Red Hat:enterprise_linux:8::baseosAll versions0:1.9-13.el8_5
gzip-debugsource Red Hat:enterprise_linux:8::baseosAll versions0:1.9-13.el8_5

Products include Debian Debian Linux, Gnu Gzip, Redhat Jboss Data Grid, Tukaani Xz.

How do I fix CVE-2022-1271?

Apply the vendor's patch.

Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.

Is CVE-2022-1271 being exploited?

There is no known exploitation of CVE-2022-1271 in the wild and no public exploit code.

All Debian Debian Linux vulnerabilities

Sources

Also known as ALPINE-CVE-2022-1271, ALSA-2022:1537, ALSA-2022:4940, ALSA-2022:4991, AZL-10819, CLEANSTART-2025-BC18774 and 52 more.

Is CVE-2022-1271 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free