Skip to content

Fix: Apply path traversal guard to WriteAllToZip() matching WriteAllToDisk()#27171

Closed
mrknight-n1du wants to merge 3 commits into
protocolbuffers:mainfrom
mrknight-n1du:main
Closed

Fix: Apply path traversal guard to WriteAllToZip() matching WriteAllToDisk()#27171
mrknight-n1du wants to merge 3 commits into
protocolbuffers:mainfrom
mrknight-n1du:main

Conversation

@mrknight-n1du

Copy link
Copy Markdown
Contributor

This PR applies the same path traversal guard already present in
WriteAllToDisk() to WriteAllToZip(). A plugin returning
a filename like ../../PWNED.txt is blocked for directory output,
but currently slips silently into an archive, enabling Zip Slip-style entries.

This fix adds an identical .. check and returns an error to prevent
traversal injection in .zip / .jar / .srcjar output.

Closes #27170

Add validation to prevent relative paths in output file names.
@google-cla

google-cla Bot commented Apr 30, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@mrknight-n1du

Copy link
Copy Markdown
Contributor Author

Updated the PR as suggested — changed from hard error to warning,
suppressed when --unsafe_allow_out_dir_escape is set, with a note
that this may become an error in a future breaking change release.

@esrauchg esrauchg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@esrauchg esrauchg added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 1, 2026
@github-actions github-actions Bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 1, 2026
@mrknight-n1du

Copy link
Copy Markdown
Contributor Author

It's my pleasure, @esrauchg. Any update on when this will be merged?

@copybara-service copybara-service Bot closed this in 28bef98 May 6, 2026
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.

Security hardening: WriteAllToZip() missing path traversal guard present in WriteAllToDisk()

3 participants