Doing this all in a webworker might be one way to get security - by sandboxing the with/eval?
It seems like that would be somewhat XSS safe since you are just passing strings back and forth.
I really like this idea.
evalSafeAsync(code,context,callback)
That being said, for a spreadsheet, you need to bite the bullet and parse the formulas. I don't see an easy way to support SUM(A1:A4) using this eval hack.