CVE-2021-39208
What it is
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.
At a glance
- Exploitability
- Can be exploited over the network with a low-privilege account. Limited direct impact.
- Exploit odds
- 1.2% chance of exploitation in the next 30 days (EPSS).
- Fix
- A patch, advisory or fixed version is referenced. Upgrade or apply it.
Timeline
- PublishedDisclosed publicly on CVE.org and NVD
- Last updatedMost recent change to the record
Why it ranks here
- Exploited in the wild: no, CISA does not list it.
- Exploit odds: 1.2% in the next 30 days (EPSS).
- Severity: 4.3 MEDIUM (CVSS).
- Fix: a patch or advisory is linked.
Details
- Published
- Last modified
- Exploit probability
- 1.2% · EPSS, next 30 days
- Weakness
- CWE-22 · Path traversal
- Record status
- Modified
Affected
- Sharpcompress Project Sharpcompress < 0.29.0
Attack profile CVSS 3.1 · 4.3
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- Low
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- Low
- Availability
- None
Raw vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N
Is it in your code?
Hand this to your coding agent. It searches your project for the affected products and checks versions. Nothing leaves your machine.
Read https://cve-list.com/agent/cve/CVE-2021-39208.md and follow it. Check whether this project is affected by CVE-2021-39208. Read only. Don't change anything and don't upload my code. Tell me yes, no or not sure, with the file as proof.
Fix and advisories
- https://github.com/adamhathcock/sharpcompress/pull/614
- https://github.com/adamhathcock/sharpcompress/releases/tag/0.29.0
- 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
- https://github.com/adamhathcock/sharpcompress/security/advisories/GHSA-jp7f-grcv-6mjf
References
- https://github.com/adamhathcock/sharpcompress/pull/614
- https://github.com/adamhathcock/sharpcompress/releases/tag/0.29.0
- 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
- https://github.com/adamhathcock/sharpcompress/security/advisories/GHSA-jp7f-grcv-6mjf