Re: minimum install & pickling



On 17 Sep, 22:18, "Aaron \"Castironpi\" Brady" <castiro...@xxxxxxxxx>
wrote:
On Sep 17, 4:43 am, Paul Boddie <p...@xxxxxxxxxxxxx> wrote:

http://wiki.python.org/moin/How_can_I_run_an_untrusted_Python_script_...)

These solutions have at least the same bugs that the bare bones
solution in the corresponding framework has.  Malicious code has fewer
options, but constructive code does too.  If you're running foreign
code, what do you want it to do?  What does it want to do?  The more
options it needs, the more code you have to trust.

As I noted, instead of just forbidding access to external resources,
what you'd want to do is to control access instead. This idea is not
exactly new: although Brett Cannon was working on a sandbox capability
for CPython, the underlying concepts involving different privilege
domains have been around since Safe-Tcl, if not longer. The advantage
of using various operating system features, potentially together with
tools like fakechroot or, I believe, Plash, is that they should work
for non-Python programs. Certainly, the chances of successfully
introducing people to such capabilities are increased if you don't
have to persuade the CPython core developers to incorporate your
changes into their code.

The only way a Python script can return a value is with sys.exit, and
only an integer at that.  It is going to have output; maybe there's a
way to place a maximum limit on its consumption.  It's going to have
input, so that the output is relative to something.  You just make
copies to prevent it from destroying data.  Maybe command-line
parameters are enough.  IIRC if I recall correctly, Win32 has a way to
examine how much time a process has owned so far, and a way to
terminate it, which could be in Python's future.

There is support for imposing limits on processes in the Python
standard library:

http://docs.python.org/lib/node521.html

My experimental package, jailtools, relies on each process's sandbox
being set up explicitly before the process is run, so you'd definitely
want to copy data into the sandbox. Setting limits on the amount of
data produced would probably require support from the operating
system. Generally, when looking into these kinds of systems, most of
the solutions ultimately come from the operating system: process
control, resource utilisation, access control, and so on. (This is the
amusing thing about Java: that Sun attempted to reproduce lots of
things that a decent operating system would provide *and* insist on
their use when deploying Java code in a controlled server environment,
despite actually having a decent operating system to offer already.)

PyPy sandbox says:  "The C code generated by PyPy is not
segfaultable."  I find that to be a bold claim (whether it's true or
not).

I'm imagining in the general case, you want the foreign code to make
changes to objects in your particular context, such as exec x in
vars.  In that case, x can still be productive without any libraries,
just less productive.

Defining an interface between trusted and untrusted code can be
awkward. When I looked into this kind of thing for my undergraduate
project, I ended up using something similar to CORBA, and my
conclusion was that trusted code would need to expose an interface
that untrusted "agents" would rely on to request operations outside
the sandbox. That seems restrictive, but as the situation with rexec
has shown, if you expose a broad interface to untrusted programs, it
becomes increasingly difficult to verify whether or not the solution
is actually secure.

Paul
.



Relevant Pages

  • Re: Computer
    ... All the Unix commands are there. ... I don't care about the base operating system. ... I like the Mac interface better than the Windows ... businesses using old DOS programs in a DOS box, ...
    (rec.photo.digital)
  • Re: Selecting embedded Linux for a new medical device project (LONG)
    ... approvals and clinical trials. ... which is indispensable during clinical trials. ... Why do we use an operating system at all and a RTOS in particular? ... Display drivers, control input ...
    (comp.os.linux.embedded)
  • Re: Secret Source code ...
    ... And that's an application, not a control. ... > of a PDP-10 operating system whose acronym I've forgotten, ... > certain the 7090 operating system developed by the IBM User Group called ... > you don't buy the rights to their source code. ...
    (microsoft.public.vc.mfc)
  • Re: User interfaces are applications. (was Re: MSs Vista majorly embarrassed in Public!
    ... The low-level software which handles the interface to peripheral hardware, ... firmware required at boot time or when installing the operating system would ... operating systems includeMS-DOS, Unix, OS/2, Macintosh, and Windows. ... and supplying a user interface. ...
    (comp.sys.mac.advocacy)
  • Re: Secret Source code ...
    ... >codeproject and google, ... And that's an application, not a control. ... >> certain the 7090 operating system developed by the IBM User Group called ... >> you don't buy the rights to their source code. ...
    (microsoft.public.vc.mfc)