GHSL-2021-125: Path traversal in SharpZipLib - CVE-2021-32840, CVE-2021-32841, CVE-2021-32842
SharpZipLib did not properly validate extraction paths, allowing TAR or ZIP entries to write files outside the intended directory. An attacker could craft a malicious archive to write arbitrary files, potentially leading to code execution.
SharpZipLib allows full or partial (depending on the version) traversal of the extraction path.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The library failed to ensure that the full path of each extracted file stays within the intended destination directory, either by not checking at all or by not enforcing a trailing slash on the destination path.
Impact
This could lead to arbitrary file write, which may result in code execution; for the slash-termination issues, the impact is limited to creating files with names that begin with the destination directory name, depending on the use case.
What the attacker needed
Victim extracts a malicious archive
The fix
The issue was fixed in version 1.3.3 by properly validating that extracted files stay within the destination directory.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you extract a ZIP or TAR file, the library should only write files inside the folder you choose. Here, it didn't check properly, so a malicious archive could write files to other places on your computer, like your home folder. That could let an attacker run their own code.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.