mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
[PR #374] [MERGED] fix: prevent extracting archived files outside of target path #990
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/374
Author: @odinn1984
Created: 5/2/2018
Status: ✅ Merged
Merged: 5/2/2018
Merged by: @adamhathcock
Base:
master← Head:feat/fail_on_outside_target_files📝 Commits (1)
80ceb1cfix: prevent extracting archived files outside of target path📊 Changes
3 files changed (+46 additions, -2 deletions)
View changed files
📝
src/SharpCompress/Archives/IArchiveEntryExtensions.cs(+19 -2)📝
tests/SharpCompress.Test/Zip/ZipArchiveTests.cs(+27 -0)➕
tests/TestArchives/Archives/Zip.Evil.zip(+0 -0)📄 Description
This PR is meant to fix an arbitrary file write vulnerability, that can be
achieved using a specially crafted zip archive, that holds path traversal
filenames. When the filename gets concatenated to the target extraction
directory, the final path ends up outside of the target folder.
A sample malicious zip file named Zip.Evil.zip was used,
and when running the code below, resulted in the creation of C:/Temp/evil.txt
outside of the intended target directory.
There are various possible ways to avoid this issue, some include checking
for .. (dot dot) characters in the filename, but the best solution in our
opinion is to check if the final target filename, starts with the target
folder (after both are resolved to their absolute path).
Stay secure,
Snyk Team
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.