logo

CVE-2021-39208 sharpcompress

Package

Manager: nuget
Name: sharpcompress
Vulnerable Version: >=0 <0.29

Severity

Level: Medium

CVSS v3.1: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N

CVSS v4.0: CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N

EPSS: 0.00432 pctl0.61803

Details

Partial path traversal in sharpcompress SharpCompress recreates a hierarchy of directories under destinationDirectory if ExtractFullPath is set to true in options. In order to prevent extraction outside the destination directory the destinationFileName path is verified to begin with fullDestinationDirectoryPath. However it is not enforced that fullDestinationDirectoryPath ends with slash: ```csharp public static void WriteEntryToDirectory(IEntry entry, string destinationDirectory, ExtractionOptions? options, Action<string, ExtractionOptions?> write) { string destinationFileName; string file = Path.GetFileName(entry.Key); string fullDestinationDirectoryPath = Path.GetFullPath(destinationDirectory); ... throw new ExtractionException("Entry is trying to write a file outside of the destination directory."); } ``` If the destinationDirectory is not slash terminated like /home/user/dir it is possible to create a file with a name thats begins as the destination directory one level up from the directory, i.e. /home/user/dir.sh. #### Impact Because of the file name and destination directory constraints the arbitrary file creation impact is limited and depends on the use case.

Metadata

Created: 2021-09-20T19:53:42Z
Modified: 2024-07-08T14:33:23Z
Source: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2021/09/GHSA-jp7f-grcv-6mjf/GHSA-jp7f-grcv-6mjf.json
CWE IDs: ["CWE-22"]
Alternative ID: GHSA-jp7f-grcv-6mjf
Finding: F063
Auto approve: 1