jeecgboot/JeecgBoot · error · IOException

解压总大小超限,可能是zip bomb攻击

Error message

解压总大小超限,可能是zip bomb攻击

What it means

Thrown by AiragKnowledgeDocServiceImpl.unzipFile() when the cumulative uncompressed size of all extracted files exceeds MAX_TOTAL_SIZE (1 GB / 1073741824 bytes). This is a zip-bomb defense against decompression ratio attacks where a small archive expands to enormous size.

Source

Thrown at jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/service/impl/AiragKnowledgeDocServiceImpl.java:441

                    log.info("跳过压缩包中的隐藏文件: {}", entry.getName());
                    continue;
                }
                //update-end---author:scott ---date:2026-04-16  for:【issues/9551】macOS压缩包隐藏文件过滤-----------

                Path newPath = safeResolve(targetDir, entry.getName());

                if (entry.isDirectory()) {
                    Files.createDirectories(newPath);
                } else {
                    Files.createDirectories(newPath.getParent());
                    try (InputStream is = zipFile.getInputStream(entry);
                         OutputStream os = Files.newOutputStream(newPath)) {

                        long bytesCopied = copyLimited(is, os, MAX_FILE_SIZE);
                        totalUnzippedSize += bytesCopied;

                        if (totalUnzippedSize > MAX_TOTAL_SIZE) {
                            throw new IOException("解压总大小超限,可能是zip bomb攻击");
                        }
                    }

                    // 解压完成后回调
                    if (afterExtract != null) {
                        afterExtract.accept(newPath.toFile());
                    }
                }
            }
        }
    }

    //update-begin---author:scott ---date:2026-04-16  for:【issues/9551】macOS压缩包隐藏文件过滤-----------
    /**
     * 过滤压缩包中的系统隐藏文件,例如 macOS 自动生成的 __MACOSX 和 ._ 文件。
     */
    static boolean shouldSkipZipEntry(String entryName) {
        if (oConvertUtils.isEmpty(entryName)) {

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Reduce the total size of files in the archive to under 1 GB uncompressed.
  2. Split large archives into smaller batches and import separately.
  3. If legitimate archives consistently exceed 1 GB, increase MAX_TOTAL_SIZE after assessing available disk space.
Defensive patterns

Strategy: validation

Try / catch

try {
    unzipFile(zipFilePath, targetDir, callback);
} catch (IOException e) {
    if (e.getMessage().contains("解压总大小超限")) {
        log.warn("Zip total size limit exceeded: {}", e.getMessage());
        throw new JeecgBootException("压缩包总大小超过1GB限制,请减少文件大小或分批上传");
    }
    throw e;
}

Prevention

When it happens

Trigger: Extracting a zip archive whose total uncompressed content exceeds 1 GB. The check runs after each file's bytes are copied, so it triggers mid-extraction when the running total crosses the threshold.

Common situations: A zip-bomb with high compression ratio (e.g. 42.zip); a legitimately large archive containing large media files or datasets; many moderate-sized files that together exceed 1 GB.

Related errors


AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14). Data as JSON: /api/errors/a623b32aa75a0d7a. Report an issue: GitHub.