在当今数字化时代,深度学习框架的安全性至关重要。然而,即使是备受开发者青睐的开源框架也可能隐藏着潜在的安全漏洞。最近,Deep Java Library(DJL)被曝出存在一个严重的路径遍历漏洞(CVE-2025-0851),这一问题可能让攻击者有机会在目标系统中执行恶意操作。今天,我们就来深入剖析这个漏洞的细节,探讨其危害以及如何有效防范。
-
版本<0.31.1 -
压缩包的创建和解压,分别在默认分隔符不同的操作系统(Windows/Linux)进行
ai.djl.util.TarUtils#untar
ublic static void untar(InputStream is, Path dir, boolean gzip) throws
IOException {
InputStream bis;
if (gzip) {
bis = new GzipCompressorInputStream(new BufferedInputStream(is));
} else {
bis = new BufferedInputStream(is);
}
bis = CloseShieldInputStream.wrap(bis);
try (TarArchiveInputStream tis = new TarArchiveInputStream(bis)) {
TarArchiveEntry entry;
while ((entry = tis.getNextEntry()) != null) {
String entryName =
ZipUtils.removeLeadingFileSeparator(entry.getName());
if (entryName.contains("..")) {
throw new IOException("Malicious zip entry: " + entryName);
}
Path file = dir.resolve(entryName).toAbsolutePath();
if (entry.isDirectory()) {
Files.createDirectories(file);
} else {
Path parentFile = file.getParent();
if (parentFile == null) {
throw new AssertionError("Parent path should never be
null: " + file);
}
Files.createDirectories(parentFile);
Files.copy(tis, file, StandardCopyOption.REPLACE_EXISTING);
}
}
}
}
首先,引入maven依赖[2]:Maven Repository: ai.djl » api » 0.31.0
import ai.djl.util.TarUtils;
@PostMapping("/CVE-2025-0851")
public void CVE20250851(@RequestParam MultipartFile file, @RequestParam
boolean gzip) {
try{
InputStream fis = file.getInputStream();
//这里只关系根路径"C:/"即可,anyPath可以是任意路径
Path base = Paths.get("C:/anyPath");
TarUtils.untar(fis,base,gzip);
}catch (Exception e){
e.printStackTrace();
}
}
并且,在Kali中创建恶意tar包。
第一步
使用curl访问测试点:
curl -X POST -F "[email protected]" -F "gzip=false"
http://192.168.23.1:8081/CVE-2025-0851
进入untar(...):发现获取到entry.name 的分隔符是/,与上述内容一致。
最终结果:因为服务器权限不足而导致失败,从报错可见,的确是尝试访问了对应的目录。
通过实操可以发现,反过来操作[2]也是可以的。
原文始发于微信公众号(山石网科安全技术研究院):Deep Java Library (DJL) CVE-2025-0851 漏洞复现与深度剖析
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论