The vulnerability is a sandbox escape in SandboxJS caused by the failure to sandbox the AsyncFunction constructor. The root cause lies in the createExecContext function in src/utils.ts. This function is responsible for setting up the sandboxed environment, including a map of native functions to their safe, sandboxed replacements.
The analysis of the patch 345aee6566e47979dee5c337b925b141e7f78ccd reveals that createExecContext was modified to add a mapping for AsyncFunction. Before this patch, the function only sandboxed the Function constructor, but not AsyncFunction, GeneratorFunction, or AsyncGeneratorFunction.
When code inside the sandbox accessed the .constructor property of an async function (e.g., (async () => {}).constructor), the executor would not find a sandboxed replacement in the map created by createExecContext. Consequently, it would return the original, powerful AsyncFunction constructor from the host environment. An attacker could then use this constructor to create and execute a new function outside of the sandbox's restrictions, achieving remote code execution.
Therefore, createExecContext is identified as the vulnerable function because its incomplete setup of the sandbox environment is the direct cause of the vulnerability.