Skip to content

Update TAR guidance for untrusted archives#54670

Open
mangod9 wants to merge 1 commit into
dotnet:mainfrom
mangod9:copilot/tar-docs-security
Open

Update TAR guidance for untrusted archives#54670
mangod9 wants to merge 1 commit into
dotnet:mainfrom
mangod9:copilot/tar-docs-security

Conversation

@mangod9

@mangod9 mangod9 commented Jul 8, 2026

Copy link
Copy Markdown
Member

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

📄 File 🔗 Preview link
docs/standard/io/zip-tar-best-practices.md Best practices for working with ZIP and TAR archives in .NET

…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>
Copilot AI review requested due to automatic review settings July 8, 2026 05:39
@mangod9 mangod9 requested review from a team and adegeo as code owners July 8, 2026 05:39
@dotnetrepoman dotnetrepoman Bot added this to the July 2026 milestone Jul 8, 2026
@mangod9 mangod9 changed the title Update TAR security guidance for untrusted archives Update TAR guidance for untrusted archives Jul 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants