Skip to content

Use stronger warnings against tar/zip ExtractToDirectory - #55455

Open
rzikm wants to merge 2 commits into
mainfrom
tar-stronger-warning
Open

Use stronger warnings against tar/zip ExtractToDirectory#55455
rzikm wants to merge 2 commits into
mainfrom
tar-stronger-warning

Conversation

@rzikm

@rzikm rzikm commented Aug 17, 2026

Copy link
Copy Markdown
Member

Summary

Enhance warnings regarding the use of ExtractToDirectory for ZIP and TAR archives to emphasize the importance of using these methods only with trusted inputs. Update documentation to clarify potential risks and provide safer alternatives for handling untrusted archives.


Internal previews

File Preview link
docs/standard/io/snippets/zip-tar-best-practices/csharp/Program.cs Preview published page
docs/standard/io/zip-tar-best-practices.md Preview published page

Copilot AI lite review requested due to automatic review settings August 17, 2026 08:54
@rzikm
rzikm requested review from a team and adegeo as code owners August 17, 2026 08:54
@dotnetrepoman dotnetrepoman Bot added this to the August 2026 milestone Aug 17, 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

This pull request strengthens the guidance around using ZIP/TAR ExtractToDirectory convenience APIs by escalating the documentation from a note to explicit warnings, and by clarifying safer patterns for handling untrusted archives.

Changes:

  • Tightens the streaming ZIP guidance to focus on per-entry extraction rather than whole-archive extraction.
  • Replaces a NOTE with a WARNING to emphasize ExtractToDirectory must be used only with trusted inputs.
  • Adds a new WARNING about TarReader.GetNextEntry(copyContents: true) potentially allocating large amounts of memory for untrusted archives.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
docs/standard/io/zip-tar-best-practices.md Strengthens warnings and clarifies safe patterns for trusted vs. untrusted archive extraction.
docs/standard/io/snippets/zip-tar-best-practices/csharp/Program.cs Updates the TAR streaming snippet to demonstrate safer handling of entry data lifetimes and memory usage.

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

Comment thread docs/standard/io/snippets/zip-tar-best-practices/csharp/Program.cs
Comment thread docs/standard/io/zip-tar-best-practices.md Outdated
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