diff options
| author | Matt Wilson <msw@amazon.com> | 2024-01-17 14:46:18 -0800 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2024-01-17 15:08:08 -0800 |
| commit | 14a5f8f266c16c87ab6c086fc52b770b27701e01 (patch) | |
| tree | ef3a7752a686dd5784a2a695204a6a3b4eca17b6 | |
| parent | 44dc43ab047d65febed972a17b0e3bf7e994e8f2 (diff) | |
| download | zlib-14a5f8f266c16c87ab6c086fc52b770b27701e01.tar.gz zlib-14a5f8f266c16c87ab6c086fc52b770b27701e01.tar.bz2 zlib-14a5f8f266c16c87ab6c086fc52b770b27701e01.zip | |
Neutralize zip file traversal attacks in miniunz.
Archive formats such as .zip files are generally susceptible to
so-called "traversal attacks". This allows an attacker to craft
an archive that writes to unexpected locations of the file system
(e.g., /etc/shadow) if an unspecting root user were to unpack a
malicious archive.
This patch neutralizes absolute paths such as /tmp/moo and deeply
relative paths such as dummy/../../../../../../../../../../tmp/moo
The Debian project requested CVE-2014-9485 be allocated for the
first identified weakness. The fix was incomplete, resulting in a
revised patch applied here. Since there wasn't an updated version
released by Debian with the incomplete fix, I suggest we use this
CVE to identify both issues.
Link: https://security.snyk.io/research/zip-slip-vulnerability
Link: https://bugs.debian.org/774321
Link: https://bugs.debian.org/776831
Link: https://nvd.nist.gov/vuln/detail/CVE-2014-9485
Reported-by: Jakub Wilk <jwilk@debian.org>
Fixed-by: Michael Gilbert <mgilbert@debian.org>
| -rw-r--r-- | contrib/minizip/miniunz.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c index 0c2fb0d..d627c42 100644 --- a/contrib/minizip/miniunz.c +++ b/contrib/minizip/miniunz.c | |||
| @@ -356,6 +356,20 @@ static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_pa | |||
| 356 | else | 356 | else |
| 357 | write_filename = filename_withoutpath; | 357 | write_filename = filename_withoutpath; |
| 358 | 358 | ||
| 359 | if (write_filename[0]!='\0') | ||
| 360 | { | ||
| 361 | const char* relative_check = write_filename; | ||
| 362 | while (relative_check[1]!='\0') | ||
| 363 | { | ||
| 364 | if (relative_check[0]=='.' && relative_check[1]=='.') | ||
| 365 | write_filename = relative_check; | ||
| 366 | relative_check++; | ||
| 367 | } | ||
| 368 | } | ||
| 369 | |||
| 370 | while (write_filename[0]=='/' || write_filename[0]=='.') | ||
| 371 | write_filename++; | ||
| 372 | |||
| 359 | err = unzOpenCurrentFilePassword(uf,password); | 373 | err = unzOpenCurrentFilePassword(uf,password); |
| 360 | if (err!=UNZ_OK) | 374 | if (err!=UNZ_OK) |
| 361 | { | 375 | { |
