Details
Observed NodeVM variant output:
NodeVM Promise.resolve thenable: returned 1
NodeVM Promise.resolve thenable events: nodevm-resolve-thenable
NodeVM direct then control: threw VMError:Async not available
NodeVM direct then control events: <none>
Impact
Applications commonly combine timeout with allowAsync: false so untrusted scripts run synchronously and cannot continue after run() returns. This issue breaks that security boundary. A sandboxed script can schedule a Promise thenable job, have VM.run() return successfully, and execute attacker-controlled code afterward. Because the code runs after VM.run() has returned, the configured timeout no longer interrupts it.
A malicious thenable can use this to block the host Node.js event loop after the host believes the sandbox run is finished. The proof above uses a bounded 35 ms loop for safety, but the same primitive can be made unbounded. The finding is therefore a sandbox policy and availability bypass. This report does not claim raw host-object exposure, process access, filesystem access, or host RCE.
Negative/control evidence: direct .then() is rejected with VMError: Async not available and no callback fires, confirming that the intended protection exists but is incomplete for static Promise thenable assimilation.
Suggested remediation
When allowAsync is false, reject or neutralize all Promise static-method paths that can schedule jobs, not only Promise.prototype.then. At minimum, Promise.resolve, Promise.all, Promise.race, Promise.any, and Promise.allSettled should not invoke attacker-controlled thenables under allowAsync: false. Possible fixes include replacing these static methods with AsyncErrorHandler-style throwers when async is disabled, or wrapping their inputs so thenable assimilation cannot schedule attacker code.
Add regression tests for VM and NodeVM that verify:
Promise.resolve({ then(){} })throws or does not call the thenable whenallowAsync: false.Promise.all,Promise.race,Promise.any, andPromise.allSettleddo the same for thenable elements.- Direct
.then()remains blocked. - A timeout-configured VM cannot execute code after
run()returns via Promise thenable assimilation.
Variant analysis summary
Confirmed variants:
VM({allowAsync:false}).run('Promise.resolve(thenable)')VM({allowAsync:false}).run('Promise.all([thenable])')VM({allowAsync:false}).run('Promise.race([thenable])')VM({allowAsync:false}).run('Promise.any([thenable])')VM({allowAsync:false}).run('Promise.allSettled([thenable])')NodeVM({allowAsync:false}).run('Promise.resolve(thenable)')
Negative cases checked:
- Direct
Promise.resolve(1).then(...)throwsVMError: Async not availablein bothVMandNodeVM. - NodeVM dangerous builtin exposure was reviewed separately and not implicated in this issue.
Credits
- Thai Son Dinh from VinSOC Labs (R&D)
- Nguyen Huy Vu Dung from VinSOC Labs (AppSec)