<p dir="ltr"><br>
On 20 Sep 2013 21:14, "Jabba Laci" <<a href="mailto:jabba.laci@gmail.com">jabba.laci@gmail.com</a>> wrote:<br>
><br>
> > That last seems to me to be the biggie.  Several times in the past few<br>
> > years, people in this mailing list have tried to build a safe sandbox.<br>
> > And each one was a big failure, for a hacker of sufficient interest.<br>
> > Some of them were spectacular failures.<br>
> ><br>
> > If you have to be safe from your user, Python may be the wrong language<br>
> > to give them.<br>
><br>
> Well, the course is about Python and I want to test Python scripts...<br>
><br>
> I've heard about "chroot jail" but I never used it. Wikipedia says:<br>
><br>
> "A chroot on Unix operating systems is an operation that changes the<br>
> apparent root directory for the current running process and its<br>
> children. A program that is run in such a modified environment cannot<br>
> name (and therefore normally not access) files outside the designated<br>
> directory tree. The term "chroot" may refer to the chroot(2) system<br>
> call or the chroot(8) wrapper program. The modified environment is<br>
> called a "chroot jail"."<br>
><br>
> I guess it could be used for sandboxing.<br>
><br>
> Laszlo</p>
<p dir="ltr">It may be a good start to whitelist the modules and builtins they are allowed to use.</p>
<p dir="ltr">The ast module could be used to scan the source tree for import statements and run the imported modules through the whitelist.</p>
<p dir="ltr">There should also be many ways to run a script with stripped-down builtins.</p>
<p dir="ltr">Then you can control execution time and memory usage using an external tool.</p>
<p dir="ltr">I'm quite sure this isn't all you need, but it can be a good place to start.</p>