Disallow symlinks in extractTarGz and harden archive extraction against path traversal - #4880
Open
sigurdm wants to merge 1 commit into
Open
Disallow symlinks in extractTarGz and harden archive extraction against path traversal#4880sigurdm wants to merge 1 commit into
sigurdm wants to merge 1 commit into
Conversation
…st path traversal 1. Disallow symlink and hardlink creation during archive extraction. Only regular files and directories are extracted; symlinks and hardlinks are safely ignored. 2. Reject invalid entry names containing backslashes, colons, NUL bytes, or control characters. 3. Reject Windows reserved DOS device names (CON, PRN, AUX, NUL, COM1-9, LPT1-9). 4. Reject filename segments ending with trailing dots or spaces. 5. Track case-insensitive path collisions on Windows and macOS. BUG=https://buganizer.corp.google.com/issues/528619187 TAG=agy CONV=9ae2ec7a-a500-4f86-b1a9-31504d7f3f24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
extractTarGz, extract only regular files and directories. Symlinks, hardlinks, and special files are safely ignored. This eliminates symlink depth-confusion and symlink-based Zip Slip attacks, avoids Windows privilege issues (OS Error 1314), and aligns withpub publish(which already flattens symlinks to copies on upload).\), colons (:), NUL bytes, or ASCII control characters.CON,PRN,AUX,NUL,COM1-9, orLPT1-9..or space.Fixes https://buganizer.corp.google.com/issues/528619187