v8 does have a sandbox feature for running untrusted scripts, and it's quite good. There's also Node's VM module.