-
Notifications
You must be signed in to change notification settings - Fork 322
Description
This vulnerability is of java.lang.NullPointerException, and can be triggered in latest version zip4j (2.9.0).
It is caused by not checking the pointer before dereference it and also failing to catch the runtime java exception (it should be wrapped as one kind of JSONException) and can be used for attackers to launch DoS (Denial of Service) attack for any java program that uses this library (since the user of zip4j doesn't know they need to catch this kind of exception) (CWE-476: NULL Pointer Dereference, CWE-248: Uncaught exception).
Likely, the root cause of this crash is in net.lingala.zip4j.io.inputstream.ZipInputStream.isEntryDirectory::ZipInputStream.java:314.
| return entryName.endsWith("/") || entryName.endsWith("\\"); |
See more detail from the following crash stack.
Crash stack:
The crash thread's stack is as follows:
net.lingala.zip4j.io.inputstream.ZipInputStream.isEntryDirectory::ZipInputStream.java:314
net.lingala.zip4j.io.inputstream.ZipInputStream.verifyLocalFileHeader::ZipInputStream.java:267
net.lingala.zip4j.io.inputstream.ZipInputStream.getNextEntry::ZipInputStream.java:97
net.lingala.zip4j.io.inputstream.ZipInputStream.getNextEntry::ZipInputStream.java:83
com.test.Entry.main::Entry.java:37
Steps to reproduce:
- Build the following java code with the corresponding zip4j library (version 2.9.0).
## Download zip4j_env_reproduce.tar.gz from https://drive.google.com/file/d/1MekCBIghKxIW4j-TLjZkm8ovvLb_grm5/view?usp=sharing
tar -xf zip4j_env_reproduce.tar.gz
cd zip4j_env_reproduce
bash build.sh
- Run the built program to see the crash by feeding one of the poc file contained in the pocs.tar.gz, e.g. :
(poc file can be downloaded from https://drive.google.com/file/d/1is17ysO4o5FsjHnXMIWHIQ9zGiHM5S-n/view?usp=sharing)
java -jar target/Entry-1.0-SNAPSHOT-jar-with-dependencies.jar pocs/crash-e2a9439c6d0b7e34d11105eb910bb6a539613652
Any further discussion for this vulnerability including fix is welcomed!