Skip to content

Clarify ZIP and TAR extraction containment warning - #56251

Open
rzikm wants to merge 1 commit into
mainfrom
clarify-archive-extraction-warning
Open

rzikm wants to merge 1 commit into
mainfrom
clarify-archive-extraction-warning

Conversation

@rzikm

@rzikm rzikm commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 24, 2026 16:20
@rzikm
rzikm requested review from a team and adegeo as code owners September 24, 2026 16:20
@dotnetrepoman dotnetrepoman Bot added this to the September 2026 milestone Sep 24, 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.

Copilot review overview

🟡 Changes recommended

Address the two documentation wording issues around containment validation and streaming APIs.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Low severity

Open (2)
What changed in this PR

Clarifies ZIP and TAR extraction containment limitations.

Changes:

  • Removes unconditional “safe” extraction wording.
  • Adds best-effort containment warnings.
  • Revises guidance for trusted archive extraction.
File Summary
docs/​standard/​io/​zip-tar-best-practices.md Updates trusted-extraction containment guidance.

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

When the archive source is known and trusted, the [convenience methods](#convenience-apis-one-shot-operations) give you a one-line extraction path:

- <xref:System.IO.Compression.ZipFile.ExtractToDirectory*?displayProperty=nameWithType> and <xref:System.Formats.Tar.TarFile.ExtractToDirectory*?displayProperty=nameWithType> handle path validation automatically. They sanitize entry names, resolve each entry's full path, and verify the resolved path stays inside the destination directory.
- <xref:System.IO.Compression.ZipFile.ExtractToDirectory*?displayProperty=nameWithType> and <xref:System.Formats.Tar.TarFile.ExtractToDirectory*?displayProperty=nameWithType> perform path validation as a best-effort attempt to keep extracted files within the specified destination directory. Neither API guarantees that extraction stays within that directory.

> [!WARNING]
> The `ExtractToDirectory` convenience methods must only be used on trusted inputs. These helpers don't enforce size limits, entry count limits, or other policies needed for safe extraction of untrusted archives. If that matters even for trusted input (for example, very large archives), use the streaming approach described in [Handle untrusted archives safely](#handle-untrusted-archives-safely).
> Use the `ExtractToDirectory` convenience methods only on trusted inputs. For both ZIP and TAR, these methods make only a best-effort attempt to stay within the specified destination directory and provide no guarantee. These helpers also don't enforce size limits, entry count limits, or other policies needed for safe extraction of untrusted archives. If that matters even for trusted input (for example, very large archives), use the streaming approach described in [Handle untrusted archives safely](#handle-untrusted-archives-safely).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants