Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions includes/tar-zip-extracttodirectory.md
Original file line number Diff line number Diff line change
@@ -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).

26 changes: 24 additions & 2 deletions xml/System.Formats.Tar/TarFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,11 @@
<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


[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="source" /> or <paramref name="destinationDirectoryName" /> is <see langword="null" />.</exception>
Expand Down Expand Up @@ -536,7 +541,13 @@ Extracting one of the tar entries would have resulted in a file outside the spec
<param name="destinationDirectoryName">To be added.</param>
<param name="options">To be added.</param>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
<remarks>
<format type="text/markdown"><![CDATA[

[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="ExtractToDirectory">
Expand Down Expand Up @@ -574,6 +585,11 @@ Extracting one of the tar entries would have resulted in a file outside the spec
<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[

[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceFileName" /> or <paramref name="destinationDirectoryName" /> is <see langword="null" />.</exception>
Expand Down Expand Up @@ -615,7 +631,13 @@ Extracting one of the tar entries would have resulted in a file outside the spec
<param name="destinationDirectoryName">To be added.</param>
<param name="options">To be added.</param>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
<remarks>
<format type="text/markdown"><![CDATA[

[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
</Docs>
</Member>
<MemberGroup MemberName="ExtractToDirectoryAsync">
Expand Down
50 changes: 17 additions & 33 deletions xml/System.IO.Compression/ZipFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1156,8 +1156,7 @@ An I/O error occurred while opening a file to be archived.</exception>

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -1235,8 +1234,7 @@ An archive entry was compressed by using a compression method that isn't support
If an entry in the zip archive is a symbolic link, it's extracted as a regular folder since symbolic link information isn't preserved in the ZIP format.
If `destinationDirectoryName` or any of its parent directories is a pre-existing junction or symbolic link, the link is followed and the extraction writes to the final target folder.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

## Examples
This example shows how to create and extract a zip archive by using the <xref:System.IO.Compression.ZipFile> class. It compresses the contents of a folder into a zip archive and extracts that content to a new folder. To use the <xref:System.IO.Compression.ZipFile> class, you must reference the `System.IO.Compression.FileSystem` assembly in your project.
Expand Down Expand Up @@ -1321,8 +1319,7 @@ An archive entry was compressed by using a compression method that isn't support

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -1433,8 +1430,7 @@ An archive entry was compressed by using a compression method that isn't support

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -1520,8 +1516,7 @@ If `destinationDirectoryName` or any of its parent directories is a pre-existing

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -1662,9 +1657,8 @@ If `entryNameEncoding` is set to `null`, entry names and comments are decoded ac

- For entries where the language encoding flag (in the general-purpose bit flag of the local file header) is not set, entry names and comments are decoded by using the current system default code page.
- For entries where the language encoding flag is set, the entry names and comments are decoded by using UTF-8.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.

[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -1755,8 +1749,7 @@ If `entryNameEncoding` is set to `null`, entry names and comments are decoded ac

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -1851,8 +1844,7 @@ An archive entry was compressed by using a compression method that isn't support

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -1944,8 +1936,7 @@ An archive entry has been compressed using a compression method that isn't suppo

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -2017,8 +2008,7 @@ An archive entry has been compressed using a compression method that isn't suppo

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -2098,8 +2088,7 @@ An archive entry has been compressed using a compression method that isn't suppo

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -2210,8 +2199,7 @@ An archive entry has been compressed using a compression method that isn't suppo

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -2291,8 +2279,7 @@ An archive entry has been compressed using a compression method that isn't suppo

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -2429,8 +2416,7 @@ An archive entry has been compressed using a compression method that isn't suppo

Unicode encodings other than UTF-8 can't be used for `entryNameEncoding`, otherwise an <xref:System.ArgumentException> is thrown.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -2519,8 +2505,7 @@ An archive entry has been compressed using a compression method that isn't suppo

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down Expand Up @@ -2618,8 +2603,7 @@ An archive entry has been compressed using a compression method that isn't suppo

Unicode encodings other than UTF-8 can't be used for `entryNameEncoding`, otherwise an <xref:System.ArgumentException> is thrown.

> [!WARNING]
> This method doesn't limit the total uncompressed size or the number of entries extracted from the archive. When processing archives from untrusted sources, iterate over the entries manually using <xref:System.IO.Compression.ZipArchive>, and validate that the total uncompressed size and the number of entries are within acceptable limits for your scenario.
[!INCLUDE[tar-zip-extracttodirectory](~/includes/tar-zip-extracttodirectory.md)]

]]></format>
</remarks>
Expand Down
Loading