/

CVE-2026-40180

Severity:

HIGH RISK

(7.5)

Path Traversal in Quarkus OpenAPI Generator unzip()

CVE-2026-40180

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write Outside Intended Directory

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

A path traversal issue in the unzip() method of Quarkus OpenAPI Generator allows ZIP entries to be extracted to arbitrary filesystem locations outside the intended output directory.

When a crafted ZIP archive includes directory traversal sequences in entry names, an attacker can cause files to be written outside the target folder, potentially overwriting or planting code and configuration files under specific deployment conditions.

Affected context

The vulnerability appears in environments where Quarkus OpenAPI Generator is used to generate REST clients or server stubs from ZIP-based input.

It affects code paths that call the vulnerable unzip() method in ApicurioCodegenWrapper.java and pass ZIP archives that may not be fully trusted or validated.

The risk is most relevant where the generation output directory is on the same filesystem as application source, build artifacts, or sensitive configuration, and where generated files may subsequently be compiled, executed, or loaded by other tooling.

Exploit preconditions

  • Attack surface: Components that invoke Quarkus OpenAPI Generator with externally supplied or modifiable ZIP archives (e.g., uploaded specs, integrated pipelines, or shared build artifacts).
  • Required access: Ability to provide or influence the ZIP file processed by the unzip() method, either directly (file upload, URL input) or indirectly (compromised upstream artifact).
  • Trigger point: Execution of the code generation process that unpacks the ZIP to an output directory.
  • Why exploitation is possible: The code constructs destination paths with new File(toOutputDir, entry.getName()) and writes content without normalizing and validating the resulting path to ensure it stays within the intended output directory, enabling directory traversal via ../ segments.

Why this happens

The bug stems from insufficient validation of file paths derived from ZIP entry names during extraction.

The implementation trusts entry.getName() and directly concatenates it with the output directory, failing to normalize the resulting path and verify that it does not escape the designated root.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where untrusted path components allow access to filesystem locations outside the intended directory.

In abstract terms, any archive extraction routine that does not canonicalize paths and explicitly enforce a "stay within this base directory" policy is vulnerable to this class of directory traversal.

Potential impact

  • Arbitrary file creation in directories outside the intended generation output folder
  • Overwriting of existing files accessible to the running process, such as source code, templates, or configuration files
  • Planting of malicious Java or configuration files that may later be compiled or executed by build tools or runtime environments
  • Interference with build pipelines or developer environments by corrupting generated sources or project metadata
  • In some setups, potential escalation to remote code execution if overwritten files are subsequently executed with higher privileges or exposed via other services

General mitigation guidance

Effective mitigation focuses on enforcing strict directory boundaries and treating archive contents as untrusted.

Pattern-based hardening approaches include:

  • Normalizing and canonicalizing the destination path for each ZIP entry, and verifying that it is still a descendant of the intended output directory before writing.
  • Rejecting or skipping entries whose names contain path traversal sequences, absolute paths, or drive prefixes, and maintaining a strict allowlist of acceptable patterns (e.g., no .. segments).
  • Running code generation processes with the least filesystem privileges necessary, isolating their output to dedicated directories that do not contain sensitive files.
  • Avoiding reuse of generation output directories that overlap with core application or system directories, helping to limit the impact of any unexpected files.
  • Treating all archive input as untrusted and applying input validation policies at the boundary where ZIP files are accepted or assembled.

How teams detect issues like this

Detection can be approached at both code and process levels:

  • Static analysis: Configure rules or custom checks to flag uses of ZIP/Archive extraction APIs where entry names are directly combined with target directories without canonicalization and boundary checks.
  • Code review: Look for patterns like new File(baseDir, entry.getName()) followed by write operations, and verify that there is explicit logic to reject or sanitize entries with .., absolute paths, or unusual prefixes.
  • Policy enforcement: Establish internal secure coding guidelines around archive processing, and integrate automated linters into CI to detect non-compliant path handling.
  • Runtime and pipeline monitoring: In build or generator environments, log extracted file paths and alert on writes that fall outside expected directories, helping to surface misuse or unexpected archive contents.

Sources

SourceLink
github.comgithub.com/quarkiverse/quarkus-openapi-generator/commit/08b406414ff30ed192e86c7fa924e57565534ff0
github.comgithub.com/quarkiverse/quarkus-openapi-generator/commit/e2a9c629a3df719abc74569a3795c265fd0e1239
github.comgithub.com/quarkiverse/quarkus-openapi-generator/security/advisories/GHSA-jx2w-vp7f-456q

Frequently asked

questions

It can be, depending on how ZIP input reaches the vulnerable unzip() call.

If remote users can upload or otherwise control the ZIP file processed by Quarkus OpenAPI Generator, the vulnerability may be remotely exploitable; if ZIP input is strictly internal and controlled, exposure is more limited.

An attacker must be able to supply or influence the ZIP archive that the generator processes.

This could be direct access (e.g., upload, API submission) or indirect control through a compromised upstream build artifact or repository.

The safest pattern is to canonicalize each entry's target path, verify that it remains within the intended output directory, and reject entries that attempt to escape this root or use absolute paths.

Additionally, ignoring suspicious entries with traversal sequences and limiting the generator's filesystem privileges further reduces risk.

Treat all archive contents as untrusted, adopt a standard utility or library for safe archive extraction, and enforce a project-wide policy requiring normalization and boundary checks for any path built from external input.

Incorporating static analysis rules and security-focused code reviews for file and path handling code paths helps prevent this class of vulnerabilities from reappearing.

Find out what's already
exploitable in your codebase.