Miggo Logo

CVE-2021-32841: Path Traversal in SharpZipLib

4

CVSS Score
3.1

Basic Information

EPSS Score
0.57377%
Published
2/1/2022
Updated
2/3/2023
KEV Status
No
Technology
TechnologyC#

Technical Details

CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
Package NameEcosystemVulnerable VersionsFirst Patched Version
SharpZipLibnuget>= 1.3.0, < 1.3.31.3.3

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems from the ExtractEntry method's path validation logic. The original code combined destDir with the entry's filename and checked if the full normalized path started with destDir. However, if destDir was not slash-terminated (e.g., /home/user/dir), an entry named dir.sh would result in a path like /home/user/dir/dir.sh, which passes the check. More critically, entries exploiting partial directory matches (e.g., dir.sh as a sibling file) could bypass containment checks. The patch replaced Path.GetFullPath(destFile) with the directory portion (destFileDir), ensuring the parent directory of the extracted file is strictly under destDir, mitigating partial matches. The commit diff and advisory explicitly reference this function as the patched location, confirming its role in the vulnerability.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

S**rpZipLi* (or #zipli*) is * Zip, *Zip, T*r *n* *Zip* li*r*ry. St*rtin* v*rsion *.*.* *n* prior to v*rsion *.*.*, * ****k w*s ***** i* t** **stin*tion *il* is un**r **stin*tion *ir**tory. *ow*v*r, it is not *n*or*** t**t `**st*ir` *n*s wit* sl*s*. I

Reasoning

T** vuln*r**ility st*ms *rom t** `*xtr**t*ntry` m*t*o*'s p*t* v*li**tion lo*i*. T** ori*in*l *o** *om*in** `**st*ir` wit* t** *ntry's *il*n*m* *n* ****k** i* t** *ull norm*liz** p*t* st*rt** wit* `**st*ir`. *ow*v*r, i* `**st*ir` w*s not sl*s*-t*rmin*