2

I would like to add a feature to my site that gives users the ability to create custom JavaScript functions that would run on a Node.js server. Users would upload the JS function and I would eval to code and use it's return value somehow on the server. However, this is an obvious security hole. Is there someway in JavaScript/ Node.js to only allow a function to have scope to only parameters given to it? I don't want it to have access to variables else where in the server.

Thanks in advance.

1
  • eval is a great security risk on the browser itself, how much more on the server? Commented Mar 30, 2012 at 0:50

1 Answer 1

5

Have a look at:

vm.runInNewContext(code, [sandbox], [filename])

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, this opens up a world of possibilities.
@Eddie: Any possibility that you could accept his answer if it worked for you?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.