/

CVE-2026-54545

Severity:

HIGH RISK

(7.1)

Path Traversal (CWE-22) in wakaru JavaScript CLI Tool

CVE-2026-54545

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write / Potential Code Execution

Severity:

HIGH RISK

(7.1)

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 flaw in the wakaru CLI unbundling feature allows crafted module filenames to escape the intended output directory after incomplete sanitization.

If a user runs wakaru --unpack on a malicious bundle, an attacker-controlled filename may write files outside the target directory and, in some environments, lead to code execution.

A path traversal flaw in the wakaru CLI unbundling feature allows crafted module filenames to escape the intended output directory after incomplete sanitization.

If a user runs wakaru --unpack on a malicious bundle, an attacker-controlled filename may write files outside the target directory and, in some environments, lead to code execution.

Affected context

This vulnerability affects projects and build pipelines that use @wakaru/cli to unpack JavaScript bundles with --unpack, and that process bundle content from untrusted or semi-trusted sources.

The issue arises when the CLI derives output paths directly from module filenames contained in the bundle and relies on a single round of sanitization.

Overlapping traversal sequences such as ....// can collapse into ../ after sanitization, allowing generated files to be placed outside the user-selected output directory.

This vulnerability affects projects and build pipelines that use @wakaru/cli to unpack JavaScript bundles with --unpack, and that process bundle content from untrusted or semi-trusted sources.

The issue arises when the CLI derives output paths directly from module filenames contained in the bundle and relies on a single round of sanitization.

Overlapping traversal sequences such as ....// can collapse into ../ after sanitization, allowing generated files to be placed outside the user-selected output directory.

Exploit preconditions

  • Attack surface: Local command-line usage of @wakaru/cli (developer machines, CI/CD agents, automated tools).
  • Required access: Ability to provide or influence a JavaScript bundle that a user or automated system processes with wakaru --unpack.
  • Trigger point: Execution of the unpack operation, where module filenames from the bundle are converted into filesystem paths and written to disk.
  • Why exploitation is possible: The path normalization and sanitization logic is applied only once and does not account for overlapping traversal patterns that become effective after the filesystem resolves them, enabling directory traversal outside the configured output directory.
  • Attack surface: Local command-line usage of @wakaru/cli (developer machines, CI/CD agents, automated tools).
  • Required access: Ability to provide or influence a JavaScript bundle that a user or automated system processes with wakaru --unpack.
  • Trigger point: Execution of the unpack operation, where module filenames from the bundle are converted into filesystem paths and written to disk.
  • Why exploitation is possible: The path normalization and sanitization logic is applied only once and does not account for overlapping traversal patterns that become effective after the filesystem resolves them, enabling directory traversal outside the configured output directory.

Why this happens

The core issue is incomplete validation and normalization of attacker-controlled file paths before writing extracted modules to disk.

The CLI assumes that a single sanitization pass is sufficient to strip traversal sequences, but patterns like ....// are not inherently dangerous until the underlying filesystem collapses them into ../.

This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled path segments are used to construct file system locations without robust canonicalization and enforcement that the final result remains within an intended base directory.

The core issue is incomplete validation and normalization of attacker-controlled file paths before writing extracted modules to disk.

The CLI assumes that a single sanitization pass is sufficient to strip traversal sequences, but patterns like ....// are not inherently dangerous until the underlying filesystem collapses them into ../.

This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled path segments are used to construct file system locations without robust canonicalization and enforcement that the final result remains within an intended base directory.

Potential impact

  • Malicious files may be written outside the selected output directory.
  • Overwrite or creation of files in sensitive project directories (e.g., configuration, scripts, or build artifacts).
  • In developer environments, injected files could be picked up by tooling, package managers, or runtime loaders, potentially leading to code execution.
  • In CI/CD environments, modified build outputs or scripts may compromise the integrity of the delivery pipeline.
  • Malicious files may be written outside the selected output directory.
  • Overwrite or creation of files in sensitive project directories (e.g., configuration, scripts, or build artifacts).
  • In developer environments, injected files could be picked up by tooling, package managers, or runtime loaders, potentially leading to code execution.
  • In CI/CD environments, modified build outputs or scripts may compromise the integrity of the delivery pipeline.

General mitigation guidance

Effective mitigation focuses on strict path handling and reducing trust in bundle-controlled filenames:

  • Perform robust, multi-step path canonicalization and verify that the final resolved path is a descendant of the chosen output directory before writing any file.
  • Reject or rewrite any module filename containing traversal indicators (.., absolute path prefixes, drive letters, or unusual separator patterns) rather than attempting to partially sanitize them.
  • Use a whitelist approach for allowable path shapes (e.g., relative, no parent directory segments, no leading separators) and normalize separators consistently across platforms.
  • Run tooling like wakaru with the least necessary filesystem privileges and avoid executing or automatically loading newly unpacked content without review.
  • Separate unpack output into isolated working directories that are not relied upon for direct code execution or configuration loading.

Effective mitigation focuses on strict path handling and reducing trust in bundle-controlled filenames:

  • Perform robust, multi-step path canonicalization and verify that the final resolved path is a descendant of the chosen output directory before writing any file.
  • Reject or rewrite any module filename containing traversal indicators (.., absolute path prefixes, drive letters, or unusual separator patterns) rather than attempting to partially sanitize them.
  • Use a whitelist approach for allowable path shapes (e.g., relative, no parent directory segments, no leading separators) and normalize separators consistently across platforms.
  • Run tooling like wakaru with the least necessary filesystem privileges and avoid executing or automatically loading newly unpacked content without review.
  • Separate unpack output into isolated working directories that are not relied upon for direct code execution or configuration loading.

How teams detect issues like this

Organizations can detect and monitor similar path traversal issues using several approaches:

  • Static analysis and code scanning: Flag any file write operations that concatenate user- or bundle-controlled strings into paths without canonicalization and base-directory enforcement.
  • Code review patterns: Pay special attention to archive or bundle extraction logic, looking for assumptions that single-pass sanitization is sufficient to prevent traversal.
  • Security unit tests: Add tests that attempt to unpack bundles containing edge-case filenames (e.g., ....//, ..\\, mixed separators) and assert that outputs stay within the intended directory.
  • Runtime monitoring: Where feasible, monitor tooling environments for unexpected file creation or modification outside designated working directories during unpack operations.

Organizations can detect and monitor similar path traversal issues using several approaches:

  • Static analysis and code scanning: Flag any file write operations that concatenate user- or bundle-controlled strings into paths without canonicalization and base-directory enforcement.
  • Code review patterns: Pay special attention to archive or bundle extraction logic, looking for assumptions that single-pass sanitization is sufficient to prevent traversal.
  • Security unit tests: Add tests that attempt to unpack bundles containing edge-case filenames (e.g., ....//, ..\\, mixed separators) and assert that outputs stay within the intended directory.
  • Runtime monitoring: Where feasible, monitor tooling environments for unexpected file creation or modification outside designated working directories during unpack operations.

Sources

SourceLink
github.comgithub.com/pionxzh/wakaru/commit/1d30383b20a6f768786b8ada2f1b0945de13c316
github.comgithub.com/pionxzh/wakaru/releases/tag/v1.4.0
github.comgithub.com/pionxzh/wakaru/security/advisories/GHSA-7wpj-vvmv-pgm8

Frequently asked

questions

Not directly over the network. Exploitation requires a victim to run wakaru --unpack on a malicious bundle, typically on a local machine or CI agent, turning it into a local code-execution or file-write issue.

An attacker needs the ability to supply or influence the JavaScript bundle that is being unpacked—this might occur through compromised dependencies, shared artifacts, or untrusted third-party bundles.

The safest pattern is to treat all bundle-provided filenames as untrusted, normalize them to a canonical form, and enforce that the resolved path remains strictly within the intended output directory, rejecting or renaming any entries that violate this constraint.

Adopt defensive path-handling practices for all extract/unpack features, add automated tests for traversal edge cases, integrate static analysis focused on file path construction, and avoid automatically executing or loading content immediately after it is unpacked from untrusted sources.

Not directly over the network. Exploitation requires a victim to run wakaru --unpack on a malicious bundle, typically on a local machine or CI agent, turning it into a local code-execution or file-write issue.

An attacker needs the ability to supply or influence the JavaScript bundle that is being unpacked—this might occur through compromised dependencies, shared artifacts, or untrusted third-party bundles.

The safest pattern is to treat all bundle-provided filenames as untrusted, normalize them to a canonical form, and enforce that the resolved path remains strictly within the intended output directory, rejecting or renaming any entries that violate this constraint.

Adopt defensive path-handling practices for all extract/unpack features, add automated tests for traversal edge cases, integrate static analysis focused on file path construction, and avoid automatically executing or loading content immediately after it is unpacked from untrusted sources.

Find out what's already
exploitable in your codebase.