The vulnerability, identified as GHSA-qcp4-v2jj-fjx8, is a sandbox escape in vm2. The root cause is the ability to leak a BaseHandler proxy handler instance from the sandbox environment, primarily through util.inspect({showProxy:true}). Once leaked, the trap methods on this handler (e.g., getPrototypeOf, get, set) could be called directly with a forged target argument. These traps lacked validation to ensure that the target they were operating on was the legitimate, intended target of the proxy.
An attacker could exploit this by providing an arbitrary host object as the target. The PoC demonstrates this by using handler.getPrototypeOf to walk the prototype chain of host objects, eventually gaining access to the host's Function constructor and achieving remote code execution.
The patch addresses this by introducing a validateHandlerTarget function. This function is called at the entry point of every proxy trap within BaseHandler and its subclasses (ProtectedHandler, ReadOnlyHandler, ReadOnlyMockHandler). It maintains a WeakMap to pair each handler with its legitimate target at creation time. Any subsequent trap invocation with a mismatched or unregistered target results in an error, effectively closing the vulnerability. All the patched trap methods were vulnerable to this same fundamental flaw.