CVE-2021-39208 json
WriteEntryToDirectory used for an archive extraction is vulnerable to partial path traversal.
published 2021-09-16 5 y ago modified 2026-07-08 4 mo ago also GHSA-jp7f-grcv-6mjf , EUVD-2021-2087
- cvss
- 4.3
- version 3.1, CNA
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 1.2%
- EPSS 1.2% chance of exploitation in 30 days, percentile 68%
- public exploits
- 0
- none known
Summary
SharpCompress is a fully managed C# library to deal with many compression types and formats. Versions prior to 0.29.0 are vulnerable to partial path traversal. 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, prior to version 0.29.0, it is not enforced that fullDestinationDirectoryPath ends with slash. 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`. Because of the file name and destination directory constraints the arbitrary file creation impact is limited and depends on the use case. This issue is fixed in SharpCompress version 0.29.0.
Patch / fix
- nuget SharpCompress 0.29
- sharpcompress_project sharpcompress 0.29.0
Exploit prediction
1.19% chance of exploitation in the next 30 days, higher than 68% of all scored CVEs (FIRST EPSS, 2026-11-08).
Exploits and checks
- github.com https://github.com/adamhathcock/sharpcompress/security/advisories/GHSA-jp7f-grcv-6mjf referenced PoC, tagged "exploit" by a source, unverified
CVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| CNA | 3.1 | 4.3 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N |
| NVD | 2.0 | 4.0 | AV:N/AC:L/Au:S/C:N/I:P/A:N |
| GitHub | 3.1 | 4.3 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N |
Affected packages
| ecosystem | package | affected | fixed in |
|---|---|---|---|
| nuget | SharpCompress | <0.29 |
0.29 |
Affected products
- adamhathcock sharpcompress
Classification
- Weakness
-
- CWE-22 Improper Limitation of a Pathname to a Restricted Directory
References
-
github.com
/adamhathcock/sharpcompress/pull/614
web, patch, third-party-advisory
-
github.com
/adamhathcock/sharpcompress/commit/ea5c8dc06314c7a5068e7901c51a625224d2b288
web
-
github.com
/adamhathcock/sharpcompress/security/advisories/GHSA-jp7f-grcv-6mjf
web, exploit, third-party-advisory
-
github.com
/adamhathcock/sharpcompress/releases/tag/0.29.0
web, release-notes, third-party-advisory
-
nvd.nist.gov
/vuln/detail/CVE-2021-39208
advisory
-
github.com
/adamhathcock/sharpcompress
package
Sources
- CVE List CVE-2021-39208
- GitHub Advisory GHSA-jp7f-grcv-6mjf
- NVD CVE-2021-39208
Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.