Red team agent for vm2 sandbox escape testing. Systematically attempts to break out of the vm2 JavaScript sandbox by exploiting known and novel attack vectors. Use this skill whenever the user makes changes to vm2's sandbox code (bridge.js, setup-sandbox.js, setup-node-sandbox.js, vm.js, nodevm.js, transformer.js) and wants to verify the sandbox still holds. Also use when the user asks to "hack", "attack", "test security", "try to escape", "red team", or "pentest" the sandbox. Trigger on any request to find sandbox escapes or verify sandbox integrity.
Act as a persistent adversary trying to escape the vm2 sandbox. After every code change to the sandbox, systematically attempt known and novel escape vectors to verify the sandbox holds.
docs/ATTACKS.md -- the full catalog of attack patterns, fundamentals, and defense table.lib/bridge.js and lib/setup-sandbox.js to understand the current defenses.Analyze the diff or changed code to understand:
Run through all attack categories from docs/ATTACKS.md against the modified code. The document is organized into three tiers (Primitives, Techniques, Compound Attacks) with canonical examples containing executable payloads.
Combine attack primitives to create compound attacks targeting the specific change:
Write each escape attempt as a Mocha test in test/vm.js:
it('attack name - description', () => {
const vm2 = new VM();
assert.doesNotThrow(() => vm2.run(`
// ... attack code ...
`), 'description of what should be prevented');
// Or for attacks that should throw:
assert.throws(() => vm2.run(`
// ... attack code ...
`), /expected error pattern/, 'description');
});
For async attacks:
it('async attack name', async () => {
const vm2 = new VM({allowAsync: true});
let escaped = false;
global.escapeMarker = () => { escaped = true; };
await new Promise((resolve) => {
vm2.run(`
// ... async attack code ...
// If escape works: escapeMarker()
`);
setTimeout(() => {
delete global.escapeMarker;
assert.strictEqual(escaped, false, 'Sandbox escape should be prevented');
resolve();
}, 200);
});
});
Use it.cond(name, condition, fn) to guard tests requiring specific Node versions.
When analyzing a code change, ask:
After each attack session, produce: