Sandboxing [Was Re: killing thread ?]

Jack Diederich jack at performancedrivers.com
Fri Jan 24 19:13:11 CET 2003


On Fri, Jan 24, 2003 at 12:44:24PM -0500, Jp Calderone wrote:
> On Fri, Jan 24, 2003 at 07:52:08AM -0800, Paul Rubin wrote:
> > Peter Hansen <peter at engcorp.com> writes:
> > > If you're worried about some kind of denial of service type
> > > thing with code written by someone else: you're out of luck.
> > > Don't use Python.  (Or, better yet, get over the worry and just
> > > accept this possibility.)
> > 
> > Wha?  Python provides the rexec and bastion modules specifically to
> > have a way to run hostile code in a sandbox.  So what kind of advice
> > is "don't use Python"?  If sandboxed code can be prevented from
> > accessing sensitive data or doing i/o, but can't be prevented from
> > looping unkillably, that's a bug in Python.
> 
>   Yes, that's why Python provides them.  But this misconception (that they
> work) is also why it will soon -not- provide them :P  And neither RExec nor
> Bastion ever protected you against "while 1: pass" or "100L ** 100L ** 100L
> ** 100L ** 100L".  It is currently not possible to write a secure sandbox in
> Python.  I'm not sure if you can call that a bug; it's certainly
> unfortunate.
> 

As has been said elsewhere, the correct [read: only way to do it realiably
without rewriting the language] way to do this is by using OS features.
Disk quotas, CPU quotas, chroot filesystems, apache configurations.

If you've ever worked on an LPC MUD or thought about implementing one
you have to deal with giving 'untrusted' users code-level access to the system.
You want to give them access to the codebase and at the same time not give
them a way to hack or DOS the system.  If anyone feels like implmenting
a setup like this, I'd be a giddy beta tester.  It would be a
combination of setup scripts (add_sanbox_user.p[ly]) that would be language
agnostic plus some language specific RPC libraries.

LPC didn't do it correctly, but it was close enough because coders
were 'trusted,' they had something to lose by exploiting the system so the
restrictions were mainly to prevent them from doing major damage.  Minor
but reversible damage was still possible.

-jackdied





More information about the Python-list mailing list