Skip to content

fix: strip path components from gzip NAME field on decompress#416

Open
KowalskiThomas wants to merge 1 commit into
intel:masterfrom
KowalskiThomas:kowalski/fix-strip-path-components-from-gzip-name-field-on-decompress
Open

fix: strip path components from gzip NAME field on decompress#416
KowalskiThomas wants to merge 1 commit into
intel:masterfrom
KowalskiThomas:kowalski/fix-strip-path-components-from-gzip-name-field-on-decompress

Conversation

@KowalskiThomas
Copy link
Copy Markdown

What is this PR?

This PR fixes an arbitrary file write arising from using the raw NAME when decompressing, without checking whether it is a valid NAME entry, or something that would escape the current working directory.
The proposed fix is to ensure the outfile_name does not contain a /, or if it does to strip everything that comes before the last /.

This matches what should be expected from a correct input per RFC 1952 §2.3.1, which states that the NAME field stores the original filename "with any directory components removed". It also is consistent with how GNU gzip handles the same case (here).

The PR also adds a regression check to confirm the issue is fixed (with an example of an ill-formed input).

Signed-off-by: Thomas Kowalski <thom.kowa@gmail.com>
@KowalskiThomas KowalskiThomas marked this pull request as ready for review May 20, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant