views:

93

answers:

3

I'm speaking specifically of something like the PLT Scheme make-evaluator.

It will run scheme code, but under certain conditions:

  • It only uses a definable amount of memory, and will quit execution if the script needs more
  • It behaves similarly with time
  • It restricts all IO except for what I specifically allow in the code

Is anyone familiar with anything else that can do this?

A: 

PHP allows something similar with eval - though you would need to set some restrictive values with ini_set before calling it, and they would affect the current script as well.

George Edison
+1  A: 

Lua lets you easily define sandboxes with as much or as little power you want.

Javier
This looks much less powerful than the PLT sandbox -- specifically, without restricting runtime and memory the whole thing is ultimately not really safe in the sense that would let you run random user code on your own server. Another problem is the need to control IO by restricting the names in the sandboxed environment -- the plt sandbox restricts IO regardless of names (which makes it possible to allow certain paths in). Also, cummunicating with the sandbox via setting values doesn't seem too attractive...
Eli Barzilay
there are hooks in the C api that can be used to restrict time and/or memory, the mailing list archive might be a better place to search. replacing the standard IO with one that checks your policy rules is less than 200 lines of Lua. As many things in Lua, you have to roll your own, but it's very easy to do. If you need a fully prebuilt system, Lua is not for you.
Javier
I doubt that there are hooks that can be used to restrict the memory of a sandboxed environment in an otherwise unrestricted environment -- that's *much* more involved than a few hooks. Same goes for standard IO -- what about a sandbox that can do *full* IO to one directory, read-only from another, and network to a single IP?
Eli Barzilay
A: 

The Java platform provides fine-grained access control and sandboxing. This isn't exactly equivalent to make-evaluator but the API allows you to place constraints on arbitrary objects (through the GuardedObject class). You can also restrict permissions of classes loaded from a particular source.

It might be helpful to read the Java Platform Security Architecture spec

Please note that Java APIs can be accessed from most languages on the jvm.

Felix Lange