The vulnerability is a path traversal issue in the .NET System.Formats.Tar library, specifically within the TarFile.ExtractToDirectory method. An attacker can craft a TAR archive containing a symbolic link that points to a location outside of the intended extraction directory. When the vulnerable version of the library attempts to extract this archive, it follows the symbolic link, allowing the attacker to write files to arbitrary locations on the filesystem.
The patch addresses this vulnerability by introducing new validation logic. The core of the fix is in the System.Formats.Tar.TarEntry.ExtractRelativeToDirectoryAsync method, which is called internally by TarFile.ExtractToDirectory. The patch adds a call to a new method, FilePathEscapesDirectory, which resolves the real path of the file to be extracted, including any symbolic links, and checks if the final path is within the boundaries of the destination directory. If a path traversal is detected, an IOException is thrown, preventing the malicious file from being written.
The identified vulnerable functions are System.Formats.Tar.TarFile.ExtractToDirectory, as it is the public entry point for the vulnerable operation, and System.Formats.Tar.TarEntry.ExtractRelativeToDirectoryAsync, which contains the flawed logic that was fixed by the patch.