Understand the Sandbox Escape Progression
mainMost sandbox escape attacks follow a specific chain of escalation. To defend against these, security implementations must block at least one step in the following progression:
- Access Sandbox Object
- Access Host Constructor (Function)
- Execute Code Evaluation (e.g.,
return process) - Access Host Modules (e.g.,
process.mainModule.require) - Require Host Built-ins (e.g.,
require("child_process")) - Execute Arbitrary Commands (e.g.,
execSync("arbitrary command"))
vm2 uses a bridge to block constructor access and a transformer to block catch-clause access to prevent this chain from completing.