fix: arbitrary file access during archive extraction filepath #6205
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.
rudder-server/router/batchrouter/asyncdestinationmanager/bing-ads/audience/util.go
Lines 251 to 283 in 6f87119
fix the "Zip Slip" vulnerability, we need to ensure that the output path constructed from each archive entry does not escape the intended target directory. The best way to do this is to:
filepath.Clean
...
elements that would traverse outside the target directory.filepath.Rel
or by comparing the prefix).The changes should be made in the
unzip
function inrouter/batchrouter/asyncdestinationmanager/bing-ads/audience/util.go
, specifically around the construction and use of thepath
variable. We will also need to add a helper function to check that the final path is within the target directory.Extracting files from a malicious zip file, or similar type of archive, is at risk of directory traversal attacks if filenames from the archive are not properly validated. archive paths. zip archives contain archive entries representing each file in the archive. These entries include a file path for the entry, but these file paths are not restricted and may contain unexpected special elements such as the directory traversal element (..). If these file paths are used to create a filesystem path, then a file operation may happen in an unexpected location. This can result in sensitive information being revealed or deleted, or an attacker being able to influence behavior by modifying unexpected files.
References
Zip Slip Vulnerability
Path Traversal
CWE-22
Security