Add reference to Zip/Tar best practices to ExractToDirectory - #12995
Open
rzikm wants to merge 3 commits into
Open
Add reference to Zip/Tar best practices to ExractToDirectory#12995rzikm wants to merge 3 commits into
rzikm wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
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
ExtractToDirectorywarning blocks inZipFile.xmlwith the shared include. - Adds the shared include to TAR
ExtractToDirectorymethod remarks inTarFile.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.
gewarren
reviewed
Aug 17, 2026
| @@ -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. | |||
Collaborator
There was a problem hiding this comment.
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[ |
Collaborator
There was a problem hiding this comment.
This didn't render properly. You might need to convert the entire remarks to Markdown.
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.
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