Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5.6k
Merging internal commits for release/9.0#129194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hoyosjs
merged 10 commits into
dotnet:release/9.0
from
vseanreesermsft:internal-merge-9.0-2026-06-09-1503Jun 11, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
543e08d
Merge commit '98618ede4a7db4faed529b3b809cd0c3c26e080c'
52a46d3
avoid symlink traversal
alinpahontu2912 cacfe16
Merged PR 59957: [release/9.0] Fix NativeAOT possible out-of-bounds w…
elinor-fung f6c6e5a
Merge commit '0361f884d288bec628a02cd342c21dd68a652ac2'
03c2af4
Merge commit '768cacfc6c379b3dc47273d6726ed39e825760c2'
f6f74e0
Merged PR 60831: Fix tar symlink resolution - NET 9
alinpahontu2912 f2c8152
Merge commit '922bda4b04b3f9d424e33d04914168bb4b90371c'
ad9bfcb
Merge commit 'f2c8152eed158e72950025393fde498c90a57a6b' into internal…
vseanreesermsft 88d5224
Marked failing tests as ActiveIssue
svick 521b196
Marked more failing tests as ActiveIssue
svick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4 ...r/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/InteropHelpers.cs
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
23 changes: 20 additions & 3 deletions
23 ...clr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/PInvokeMarshal.cs
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
102 changes: 99 additions & 3 deletions
102 src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
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
98 changes: 98 additions & 0 deletions
98 src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.File.Tests.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,6 +3,7 @@ | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using Xunit; | ||
| namespace System.Formats.Tar.Tests | ||
| @@ -45,6 +46,7 @@ public void NonExistentDirectory_Throws() | ||
| } | ||
| [Fact] | ||
| [ActiveIssue("https://github.com/dotnet/runtime/issues/129227")] | ||
| public void SetsLastModifiedTimeOnExtractedFiles() | ||
| { | ||
| using TempDirectory root = new TempDirectory(); | ||
| @@ -72,6 +74,7 @@ public void SetsLastModifiedTimeOnExtractedFiles() | ||
| } | ||
| [Fact] | ||
| [ActiveIssue("https://github.com/dotnet/runtime/issues/129227")] | ||
| public void SetsLastModifiedTimeOnExtractedDirectories() | ||
| { | ||
| using TempDirectory root = new TempDirectory(); | ||
| @@ -208,6 +211,7 @@ public void Extract_AllSegmentsOfPath() | ||
| } | ||
| [Fact] | ||
| [ActiveIssue("https://github.com/dotnet/runtime/issues/129227")] | ||
| public void ExtractArchiveWithEntriesThatStartWithSlashDotPrefix() | ||
| { | ||
| using TempDirectory root = new TempDirectory(); | ||
| @@ -233,6 +237,7 @@ public void ExtractArchiveWithEntriesThatStartWithSlashDotPrefix() | ||
| [Theory] | ||
| [InlineData(true)] | ||
| [InlineData(false)] | ||
| [ActiveIssue("https://github.com/dotnet/runtime/issues/129227")] | ||
| public void UnixFileModes(bool overwrite) | ||
| { | ||
| using TempDirectory source = new TempDirectory(); | ||
| @@ -301,6 +306,7 @@ public void UnixFileModes(bool overwrite) | ||
| [Theory] | ||
| [InlineData(true)] | ||
| [InlineData(false)] | ||
| [ActiveIssue("https://github.com/dotnet/runtime/issues/129227")] | ||
| public void UnixFileModes_RestrictiveParentDir(bool overwrite) | ||
| { | ||
| using TempDirectory source = new TempDirectory(); | ||
| @@ -341,6 +347,7 @@ public void UnixFileModes_RestrictiveParentDir(bool overwrite) | ||
| } | ||
| [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))] | ||
| [ActiveIssue("https://github.com/dotnet/runtime/issues/129227")] | ||
| public void LinkBeforeTarget() | ||
| { | ||
| using TempDirectory source = new TempDirectory(); | ||
| @@ -368,5 +375,96 @@ public void LinkBeforeTarget() | ||
| Assert.True(File.Exists(filePath), $"{filePath}' does not exist."); | ||
| Assert.True(File.Exists(linkPath), $"{linkPath}' does not exist."); | ||
| } | ||
| [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))] | ||
| [ActiveIssue("https://github.com/dotnet/runtime/issues/129227")] | ||
| public void ExtractToDirectory_RejectsSymlinkDirectoryTraversal_WithNestedFile() | ||
| { | ||
| using TempDirectory root = new TempDirectory(); | ||
| string destDir = Path.Combine(root.Path, "dest"); | ||
| Directory.CreateDirectory(destDir); | ||
| // Absolute path outside destDir | ||
| string linkTarget = "/tmp/outside"; | ||
| string tarPath = Path.Combine(root.Path, "symlink_dir_traversal.tar"); | ||
| using (FileStream stream = new FileStream(tarPath, FileMode.Create, FileAccess.Write)) | ||
| using (TarWriter writer = new TarWriter(stream, leaveOpen: false)) | ||
| { | ||
| // symlink: "link" -> "/tmp/outside" | ||
| writer.WriteEntry(new PaxTarEntry(TarEntryType.SymbolicLink, "link") | ||
| { | ||
| LinkName = linkTarget | ||
| }); | ||
| // file: "link/test.txt" with "hello" | ||
| byte[] content = Encoding.UTF8.GetBytes("hello"); | ||
| var fileEntry = new PaxTarEntry(TarEntryType.RegularFile, "link/test.txt") | ||
| { | ||
| DataStream = new MemoryStream(content, writable: false) | ||
| }; | ||
| fileEntry.DataStream.Position = 0; | ||
| writer.WriteEntry(fileEntry); | ||
| } | ||
| Assert.Throws<IOException>(() => TarFile.ExtractToDirectory(tarPath, destDir, overwriteFiles: true)); | ||
| // Nothing should be created in dest | ||
| string linkPath = Path.Combine(destDir, "link"); | ||
| string outsideFilePath = Path.Combine(destDir, "link", "test.txt"); | ||
| Assert.False(File.Exists(linkPath) || Directory.Exists(linkPath), "link should not have been created."); | ||
| Assert.False(File.Exists(outsideFilePath) || Directory.Exists(linkPath), "traversal link should not have been created."); | ||
hoyosjs marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))] | ||
| [ActiveIssue("https://github.com/dotnet/runtime/issues/129227")] | ||
| public void ExtractToDirectory_RejectsChainedSymlinkDirectoryTraversal_WithNestedFile() | ||
| { | ||
| // dir a/ | ||
| // symlink a/b → . | ||
| // symlink a/b/c → . | ||
| // symlink a/b/c/d → ../../outside | ||
| // file a/d/ pwned.txt escapes | ||
| using TempDirectory root = new TempDirectory(); | ||
| string destDir = Path.Combine(root.Path, "dest"); | ||
| Directory.CreateDirectory(destDir); | ||
| string tarPath = Path.Combine(root.Path, "chained_symlink_traversal.tar"); | ||
| using (FileStream stream = new FileStream(tarPath, FileMode.Create, FileAccess.Write)) | ||
| using (TarWriter writer = new TarWriter(stream, leaveOpen: false)) | ||
| { | ||
| writer.WriteEntry(new PaxTarEntry(TarEntryType.Directory, "a/")); | ||
| writer.WriteEntry(new PaxTarEntry(TarEntryType.SymbolicLink, "a/b") { LinkName = "." }); | ||
| writer.WriteEntry(new PaxTarEntry(TarEntryType.SymbolicLink, "a/b/c") { LinkName = "." }); | ||
| writer.WriteEntry(new PaxTarEntry(TarEntryType.SymbolicLink, "a/b/c/d") { LinkName = "../../outside" }); | ||
| var pwned = new PaxTarEntry(TarEntryType.RegularFile, "a/d/pwned.txt") | ||
| { | ||
| DataStream = new MemoryStream(Encoding.UTF8.GetBytes("pwned")) | ||
| }; | ||
| writer.WriteEntry(pwned); | ||
| } | ||
| if (OperatingSystem.IsWindows()) | ||
| { | ||
| // Windows only creates file symlinks and trying to process a directory symlink will throw UnauthorizedAccessException instead of IOException | ||
| Assert.Throws<UnauthorizedAccessException>(() => TarFile.ExtractToDirectory(tarPath, destDir, overwriteFiles: true)); | ||
| } | ||
| else | ||
| { | ||
| Assert.Throws<IOException>(() => TarFile.ExtractToDirectory(tarPath, destDir, overwriteFiles: true)); | ||
| } | ||
| string outsideDir = Path.Combine(root.Path, "outside"); | ||
| Assert.False(Directory.Exists(outsideDir), "outside/directory should not have been created."); | ||
| Assert.False(File.Exists(Path.Combine(outsideDir, "pwned.txt")), "pwned.txt should not have been written outside destination."); | ||
| } | ||
| } | ||
| } | ||
7 changes: 7 additions & 0 deletions
7 src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs
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
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.