CVE-2021-32842 Path Traversal in SharpZipLib

Medium 4.0 Published Updated

An attacker can create files outside the intended directory due to missing slash validation in SharpZipLib, potentially overwriting files.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Local or same network only
Victim action needed
Not needed
Fix
Available

What is CVE-2021-32842?

CVE-2021-32842 is a medium-severity path traversal vulnerability in icsharpcode sharpziplib, published on 26 Jan 2022. It can only be exploited from the same machine or local network, with no action from the victim.

Official description

SharpZipLib (or #ziplib) is a Zip, GZip, Tar and BZip2 library. Starting version 1.0.0 and prior to version 1.3.3, a check was added if the destination file is under a destination directory. However, it is not enforced that `_baseDirectory` ends with slash. If the _baseDirectory 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. Version 1.3.3 fixed this vulnerability.

Weakness: CWE-22

Which versions are affected by CVE-2021-32842?

2 open source packages ship an affected version, including SharpZipLib. It affects 1 product.

PackageAffectedFixed in
SharpZipLib NuGetFrom 1.0.01.3.3
SharpZipLib NuGetFrom 1.0.01.3.3

Products include Sharpziplib Project Sharpziplib.

How do I fix CVE-2021-32842?

Upgrade SharpZipLib to 1.3.3 or later.

Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.

Is CVE-2021-32842 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2021-32842 exists.

Sources

Also known as GHSA-mm6g-mmq6-53ff, UBUNTU-CVE-2021-32842.

Is CVE-2021-32842 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free