Adam/fix tar symlink - #1407
Merged
Merged
Conversation
…ction root when a SymbolicLinkHandler enables symlink chaining
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.
fixes GHSA-rch7-vc9j-fw2v
This pull request introduces significant improvements to the security of directory extraction, specifically around symbolic links and reparse points. It ensures that symbolic links cannot target locations outside the extraction root and that extraction never follows symbolic links or reparse points in later entries. The changes also add comprehensive tests to verify these protections across multiple extraction APIs.
Security enhancements for extraction:
Extraction now rejects symbolic link targets that point outside the extraction root, and never follows symbolic links or reparse points when extracting subsequent entries. This prevents directory traversal and privilege escalation attacks. (
src/SharpCompress/Common/DirectoryManagement.cs,src/SharpCompress/Common/IEntryExtensions.cs,src/SharpCompress/Common/IEntryExtensions.Async.cs, [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]New error messages and validation methods were added to enforce these checks and throw exceptions if a violation is detected. (
src/SharpCompress/Common/DirectoryManagement.cs, [1] [2]API and documentation updates:
SymbolicLinkHandlerdocumentation and interface were updated to clarify the new security guarantees and behaviors. (src/SharpCompress/Common/ExtractionOptions.cs,src/SharpCompress/Common/Options/IExtractionOptions.cs, [1] [2]docs/API.md, docs/API.mdR466-R467)Testing:
tests/SharpCompress.Test/Security/SymbolicLinkExtractionTests.cs, tests/SharpCompress.Test/Security/SymbolicLinkExtractionTests.csR1-R304)Overall, these changes greatly improve the safety of extracting archives containing symbolic links, providing robust defenses against common archive extraction vulnerabilities.