Update TAR guidance for untrusted archives#54670
Open
mangod9 wants to merge 4 commits into
Open
Conversation
…ributes Adds security guidance to the ZIP/TAR best-practices article for handling untrusted TAR archives: - A note that destination boundary validation assumes the destination is a real directory the app controls; a junction/symlink destination (or parent) causes extraction to follow the link, even with TarFile.ExtractToDirectory. - A new section on PAX extended attributes and link names as untrusted, archive-supplied input that can override header fields. - Updated the untrusted-metadata checklist item to include link names and PAX extended attributes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the archive security best-practices guidance to cover TAR-specific risks when extracting untrusted archives, complementing the existing ZIP guidance.
Changes:
- Adds a note clarifying the limits of destination boundary validation when the destination path contains junctions or symlinks.
- Documents TAR PAX extended attributes and TAR link names as untrusted metadata that requires validation and limits.
- Updates the best-practices checklist to explicitly include TAR link names and PAX extended attributes.
gewarren
approved these changes
Jul 8, 2026
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Member
Author
|
@copilot can you please apply the review suggested text changes? |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
GrabYourPitchforks
requested changes
Jul 8, 2026
| - The trailing directory separator on `fullDestDir` is critical—without it, a path like `/safe-dir-evil/file` would incorrectly match `/safe-dir`. | ||
|
|
||
| > [!NOTE] | ||
| > Boundary validation assumes the destination directory itself is a real directory you control. If the destination directory or one of its parents is already a junction or symbolic link, extraction follows that link and writes to the link's target—even with <xref:System.Formats.Tar.TarFile.ExtractToDirectory*?displayProperty=nameWithType>, which otherwise rejects entries and link targets that escape the destination. When handling untrusted archives, extract into a fresh, application-controlled directory rather than a reused or externally writable location. |
Member
There was a problem hiding this comment.
When handling untrusted archives, extract into a fresh, application-controlled directory rather than a reused or externally writable location.
This is inconsistent with line 44 in this same document, which says that ExtractToDirectory is meant only for trusted archives.
Member
Author
There was a problem hiding this comment.
updated the content to not include ExtractToDirectory
…chive note The note lives in the streaming/untrusted-input section, but referenced TarFile.ExtractToDirectory, which the article frames as a trusted-input convenience API. Reword to keep the note focused on manual boundary validation and avoid the inconsistency. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Updating the ZIP/TAR best-practices docs with security guidance for TAR API use: destination boundary validation, PAX extended attributes, and link names.
Internal previews