Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54635 > unrolled thread
| Started by | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| First post | 2013-09-23 09:20 -0400 |
| Last post | 2013-09-23 20:04 -0700 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: building an online judge to evaluate Python programs Ned Batchelder <ned@nedbatchelder.com> - 2013-09-23 09:20 -0400
Re: building an online judge to evaluate Python programs Larry Hudson <orgnut@yahoo.com> - 2013-09-23 20:04 -0700
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2013-09-23 09:20 -0400 |
| Subject | Re: building an online judge to evaluate Python programs |
| Message-ID | <mailman.265.1379942417.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
On 9/23/13 8:33 AM, Fábio Santos wrote: > > > On 20 Sep 2013 21:14, "Jabba Laci" <jabba.laci@gmail.com > <mailto:jabba.laci@gmail.com>> wrote: > > > > > That last seems to me to be the biggie. Several times in the past few > > > years, people in this mailing list have tried to build a safe sandbox. > > > And each one was a big failure, for a hacker of sufficient interest. > > > Some of them were spectacular failures. > > > > > > If you have to be safe from your user, Python may be the wrong > language > > > to give them. > > > > Well, the course is about Python and I want to test Python scripts... > > > > I've heard about "chroot jail" but I never used it. Wikipedia says: > > > > "A chroot on Unix operating systems is an operation that changes the > > apparent root directory for the current running process and its > > children. A program that is run in such a modified environment cannot > > name (and therefore normally not access) files outside the designated > > directory tree. The term "chroot" may refer to the chroot(2) system > > call or the chroot(8) wrapper program. The modified environment is > > called a "chroot jail"." > > > > I guess it could be used for sandboxing. > > > > Laszlo > > It may be a good start to whitelist the modules and builtins they are > allowed to use. > > The ast module could be used to scan the source tree for import > statements and run the imported modules through the whitelist. > > There should also be many ways to run a script with stripped-down > builtins. > > Then you can control execution time and memory usage using an external > tool. > > I'm quite sure this isn't all you need, but it can be a good place to > start. > > Python really is too dynamic for any static analysis like this to help in the long run. It will stop people from doing the obvious things, but there will always be a way to circumvent it. Take a look here: Eval really is dangerous: http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html If you want to run untrusted Python code and prevent malice (or stupidity) from harming you, you need OS-level protection. --Ned.
[toc] | [next] | [standalone]
| From | Larry Hudson <orgnut@yahoo.com> |
|---|---|
| Date | 2013-09-23 20:04 -0700 |
| Message-ID | <ZpmdnTPGoKbFnNzPnZ2dnUVZ_qCdnZ2d@giganews.com> |
| In reply to | #54635 |
On 09/23/2013 06:20 AM, Ned Batchelder wrote:
<snip>
> If you want to run untrusted Python code and prevent malice (or stupidity) from harming you, you
> need OS-level protection.
>
> --Ned.
>
That reminds me of the quote from Albert Einstein, (paraphrased):
"There are only two things that are infinite, the universe and human stupidity. And I'm not
sure about the universe."
-=- Larry -=-
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web