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

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

- **Severity:** High 8.8 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 31 Aug 2022
- **Updated:** 14 Oct 2026
- **Also known as:** ALPINE-CVE-2022-1271, ALSA-2022:1537, ALSA-2022:4940, ALSA-2022:4991, AZL-10819, CLEANSTART-2025-BC18774, CLSA-2022-1652706322, CLSA-2022-1652801011, CLSA-2022-1652801052, CLSA-2022-1652801135, CLSA-2022-1652986585, CLSA-2022-1653005178, CLSA-2022-1668546739, CLSA-2022-1668547209, DEBIAN-CVE-2022-1271, DLA-2976-1, DLA-2977-1, DSA-5122-1, DSA-5123-1, GHSA-jrpw-543v-8r62, JLSEC-2026-61, MGASA-2022-0149, OESA-2022-1629, OESA-2022-1650, RHSA-2022:1537, RHSA-2022:1592, RHSA-2022:1665, RHSA-2022:1676, RHSA-2022:2191, RHSA-2022:4582, RHSA-2022:4940, RHSA-2022:4991, RHSA-2022:4992, RHSA-2022:4993, RHSA-2022:4994, RHSA-2022:5052, RLSA-2022:1537, RLSA-2022:4582, RLSA-2022:4940, RLSA-2022:4991, SUSE-SU-2022:1158-1, SUSE-SU-2022:1160-1, SUSE-SU-2022:1250-1, SUSE-SU-2022:1272-1, SUSE-SU-2022:1275-1, SUSE-SU-2022:14938-1, SUSE-SU-2022:1617-1, SUSE-SU-2022:1650-1, SUSE-SU-2022:1673-1, SUSE-SU-2022:1674-1, UBUNTU-CVE-2022-1271, USN-5378-1, USN-5378-2, USN-5378-3, USN-5378-4, openSUSE-SU-2024:11987-1, openSUSE-SU-2024:11992-1, openSUSE-SU-2024:12271-1

## 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 (Improper Input Validation), CWE-179 (Incorrect Behavior Order: Early Validation)

## Which versions are affected by CVE-2022-1271?

It affects 4 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `gzip` | AlmaLinux:8 | All versions | 1.9-13.el8_5 |
| `xz` | AlmaLinux:8 | All versions | 5.2.4-4.el8_6 |
| `xz-devel` | AlmaLinux:8 | All versions | 5.2.4-4.el8_6 |
| `xz-libs` | AlmaLinux:8 | All versions | 5.2.4-4.el8_6 |
| `xz-lzma-compat` | AlmaLinux:8 | All versions | 5.2.4-4.el8_6 |
| `xz` | AlmaLinux:9 | All versions | 5.2.5-8.el9_0 |
| `xz-devel` | AlmaLinux:9 | All versions | 5.2.5-8.el9_0 |
| `xz-libs` | AlmaLinux:9 | All versions | 5.2.5-8.el9_0 |
| `xz-lzma-compat` | AlmaLinux:9 | All versions | 5.2.5-8.el9_0 |
| `gzip` | Red Hat:enterprise_linux:7::client | All versions | 0:1.5-11.el7_9 |
| `gzip-debuginfo` | Red Hat:enterprise_linux:7::client | All versions | 0:1.5-11.el7_9 |
| `xz` | Red Hat:enterprise_linux:7::client | All versions | 0:5.2.2-2.el7_9 |
| `xz-compat-libs` | Red Hat:enterprise_linux:7::client | All versions | 0:5.2.2-2.el7_9 |
| `xz-debuginfo` | Red Hat:enterprise_linux:7::client | All versions | 0:5.2.2-2.el7_9 |
| `xz-devel` | Red Hat:enterprise_linux:7::client | All versions | 0:5.2.2-2.el7_9 |
| `xz-libs` | Red Hat:enterprise_linux:7::client | All versions | 0:5.2.2-2.el7_9 |
| `xz-lzma-compat` | Red Hat:enterprise_linux:7::client | All versions | 0:5.2.2-2.el7_9 |
| `xz-compat-libs` | Red Hat:enterprise_linux:7::computenode | All versions | 0:5.2.2-2.el7_9 |
| `xz-debuginfo` | Red Hat:enterprise_linux:7::computenode | All versions | 0:5.2.2-2.el7_9 |
| `xz-devel` | Red Hat:enterprise_linux:7::computenode | All versions | 0:5.2.2-2.el7_9 |
| `xz-lzma-compat` | Red Hat:enterprise_linux:7::computenode | All versions | 0:5.2.2-2.el7_9 |
| `gzip` | Red Hat:enterprise_linux:7::server | All versions | 0:1.5-11.el7_9 |
| `gzip-debuginfo` | Red Hat:enterprise_linux:7::server | All versions | 0:1.5-11.el7_9 |
| `xz` | Red Hat:enterprise_linux:7::server | All versions | 0:5.2.2-2.el7_9 |
| `xz-compat-libs` | Red Hat:enterprise_linux:7::server | All versions | 0:5.2.2-2.el7_9 |
| `xz-debuginfo` | Red Hat:enterprise_linux:7::server | All versions | 0:5.2.2-2.el7_9 |
| `xz-devel` | Red Hat:enterprise_linux:7::server | All versions | 0:5.2.2-2.el7_9 |
| `xz-libs` | Red Hat:enterprise_linux:7::server | All versions | 0:5.2.2-2.el7_9 |
| `xz-lzma-compat` | Red Hat:enterprise_linux:7::server | All versions | 0:5.2.2-2.el7_9 |
| `gzip` | Red Hat:enterprise_linux:7::workstation | All versions | 0:1.5-11.el7_9 |
| `gzip-debuginfo` | Red Hat:enterprise_linux:7::workstation | All versions | 0:1.5-11.el7_9 |
| `xz` | Red Hat:enterprise_linux:7::workstation | All versions | 0:5.2.2-2.el7_9 |
| `xz-compat-libs` | Red Hat:enterprise_linux:7::workstation | All versions | 0:5.2.2-2.el7_9 |
| `xz-debuginfo` | Red Hat:enterprise_linux:7::workstation | All versions | 0:5.2.2-2.el7_9 |
| `xz-devel` | Red Hat:enterprise_linux:7::workstation | All versions | 0:5.2.2-2.el7_9 |
| `xz-libs` | Red Hat:enterprise_linux:7::workstation | All versions | 0:5.2.2-2.el7_9 |
| `xz-lzma-compat` | Red Hat:enterprise_linux:7::workstation | All versions | 0:5.2.2-2.el7_9 |
| `gzip` | Red Hat:enterprise_linux:8::baseos | All versions | 0:1.9-13.el8_5 |
| `gzip-debuginfo` | Red Hat:enterprise_linux:8::baseos | All versions | 0:1.9-13.el8_5 |
| `gzip-debugsource` | Red Hat:enterprise_linux:8::baseos | All versions | 0:1.9-13.el8_5 |

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

## How do I fix CVE-2022-1271?

Apply the vendor's patch.

## Is CVE-2022-1271 being exploited?

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

## Other vulnerabilities in Debian Debian Linux

- [CVE-2015-3306](https://insights.sbomify.com/CVE-2015-3306/): ProFTPD Improper Access Control (critical 10.0, exploited in the wild)
- [CVE-2025-49113](https://insights.sbomify.com/CVE-2025-49113/): RoundCube Webmail Deserialization of Untrusted Data (critical 9.9, exploited in the wild)
- [CVE-2026-24061](https://insights.sbomify.com/CVE-2026-24061/): GNU InetUtils Argument Injection (critical 9.8, exploited in the wild)
- [CVE-2025-39682](https://insights.sbomify.com/CVE-2025-39682/): Linux Kernel Improper Check for Unusual or Exceptional Conditions (critical 9.8, exploited in the wild)
- [CVE-2024-9680](https://insights.sbomify.com/CVE-2024-9680/): Mozilla Firefox Use-After-Free (critical 9.8, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-1271 and fix it if it is affected.

What it is: 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.
Exploitation: There is no known exploitation of CVE-2022-1271 in the wild and no public exploit code.

Affected product: Debian Debian Linux. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-1271/ (Markdown: https://insights.sbomify.com/CVE-2022-1271/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-1271
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-1271
- OSV: https://osv.dev/vulnerability/CVE-2022-1271

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-1271/
Summaries are generated and may contain mistakes; the official description above is the record.
