/

CVE-2025-70952

Severity:

HIGH RISK

(7.5)

Path Traversal / Zip Slip in pf4j Unzip.extract()

CVE-2025-70952

Analyzed

Vulnerability type

Category:

Path Traversal / Zip Slip

CWE:

CWE-22

Impact:

Arbitrary File Write via Path Traversal

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

pf4j contains a path traversal (Zip Slip) vulnerability in the extract() function of Unzip.java, where zip entry names are not properly normalized and validated before being written to disk.

An attacker who can supply or influence the zip file content may cause files to be created or overwritten outside the intended extraction directory, leading to data corruption, configuration tampering, or potential code execution in certain deployments.

Affected context

This vulnerability appears in environments where pf4j is used to extract plugin archives or other zip bundles via the Unzip.extract() functionality.

It is relevant when the application accepts zip files from external or semi-trusted sources and extracts them on the server-side.

The risk increases when the extraction root is close to application binaries, configuration folders, or other sensitive directories, or when the running process has broad filesystem permissions.

Exploit preconditions

  • Attack surface: Any server-side or build-time functionality that uses pf4j's Unzip.extract() to unpack zip files.
  • Required access: Ability to provide or control a zip file that will be extracted (e.g., plugin upload, extension repository, or automated update mechanism).
  • Trigger point: The vulnerable extract() method processes zip entries whose names contain ../ or absolute paths.
  • Why exploitation is possible: The implementation lacks robust path normalization and post-normalization checks to ensure that the output path remains within the intended extraction directory, allowing crafted zip entries to escape the target folder.

Why this happens

The underlying bug is a classic path traversal during archive extraction (Zip Slip).

The extract() method in Unzip.java uses zip entry names directly to construct filesystem paths without enforcing that the final, normalized path remains confined to the designated extraction root.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled or external input (zip entry names) influences file system paths without adequate canonicalization and boundary checks.

The abstract insecure pattern is: "Use of untrusted path components from archive metadata to create files on disk, without validating that the resolved path is within a trusted directory."

Potential impact

  • Overwriting application or configuration files that the pf4j process can write to
  • Creating new files in sensitive locations, which could be used to plant malicious scripts or code
  • Tampering with plugin directories, logs, or data files, potentially affecting integrity and availability
  • In some deployments, escalating to remote code execution if overwritten files are later executed or interpreted by the system

General mitigation guidance

Effective mitigation focuses on strictly confining archive extraction to a safe directory and rejecting unsafe paths:

  • Normalize each zip entry path (e.g., using canonical path resolution) and verify that it remains a child of the intended extraction root before writing.
  • Reject entries containing path traversal sequences (such as ../) or absolute paths, rather than attempting to "fix" them silently.
  • Use high-level archive extraction utilities or libraries that include built-in Zip Slip protections where possible.
  • Run the extraction logic under least-privilege accounts with write access limited to non-sensitive directories.
  • Treat all external archives as untrusted data and pair extraction with additional hardening (e.g., separate working directories, containerization).

How teams detect issues like this

Detection typically combines code-level review and behavioral monitoring:

  • Static analysis: Flag file operations where paths are derived from zip entry names or other archive metadata without canonicalization and boundary checks.
  • Code review signals: Look for direct concatenation of ZipEntry.getName() (or equivalent) with target directories, missing checks that the resolved path starts with the extraction root, and absence of explicit traversal rejection logic.
  • Policy enforcement: Add secure extraction patterns to coding standards and apply automated checks in CI to prevent unvalidated path writes from archive data.
  • Runtime monitoring: Optionally log extraction destinations and alert on attempts to write outside expected directories when extracting archives.

Sources

SourceLink
gist.github.comgist.github.com/weaver4VD/410f23adb24ef5f5077f021f4393e705
github.comgithub.com/pf4j/pf4j/commit/20c2f80089d1ea779e22c2de5f109a0bce4e1b14
github.comgithub.com/pf4j/pf4j/issues/618
github.comgithub.com/pf4j/pf4j/issues/623

Frequently asked

questions

It can be, if a remote user can upload or otherwise provide zip files that the application extracts using pf4j. In purely local or tightly controlled scenarios, the risk is reduced but still present if archives can be influenced.

An attacker needs the ability to control the contents of a zip file processed by Unzip.extract(), such as through plugin upload features, extension repositories, automated update feeds, or any integration that ingests external archives.

Normalize the path derived from each zip entry and enforce that it stays within the intended extraction directory before writing. Reject any entries that produce paths outside the allowed root, and avoid using zip entry names directly without these checks.

Establish a standard, reusable archive-extraction utility that performs canonicalization and directory-boundary enforcement, mandate its use in coding guidelines, and support it with static analysis rules and code reviews focused on file path handling and archive processing.

Find out what's already
exploitable in your codebase.