Skip to content

Fix case-sensitive extraction on Windows - #133987

Open
iremyux wants to merge 2 commits into
dotnet:mainfrom
iremyux:133345-tar-casesensivity
Open

iremyux wants to merge 2 commits into
dotnet:mainfrom
iremyux:133345-tar-casesensivity

Conversation

@iremyux

@iremyux iremyux commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Use ordinal comparisons when validating extraction paths for TAR extraction.

Fixes #133345

@iremyux iremyux self-assigned this Sep 15, 2026
Copilot AI lite review requested due to automatic review settings September 15, 2026 19:05
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-formats-tar
See info in area-owners.md if you want to be subscribed.

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 encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

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.

🔵 Needs a closer look

One or more issues must be addressed before approval.

Review details

Suppressed comments (2)

src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs:442

  • The ordinal change is security-sensitive, but the old rationale for the platform-dependent comparison was removed without documenting why ordinal matching is intentional. Please add a brief explanation that this must remain ordinal to support case-sensitive Windows directories; otherwise a future cleanup may restore PathInternal.StringComparison and reintroduce the bug.
            if (!normalizedFile.StartsWith(logicalPrefix, StringComparison.Ordinal) &&
                !normalizedFile.Equals(logicalDest, StringComparison.Ordinal))

src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs:522

  • The added cases only verify the early GetFullDestinationPath rejection; they do not cover valid normalized paths such as subdir/../file or ./, nor exercise the changed symlink-walk comparisons. Please add sync and async positive coverage so this stricter ordinal validation cannot regress legitimate in-root extraction while fixing the case-only sibling case.
            return fullPath.StartsWith(destinationDirectoryFullPath, StringComparison.Ordinal) ? fullPath : null;
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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.

TAR extraction is always case insensitive on Windows

2 participants