{"id":"CVE-2024-34347","aliases":["CVE-2024-34347","GHSA-qmmm-73r2-f8xr"],"related":[],"kind":"vulnerability","state":"published","title":"@hoppscotch/cli affected by Sandbox Escape in @hoppscotch/js-sandbox leads to RCE","summary":"@hoppscotch/cli is a CLI to run Hoppscotch Test Scripts in CI environments. Prior to 0.8.0, the @hoppscotch/js-sandbox package provides a Javascript sandbox that uses the Node.js vm module. However, the vm module is not safe for sandboxing untrusted Javascript code. This is because code inside the vm context can break out if it can get a hold of any reference to an object created outside of the vm. In the case of @hoppscotch/js-sandbox, multiple references to external objects are passed into the vm context to allow pre-request scripts interactions with environment variables and more. But this also allows the pre-request script to escape the sandbox. This vulnerability is fixed in 0.8.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"@hoppscotch/cli is a CLI to run Hoppscotch Test Scripts in CI environments. Prior to 0.8.0, the @hoppscotch/js-sandbox package provides a Javascript sandbox that uses the Node.js vm module. However, the vm module is not safe for sandboxing untrusted Javascript code. This is because code inside the vm context can break out if it can get a hold of any reference to an object created outside of the vm. In the case of @hoppscotch/js-sandbox, multiple references to external objects are passed into the vm context to allow pre-request scripts interactions with environment variables and more. But this also allows the pre-request script to escape the sandbox. This vulnerability is fixed in 0.8.0.","source":"cvelist"},{"lang":"en","text":"### Observations\n\nThe Hoppscotch desktop app takes multiple precautions to be secure against arbitrary JavaScript and system command execution. It does not render user-controlled HTML or Markdown, uses Tauri instead of Electron, and sandboxes pre-request scripts with a simple yet secure implementation using web workers.\n\nUnfortunately, web workers are not available in a pure Node.js application like Hoppscotch CLI. That is why the [@hoppscotch/js-sandbox](https://github.com/hoppscotch/hoppscotch/tree/main/packages/hoppscotch-js-sandbox) package also provides a Javascript sandbox that uses the Node.js `vm` module. However, the `vm` module is not safe for sandboxing untrusted Javascript code, as stated [in the documentation](https://nodejs.org/api/vm.html#vm-executing-javascript). This is because [code inside the vm context can break out](https://thegoodhacker.com/posts/the-unsecure-node-vm-module/) if it can get a hold of any reference to an object created outside of the vm.\n\nIn the case of @hoppscotch/js-sandbox, multiple references to external objects are passed into the vm context to allow pre-request scripts interactions with environment variables and more. But this also allows the pre-request script to escape the sandbox.\n[packages/hoppscotch-js-sandbox/src/pre-request/node-vm/index.ts](https://github.com/hoppscotch/hoppscotch/blob/faab1d20fde9a6be660db40fc73dcf28f9038008/packages/hoppscotch-js-sandbox/src/pre-request/node-vm/index.ts#L23-L31)\n```js\nconst { pw, updatedEnvs } = getPreRequestScriptMethods(envs)\n\n// Expose pw to the context\ncontext.pw = pw\ncontext.atob = atob\ncontext.btoa = btoa\n\n// Run the pre-request script in the provided context\nrunInContext(preRequestScript, context)\n```\n\n### Exploitation\n\nAn attacker can use the exposed `pw` object reference to escape the sandbox and execute arbitrary system commands using the `child_process` Node.js module. This PoC pre-request script executes the `id > /tmp/pwnd` system command as soon as a request is sent.\n```js\noutside = pw.constructor.constructor('return this')()\noutside.process.mainModule.require('child_process').execSync('id > /tmp/pwnd')\n```\nAn attacker who wants to run arbitrary code on the machine of a victim can create a Hoppscotch collection containing a request with a malicious pre-request script and share it with a victim, using the JSON export feature. The victim then has to run the collection with the Hoppscotch CLI. Then the malicious pre-request script executes.\n\n### Impact\n\nThis attack gives an attacker arbitrary command execution on the machine of a victim Hoppscotch CLI user. For the attack to succeed, an attacker has to lure the victim into downloading a malicious Hoppscotch collection and running it with the Hoppscotch CLI.\n\nThis issue does not impact Hoppscotch Web or Desktop, as they use the safe web worker sandboxing approach.\n\n### Recommendations\n\nHoppscotch CLI and other tools that rely on @hoppscotch/js-sandbox but don't have access to a browser cannot use the web worker sandbox. For these, you can look into other safe JavaScript sandboxing libraries. We think that [isolated-vm](https://github.com/laverdet/isolated-vm) looks promising. We discourage the use of [vm2](https://github.com/patriksimek/vm2), which is deprecated because it has arbitrary bypasses. Alternatively, you can introduce an `--enable-scripting` flag for the CLI and disable scripting by default. Or you can change the threat model and educate users that they should not run untrusted collections as it can lead to RCE.\n\n\n### Differences from existing CVEs\n- [nvd.nist.gov/vuln/detail/CVE-2023-37466](https://nvd.nist.gov/vuln/detail/CVE-2023-37466) : This CVE is regarding an escape of vm2 which we do not even use.","format":"markdown","source":"ghsa"},{"lang":"es","text":"@hoppscotch/cli es una CLI para ejecutar scripts de prueba de Hoppscotch en entornos de CI. Antes de 0.8.0, el paquete @hoppscotch/js-sandbox proporciona un entorno limitado de Javascript que utiliza el módulo vm de Node.js. Sin embargo, el módulo vm no es seguro para el código Javascript que no es de confianza. Esto se debe a que el código dentro del contexto de la máquina virtual puede romperse si puede obtener cualquier referencia a un objeto creado fuera de la máquina virtual. En el caso de @hoppscotch/js-sandbox, se pasan múltiples referencias a objetos externos al contexto de la máquina virtual para permitir interacciones de scripts de solicitud previa con variables de entorno y más. Pero esto también permite que el script de solicitud previa escape del entorno limitado. Esta vulnerabilidad se solucionó en 0.8.0.","source":"nvd"}],"published":"2024-04-22T18:38:11.000Z","modified":"2026-09-10T03:50:12.871Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","score":8.4,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","score":8.4,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","score":8.3,"rating":"HIGH"}],"cwes":["CWE-77"],"affected":[{"ranges":[{"version":">= 0.5.0, < 0.8.0","status":"affected"}],"vendor":"hoppscotch","product":"hoppscotch","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0.5.0","fixed":"0.8.0","status":"affected"}],"vendor":"hoppscotch","product":"hoppscotch","cpe":"cpe:2.3:a:hoppscotch:hoppscotch:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0.5.0","status":"affected","fixed":"0.8.0"}],"ecosystem":"npm","package":"@hoppscotch/cli","purl":"pkg:npm/%40hoppscotch/cli","source":"ghsa"}],"references":[{"url":"https://github.com/hoppscotch/hoppscotch/security/advisories/GHSA-qmmm-73r2-f8xr","tags":["web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/hoppscotch/hoppscotch/commit/22c6eabd133195d22874250a5ae40cb26b851b01","tags":["web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.sonarsource.com/blog/scripting-outside-the-box-api-client-security-risks-part-2","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-34347","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/hoppscotch/hoppscotch","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2024-05-08T17:33:34.499Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-34347","url":"https://www.cve.org/CVERecord?id=CVE-2024-34347","licence":"CVE Terms of Use","modified":"2025-06-10T15:33:47.072Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-qmmm-73r2-f8xr","url":"https://github.com/advisories/GHSA-qmmm-73r2-f8xr","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:12.871Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-34347","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-34347","licence":"Public domain","modified":"2026-06-17T07:33:13.343Z"}],"updatedAt":"2026-11-25T22:58:40.090Z","epss":{"score":0.00611,"percentile":0.50606,"date":"2026-12-01T12:00:22.000Z"}}