CVE-2021-39208

WriteEntryToDirectory used for an archive extraction is vulnerable to partial path traversal.

MEDIUM
4.3
CVSS Score
Published: September 16, 2021 at 02:35 PM UTC
Updated: June 17, 2026 at 04:03 AM UTC
2 products affected across 2 vendorsSharpcompressSharpcompress

Using sharpcompress by adamhathcock?

Get instant alerts when new vulnerabilities affect sharpcompress - before attackers find them.

Real-time alertsTrack your software stackFree plan available
Severity
MEDIUM4.3
Exploit prediction
EPSS 1%

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.

Affected

Our own answer: ranges merged, affected separated from platform-only, with confidence and review flags.

v < 0.29.0
Affected range stops below 0.29.0, so it looks safe — our inference, not a vendor statement
v < 0.29.0
Affected range stops below 0.29.0, so it looks safe — our inference, not a vendor statement

Remediation

No guide yet

No remediation guidance has been written for this CVE yet. What the record does show:

References (3)

CVSS

4.3MEDIUMGitHub_M
Attack Vector
NETWORK
Complexity
LOW
Privileges
LOW
User Interaction
NONE
Scope
UNCHANGED
Confidentiality
NONE
Integrity
LOW
Availability
NONE
Vector?

Quick Info

StatusMODIFIED
CWE
CWE-22

Get alerted

Stop reading CVE feeds looking for your own stack

Track the products you run and VulnTracker tells you when a new CVE affects them — with what is known about fixing it, and nothing about the rest.

Free plan, no card