Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory traversal vulnerability from libzip #54

Open
jiahao42 opened this issue May 10, 2020 · 15 comments
Open

Directory traversal vulnerability from libzip #54

jiahao42 opened this issue May 10, 2020 · 15 comments

Comments

@jiahao42
Copy link

jiahao42 commented May 10, 2020

Issue

Given a crafted zip file containing a file of filename ../../../../../../../../tmp/evil.txt, zip will extract the file to /tmp/evil.txt, while actually it should be extracted to ./tmp/evil.txt. This vulnerability could allow the attacker to write a file to an arbitrary directory.

How to reproduce

You can try to reproduce this vulnerability using this zip file, note that the symbol nim -d:useLibzipSrc is needed for compilation. You can find the PoC here

@dmknght
Copy link

dmknght commented Jun 13, 2021

The variable dest should be filtered
https://github.com/nim-lang/zip/blob/master/zip/zipfiles.nim#L193

@StayPirate
Copy link

CVE-2020-23171 has been assigned to this security bug. Is any patch going to be released anytime soon?

@Araq
Copy link
Member

Araq commented Aug 11, 2021

Well the hyperbole isn't motivating to look into the issue.

This vulnerability could allow the attacker to write a file to an arbitrary directory.

The operating system enforces access rights...

@rposkocil
Copy link

Understood but any progress or what is the plan with this issue? Still open and vulnerability tools marks all versions.

@ajurge
Copy link

ajurge commented Aug 25, 2021

Hi is there any update on this because our builds started failing because of CVE-2020-23171?

@VaeterchenFrost
Copy link

Some guidance on remedial actions has been collected, for example, in https://snyk.io/research/zip-slip-vulnerability.

@rposkocil
Copy link

Hi guys, it's false positive. See jeremylong/DependencyCheck#3594.

@StayPirate
Copy link

How can that be a FP if the reported @jiahao42 attached a reproducer? Has anyone tested it?

@prosprice
Copy link

prosprice commented Aug 30, 2021

The linked DependencyCheck project is doing a poor job matching CPEs and has attributed the CVE for this issue to an unrelated Java library. That's the FP that @rposkocil is referring to and what brought me here, but the FP report in that project should not be interpreted to mean that this issue is false.

@StayPirate
Copy link

Just to clarify, we can ignore jeremylong/DependencyCheck#3594 (FP is their problem) and keep tracking this actual security bug with CVE-2020-23171. @prosprice, am I correct?

@prosprice
Copy link

@StayPirate I'm not a Nim user; with that caveat, yes I agree with you.

@StayPirate
Copy link

@Araq could you share some extra information about how the upstream is going to address this issue?

@supakeen
Copy link

I must say that without diminishing the exploitability of this that nim-lang/zip isn't in Nim by default and like many other libraries it can be misused.

This is the same for other languages that provide wrappers around libzip's extractall, see for example the Python documentation warning you against this possibility: https://docs.python.org/3/library/zipfile.html#zipfile.ZipFile.extractall

What would be the proposed 'fix' for this CVE? Removing the extractall binding or documenting that it doesn't handle relative paths?

@kraptor
Copy link

kraptor commented Feb 16, 2024

Shouldn't this bug be moved into nim-lang/zip as it's not a bug in Nim and it's not in the standard library as pointed out by @supakeen ??

@0-wiz-0
Copy link

0-wiz-0 commented Apr 23, 2024

I must say that without diminishing the exploitability of this that nim-lang/zip isn't in Nim by default and like many other libraries it can be misused.

This is the same for other languages that provide wrappers around libzip's extractall, see for example the Python documentation warning you against this possibility: https://docs.python.org/3/library/zipfile.html#zipfile.ZipFile.extractall

What would be the proposed 'fix' for this CVE? Removing the extractall binding or documenting that it doesn't handle relative paths?

libzip doesn't provide an extractall function. (Python doesn't use libzip.)
It's a problem in the zip implementation for nim - they need to sanitize their paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests