<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Drinkable Chicken &#187; security</title>
	<atom:link href="http://4.flowsnake.org/archives/tag/security/feed" rel="self" type="application/rss+xml" />
	<link>http://4.flowsnake.org</link>
	<description>A Pythoneer's adventures with Scheme, Clojure and a whole lot more. ^_^</description>
	<lastBuildDate>Sat, 10 Jul 2010 14:39:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Security</title>
		<link>http://4.flowsnake.org/archives/545</link>
		<comments>http://4.flowsnake.org/archives/545#comments</comments>
		<pubDate>Sun, 01 Mar 2009 12:30:46 +0000</pubDate>
		<dc:creator>Hans Nowak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://4.flowsnake.org/?p=545</guid>
		<description><![CDATA[This is great stuff: A Challenge To Break Python Security. The challenge is simple: Open a fresh Python interpreter and do: &#62;&#62;&#62; from safelite import FileReader You can use FileReader to read files on your filesystem Now find a way to write to the filesystem from your interpreter This has been discussed extensively for the [...]]]></description>
			<content:encoded><![CDATA[<p>This is great stuff: <a href="http://tav.espians.com/a-challenge-to-break-python-security.html">A Challenge To Break Python Security</a>.</p>
<blockquote><p>The challenge is simple:</p>
<ul>
<li> Open a fresh Python interpreter and do:
<pre class="doctest-block"><span class="doctest-input">&gt;&gt;&gt; from safelite import FileReader</span></pre>
</li>
<li>You can use <tt class="docutils literal"><span class="pre">FileReader</span></tt> to read files on your filesystem</li>
<li>Now find a way to <em>write</em> to the filesystem from your interpreter</li>
</ul>
</blockquote>
<p>This has been <a href="http://mail.python.org/pipermail/python-dev/2009-February/086401.html">discussed</a> extensively for the last few days on python-dev. It&#8217;s funny how code seems to be pretty secure at first glance, then someone comes up with another loophole.</p>
<p>It especially piqued my interest since I am working on yet another searchable card database, this time using Google App Engine. Kind of like <a href="http://ww2.wizards.com/gatherer/index.aspx?">Gatherer</a>, but for a different CCG than Magic, and (hopefully) more flexible. What does this have to do with security? Simple: the most flexible way to search cards is to store them as Python objects, then search them using a Python expression, e.g.</p>
<pre>card.red and card.black and (card.creature or card.instant) and card.cost &gt; 2</pre>
<p>&#8230;or, a more convoluted query:</p>
<pre>(card.red or card.black) and not card.multicolor \
and card.type == 'Dragon' and card.set.year &gt; 2006</pre>
<p>Now, executing an arbitary Python expression entered on a web page, is of course very unsafe. So I need to find ways to make it more secure, while still preserving the flexibility of a Python-based search. Although I&#8217;m not sure how much it matters in this particular case, because:</p>
<ul>
<li>According to the App Engine docs, <a href="http://code.google.com/appengine/docs/whatisgoogleappengine.html">an application cannot write to the system</a>, so no overwriting of files (?).</li>
</ul>
<ul>
<li>I&#8217;m not using the data store at all, and there is no user registration, so there&#8217;s no sensitive data to be accessed or manipulated.</li>
</ul>
<ul>
<li>Projects like <a href="http://www.trypython.org/">Try Python</a> and <a href="http://tryruby.hobix.com/">Try Ruby</a> seem to fare pretty well without imposing many restrictions on the user.</li>
</ul>
<p>That said, there might be other ways to mess with the site. Personally I don&#8217;t care if a user manages to screw up their own session due to malicious hackery, as long as it doesn&#8217;t affect other users. :-)</p>
<p>Anyway, the site isn&#8217;t ready yet, I still need to add more cards and flesh out the API. If you want to try it (locally), drop me a note, and I&#8217;ll send you the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://4.flowsnake.org/archives/545/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
