Arbitrary File Write Vulnerability in GNU gzip's zgrep Utility

gzip Updated 02 Oct 2025

Summary

31/08/2022
N/A
Yes i
High
8.8

CVE-2022-1271: An arbitrary file write vulnerability was found in GNU gzip's zgrep utility. Affects gzip across 2 version ranges.

< 1.12-r0 < 2327a461e1afce862c22269b80d3517801103c1b

Fixed in 1.12-r0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

GNU gzip is a popular compression utility used to compress and decompress files. It includes a utility called zgrep, which allows users to search for patterns within compressed files. The vulnerability affects the zgrep utility and can be exploited by an attacker to write arbitrary files on the system. This can lead to unauthorized access, data loss, or even remote code execution.

Vulnerability Detail

The vulnerability (CVE-2022-1271) arises due to insufficient validation when processing filenames with two or more newlines. An attacker can craft a multi-line file name with embedded content and target file names, tricking zgrep into overwriting arbitrary files with the attacker's chosen content. This can be exploited remotely by a low privileged attacker. The impact of this vulnerability is significant, as it allows an attacker to modify or delete sensitive files on the system.

How To Fix

Minimum fixed version

1.12-r0

This is the first release that contains the fix.

sudo apk add --upgrade gzip

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

There is no known workaround for this vulnerability. It is crucial to apply the recommended fix and update the affected packages to mitigate the risk of exploitation.

Conclusion

The arbitrary file write vulnerability in GNU gzip's zgrep utility (CVE-2022-1271) poses a significant risk to systems running affected versions of gzip and xz in Alpine Linux. It allows an attacker to overwrite arbitrary files on the system, potentially leading to unauthorized access, data loss, or remote code execution. It is crucial to update the affected packages to the fixed versions to mitigate the risk of exploitation. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for gzip →

Share this vulnerability

FAQ

This vulnerability allows an attacker to write arbitrary files on the system, potentially leading to unauthorized access, data loss, or remote code execution.

Yes, this vulnerability can be exploited remotely by a low privileged attacker.

No, there are no known workarounds for this vulnerability. It is essential to update the affected packages to the fixed versions.

The vulnerability affects the gzip and xz packages in Alpine Linux versions 3.12 to 3.18.

Users can update the affected packages using the package manager or by manually downloading and installing the updated packages from the official Alpine Linux repositories.

Related vulnerabilities

Recent vulnerabilities recorded for gzip.

How To Fix

Minimum fixed version

1.12-r0

This is the first release that contains the fix.

sudo apk add --upgrade gzip

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback