🛡️ CVE-2021-39208 — sharpcompress
Description
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.
How this vulnerability can be exploited
This issue can be reached over the network, attack complexity is low, an attacker needs low-level privileges on the target. No user interaction is required. Rated impact: confidentiality none, integrity low, availability none.
Weakness class
CVE-2021-39208 is classified as CWE-22: Path Traversal. A file path built from user input is not confined to the intended directory, letting an attacker reach files elsewhere on the filesystem.
Affected software
CVE-2021-39208 is recorded against 1 package.
- sharpcompress (fixed in 0.29)
Timeline and source
Published on 20 September 2021 and last revised on 8 July 2026. No public exploit is currently recorded for this entry. Record sourced from OSV.
References
github.com (Web)
nvd.nist.gov (Advisory)
github.com (Web)
github.com (Web)
github.com (Package)
github.com (Web)
Details
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
Affected Packages
| Software | From version | Fixed in |
|---|---|---|
| sharpcompress | — | 0.29 |
References
Similar Threats
- Medium CVE-2026-44788
More CVE 2021 advisories
Browse all of CVE 2021 in the advisory index.
Free Vulnerability Check
Is your site affected by CVE-2021-39208?
BotEraser helps you identify potentially vulnerable plugins and themes by checking your installation against CVE-2021-39208 and other known CVE records.
Scan My Site Free →No credit card required · Results in minutes
ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.