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

解压缩失败Zip bomb attack detected #3018

Closed
airujingye opened this issue Mar 27, 2023 · 8 comments
Closed

解压缩失败Zip bomb attack detected #3018

airujingye opened this issue Mar 27, 2023 · 8 comments

Comments

@airujingye
Copy link

版本情况

JDK版本: openjdk_8_201
hutool版本: 5.8.15(请确保最新尝试是否还有问题)

问题描述(包括截图)

使用最新版后,解压zip文件时提示Zip bomb attack detected。之前使用5.5.2版本没有这个问题。

  1. 复现代码
    //压缩文件的代码是
    ZipUtil.zip(exportDir, Charset.forName("UTF-8"));

// 解压代码
unzipDir = ZipUtil.unzip(modelFile.getInputStream(), tempDir, Charset.forName("UTF-8"));

Console.log("报错了");

// 报错信息
cn.hutool.core.exceptions.UtilException: Zip bomb attack detected, invalid sizes: compressed -1, uncompressed -1, name cy_user_process.png
at cn.hutool.core.compress.ZipReader.checkZipBomb(ZipReader.java:247)
at cn.hutool.core.compress.ZipReader.readFromStream(ZipReader.java:224)
at cn.hutool.core.compress.ZipReader.read(ZipReader.java:188)
at cn.hutool.core.compress.ZipReader.readTo(ZipReader.java:148)
at cn.hutool.core.compress.ZipReader.readTo(ZipReader.java:135)
at cn.hutool.core.util.ZipUtil.unzip(ZipUtil.java:665)
at cn.hutool.core.util.ZipUtil.unzip(ZipUtil.java:650)
3. 堆栈信息
image

  1. 测试涉及到的文件(注意脱密)

比如报错的Excel文件,有问题的图片等。

@looly
Copy link
Member

looly commented Mar 27, 2023

新版本中增加了Zip bomb漏洞安全检查。

image

看报错是你的name cy_user_process.png文件压缩后大小没有读到。

麻烦提供下测试的文件,之后再打开此issue。

@looly looly closed this as completed Mar 27, 2023
@looly looly added the question label Mar 27, 2023
@airujingye
Copy link
Author

新版本中增加了Zip bomb漏洞安全检查。

image

看报错是你的name cy_user_process.png文件压缩后大小没有读到。

麻烦提供下测试的文件,之后再打开此issue。

导出导入测试.zip
这个压缩文件是用hutool代码压缩的,如果手动解压后再压缩,最后用代码执行解压就没这个问题ZipUtil.unzip()

@looly looly reopened this Mar 27, 2023
@looly
Copy link
Member

looly commented Mar 27, 2023

@airujingye

image

image

经过测试,使用文件方式可以正常读取元信息,但是使用流不行。

保留此issue稍后处理。

@looly looly removed the question label Mar 27, 2023
@looly
Copy link
Member

looly commented Mar 31, 2023

5.8.17修复此问题,感谢~

@looly looly closed this as completed Mar 31, 2023
@looly looly added the bug label Mar 31, 2023
@werfei
Copy link

werfei commented May 18, 2023

5.8.17依然存在这个问题

@looly
Copy link
Member

looly commented May 18, 2023

@werfei 更新最新试下。

@chuzhongzai
Copy link

版本情况
JDK版本: openjdk-17.0.5
hutool版本: 5.8.20(请确保最新尝试是否还有问题)

问题描述(包括截图)
刚刚好遇到压缩一百倍的情况,导致zip bomb错误。能否给一个检测炸弹的开关或者提供改倍数的函数?这个是自己两个服务器之间传文件的场景,也许还有其他不需要检测炸弹的场景?
image

test.zip

@looly
Copy link
Member

looly commented Jul 20, 2023

@A-Pupils-form-china 这里确实是个极端的例子。

5.8.21在ZipReader中增加setMaxSizeDiff方法来自定义这个参数。

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

No branches or pull requests

4 participants