# CVE-2021-39208: WriteEntryToDirectory used for an archive extraction is vulnerable to partial path traversal.

- Severity: Medium 4.3 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 1.19%, higher than 68% of CVEs (2026-12-01)
- Public exploit code or proof of concept: one link below, marked "exploit"
- Published: 2021-09-16T14:35:11.000Z
- Modified: 2026-07-08T06:29:22.057Z
- Also known as: GHSA-jp7f-grcv-6mjf
- Weaknesses: CWE-22
- Assigned by: GitHub_M

## Description

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.

(As written by CVE List.)

## Affected

- adamhathcock sharpcompress: < 0.29.0
- SharpCompress (NuGet): before 0.29
- sharpcompress_project sharpcompress: before 0.29.0

## Every score

- GitHub_M: CVSS:3.1 4.3 Medium `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N`
- GitHub: CVSS:3.1 4.3 Medium `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N`
- GitHub: CVSS:4.0 Medium `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`
- NVD: CVSS:2.0 4.0 Medium `AV:N/AC:L/Au:S/C:N/I:P/A:N`

## References

- <https://github.com/adamhathcock/sharpcompress/security/advisories/GHSA-jp7f-grcv-6mjf> (exploit, third-party-advisory, web)
- <https://github.com/adamhathcock/sharpcompress/pull/614> (patch, third-party-advisory, web)
- <https://github.com/adamhathcock/sharpcompress/releases/tag/0.29.0> (release-notes, third-party-advisory, web)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-39208> (advisory)
- <https://github.com/adamhathcock/sharpcompress/commit/ea5c8dc06314c7a5068e7901c51a625224d2b288> (web)
- <https://github.com/adamhathcock/sharpcompress> (package)

## Sources

- CVE List: [CVE-2021-39208](https://www.cve.org/CVERecord?id=CVE-2021-39208), CVE Terms of Use, modified 2024-08-04
- GitHub Advisory Database: [GHSA-jp7f-grcv-6mjf](https://github.com/advisories/GHSA-jp7f-grcv-6mjf), CC-BY-4.0, modified 2026-07-08
- NVD: [CVE-2021-39208](https://nvd.nist.gov/vuln/detail/CVE-2021-39208), Public domain, modified 2026-06-17

---

Page: https://cve.day/CVE-2021-39208 · Whole record: https://cve.day/CVE-2021-39208.json · Rebuilt by cve.day 2026-11-25T22:58:04.007Z
