The vulnerability allowed a sandbox escape in vm2 by exploiting the module built-in. When the module built-in was allowed, it was possible to use Module._load() to load any other Node.js module, including child_process, which could then be used for remote code execution. The vulnerability was present in the addDefaultBuiltin function in lib/builtin.js, which did not properly restrict access to dangerous built-in modules. The patch addresses this by creating a denylist of dangerous modules and modifying addDefaultBuiltin to prevent them from being loaded, even when explicitly requested. The primary vulnerable function is addDefaultBuiltin as it was the function that directly allowed the dangerous module to be loaded into the sandbox.