Update TAR guidance for untrusted archives#54670
Open
mangod9 wants to merge 1 commit 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.
|
|
||
| ### TAR extended attributes and link names | ||
|
|
||
| - **PAX extended attributes** (<xref:System.Formats.Tar.PaxTarEntry.ExtendedAttributes?displayProperty=nameWithType>) are an arbitrary, archive-supplied set of key-value strings. A PAX entry can carry many attributes, and individual values can be large. The format also uses these attributes to override standard header fields such as the entry path, link name, and size. Treat them as untrusted input: if your application reads or acts on extended attributes, validate their contents and bound how many you process and how large they can be. |
| - **Memory limits:** Avoid <xref:System.IO.Compression.ZipArchiveMode.Update?displayProperty=nameWithType> for large untrusted archives. Avoid <xref:System.IO.Compression.ZipArchiveMode.Read?displayProperty=nameWithType> mode with unseekable streams from untrusted sources. | ||
| - **Thread safety:** Don't share <xref:System.IO.Compression.ZipArchive>, <xref:System.Formats.Tar.TarReader?displayProperty=fullName>, or <xref:System.Formats.Tar.TarWriter?displayProperty=fullName> instances across threads. | ||
| - **Untrusted metadata:** Treat entry names, comments, and extra fields as untrusted input. Sanitize before display or processing. | ||
| - **Untrusted metadata:** Treat entry names, link names, comments, ZIP extra fields, and TAR PAX extended attributes as untrusted input. Validate and bound them before display or processing. |
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