Skip to content

Add reference to Zip/Tar best practices to ExractToDirectory - #12995

Open
rzikm wants to merge 3 commits into
mainfrom
tar-zip-best-practices
Open

Add reference to Zip/Tar best practices to ExractToDirectory#12995
rzikm wants to merge 3 commits into
mainfrom
tar-zip-best-practices

Conversation

@rzikm

@rzikm rzikm commented Aug 17, 2026

Copy link
Copy Markdown
Member

Summary

Add warnings to the Tar extraction method to inform users about the risks of using it on untrusted archives. Include a reference to the best practices document for safely extracting archives.


Internal previews

File Preview link
includes/tar-zip-extracttodirectory.md Preview published page
xml/System.Formats.Tar/TarFile.xml Preview published page
xml/System.IO.Compression/ZipFile.xml Preview published page

@rzikm
rzikm requested a review from a team as a code owner August 17, 2026 09:15
Copilot AI lite review requested due to automatic review settings August 17, 2026 09:15

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

This PR updates the .NET API reference docs to add a shared warning + best-practices reference for archive extraction APIs (ZIP and TAR), aiming to better inform users about risks when extracting untrusted archives.

Changes:

  • Introduces a reusable include (tar-zip-extracttodirectory.md) containing a warning and a link to archive-extraction best practices.
  • Replaces repeated ZIP ExtractToDirectory warning blocks in ZipFile.xml with the shared include.
  • Adds the shared include to TAR ExtractToDirectory method remarks in TarFile.xml.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
xml/System.IO.Compression/ZipFile.xml Replaces duplicated ZIP extraction warning text with a shared include.
xml/System.Formats.Tar/TarFile.xml Adds the shared include into TAR extraction remarks (including placeholder remarks).
includes/tar-zip-extracttodirectory.md New shared warning text + best-practices link used by both ZIP and TAR docs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread includes/tar-zip-extracttodirectory.md Outdated
@@ -0,0 +1,2 @@
> [!WARNING]
> This method must be used only on trusted archives as it doesn't enforce any size limits, entry count limits, or other policies needed for safe extraction of untrusted archives. Refer to [Best practices for using zip and tar archives](/dotnet/standard/io/zip-tar-best-practices) for more information on safely extracting archives from untrusted sources.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
> This method must be used only on trusted archives as it doesn't enforce any size limits, entry count limits, or other policies needed for safe extraction of untrusted archives. Refer to [Best practices for using zip and tar archives](/dotnet/standard/io/zip-tar-best-practices) for more information on safely extracting archives from untrusted sources.
> This method must be used only on trusted archives as it doesn't enforce any size limits, entry count limits, or other policies needed for safe extraction of untrusted archives. For more information on safely extracting archives from untrusted sources, see [Best practices for using zip and tar archives](/dotnet/standard/io/zip-tar-best-practices).

<para>Files of type <see cref="F:System.Formats.Tar.TarEntryType.BlockDevice" />, <see cref="F:System.Formats.Tar.TarEntryType.CharacterDevice" />, or <see cref="F:System.Formats.Tar.TarEntryType.Fifo" /> can only be extracted in Unix platforms.</para>
<para>Elevation is required to extract a <see cref="F:System.Formats.Tar.TarEntryType.BlockDevice" /> or <see cref="F:System.Formats.Tar.TarEntryType.CharacterDevice" /> to disk.</para>
<para>This method doesn't limit the total extracted size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <see cref="T:System.Formats.Tar.TarReader" />, and validate that the size and the number of entries are within acceptable limits for your scenario.</para>
<format type="text/markdown"><![CDATA[

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This didn't render properly. You might need to convert the entire remarks to Markdown.

Image

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.

3 participants