Description
This affects the package vm2 before 3.6.11. It is possible to trigger a RangeError exception from the host rather than the "sandboxed" context by reaching the stack call limit with an infinite recursion. The returned object is then used to reference the mainModule property of the host code running the script allowing it to spawn a child_process and execute arbitrary code.
Remediation
References
https://github.com/patriksimek/vm2/commit/4b22d704e4794af63a5a2d633385fd20948f6f90
https://github.com/patriksimek/vm2/issues/197
https://snyk.io/vuln/SNYK-JS-VM2-473188
Related Vulnerabilities
CVE-2019-10745 Vulnerability in npm package assign-deep
CVE-2020-6422 Vulnerability in maven package org.webjars.npm:electron
CVE-2021-23463 Vulnerability in maven package com.h2database:h2
CVE-2020-6460 Vulnerability in maven package org.webjars.npm:electron
CVE-2022-43401 Vulnerability in maven package org.jenkins-ci.plugins:script-security