The vulnerability is a sandbox escape caused by a TOCTOU (Time-of-Check to Time-of-Use) bug in how property access is handled in @nyariv/sandboxjs. The analysis of the patch commit 67cb186c41c78c51464f70405504e8ef0a6e43c3 reveals the exact location of the vulnerability and the nature of the fix.
The root cause lies in the handler for property access, which is an anonymous function registered for LispType.Prop in src/executor.ts. Before the patch, this function did not immediately sanitize or fix the value of the property key. An attacker could provide an object with a malicious toString() method as the property key. This method would return a safe value when the sandbox performed its security checks (e.g., using hasOwnProperty) but would return a malicious value like __proto__ when the actual property access (object[key]) occurred. This allowed an attacker to bypass the sandbox's prototype pollution protections.
The patch addresses this by ensuring the property key is converted to a primitive string value at the very beginning of the handler function. This single, sanitized value is then used for all subsequent operations, including security checks and the final property access, thus closing the TOCTOU window. The vulnerable function is the anonymous callback itself, as it contained this flawed logic. During exploitation, this function's logic would be on the call stack when the malicious property access is triggered.