<?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>Mike&#039;s Blabberings &#187; web security</title>
	<atom:link href="http://www.mike-griffith.com/blog/tag/web-security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mike-griffith.com/blog</link>
	<description>on software, testing, and the web.</description>
	<lastBuildDate>Mon, 14 Feb 2011 10:51:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CWE/SANS 25 Most Dangerous Programming Mistakes</title>
		<link>http://www.mike-griffith.com/blog/2009/01/cwesans-25-most-dangerous-programming-mistakes/</link>
		<comments>http://www.mike-griffith.com/blog/2009/01/cwesans-25-most-dangerous-programming-mistakes/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 15:55:05 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[software development]]></category>
		<category><![CDATA[web security]]></category>

		<guid isPermaLink="false">http://www.mike-griffith.com/blog/?p=179</guid>
		<description><![CDATA[A new list of the most dangerous programming mistakes was released today by SANS Institute.  This is a great followup to the OWASP Top 10.  The list of potential application security flaws is broken up into three sections, one for dealing with each of application component interaction, resource management, and weak defenses.

CATEGORY: Insecure [...]]]></description>
			<content:encoded><![CDATA[<p>A new <a href="http://www.sans.org/top25errors/?cat=top25">list of the most dangerous programming mistakes</a> was released today by SANS Institute.  This is a great followup to the <a href="http://www.owasp.org/index.php/OWASP_Top_Ten_Project">OWASP Top 10</a>.  The list of potential application security flaws is broken up into three sections, one for dealing with each of application component interaction, resource management, and weak defenses.</p>
<blockquote><p>
<strong>CATEGORY: Insecure Interaction Between Components</strong><br />
CWE-20: Improper Input Validation<br />
CWE-116: Improper Encoding or Escaping of Output<br />
CWE-89: Failure to Preserve SQL Query Structure (aka &#8216;SQL Injection&#8217;)<br />
CWE-79: Failure to Preserve Web Page Structure (aka &#8216;Cross-site Scripting&#8217;)<br />
CWE-78: Failure to Preserve OS Command Structure (aka &#8216;OS Command Injection&#8217;)<br />
CWE-319: Cleartext Transmission of Sensitive Information<br />
CWE-352: Cross-Site Request Forgery (CSRF)<br />
CWE-362: Race Condition<br />
CWE-209: Error Message Information Leak</p>
<p><strong>CATEGORY: Risky Resource Management</strong><br />
CWE-119: Failure to Constrain Operations within the Bounds of a Memory Buffer<br />
CWE-642: External Control of Critical State Data<br />
CWE-73: External Control of File Name or Path<br />
CWE-426: Untrusted Search Path<br />
CWE-94: Failure to Control Generation of Code (aka &#8216;Code Injection&#8217;)<br />
CWE-494: Download of Code Without Integrity Check<br />
CWE-404: Improper Resource Shutdown or Release<br />
CWE-665: Improper Initialization<br />
CWE-682: Incorrect Calculation</p>
<p><strong>CATEGORY: Porous Defenses</strong><br />
CWE-285: Improper Access Control (Authorization)<br />
CWE-327: Use of a Broken or Risky Cryptographic Algorithm<br />
CWE-259: Hard-Coded Password<br />
CWE-732: Insecure Permission Assignment for Critical Resource<br />
CWE-330: Use of Insufficiently Random Values<br />
CWE-250: Execution with Unnecessary Privileges<br />
CWE-602: Client-Side Enforcement of Server-Side Security
</p></blockquote>
<p>Most of these are also listed on the OWASP Top 10, last updated in 2007 and summarized below.  Some come under different names, and I tend to prefer the more generic terms described in the new list of 25.</p>
<blockquote><p>
A1 &#8211; Cross Site Scripting (XSS)<br />
A2 &#8211; Injection Flaws<br />
A3 &#8211; Malicious File Execution<br />
A4 &#8211; Insecure Direct Object Reference<br />
A5 &#8211; Cross Site Request Forgery (CSRF)<br />
A6 &#8211; Information Leakage and Improper Error Handling<br />
A7 &#8211; Broken Authentication and Session Management<br />
A8 &#8211; Insecure Cryptographic Storage<br />
A9 &#8211; Insecure Communications<br />
A10 &#8211; Failure to Restrict URL Access
</p></blockquote>
<p>It&#8217;s our responsibility as software developers to be aware of these and ensure our architectures and modules do not expose any of these well-defined and documented vulnerabilities.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mike-griffith.com/blog/2009/01/cwesans-25-most-dangerous-programming-mistakes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tamper-proof python dictionary</title>
		<link>http://www.mike-griffith.com/blog/2008/09/tamper-proof-python-dictionary/</link>
		<comments>http://www.mike-griffith.com/blog/2008/09/tamper-proof-python-dictionary/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 19:23:43 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[software development]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web security]]></category>

		<guid isPermaLink="false">http://blog.rideshootlive.com/?p=83</guid>
		<description><![CDATA[Sometimes the need arises to pass a python list, tuple, dictionary, etc. from one page to another.  If you do not have a session service to hold it, the object may need to pass through a HTTP request (in cookie or get/post param), opening the possibility of tampering.  Without some precautions, a serious [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes the need arises to pass a python list, tuple, dictionary, etc. from one page to another.  If you do not have a session service to hold it, the object may need to pass through a HTTP request (in cookie or get/post param), opening the possibility of tampering.  Without some precautions, a serious vulnerability could be exposed.  Googling for “dictionary to string” yields some example implementations, most of which are still vulnerable to attack.  I think we can do better.</p>
<p><strong>Option 1: encode=string-ify, decode=eval</strong><br />
The idea here is take a dict and turn it into a string.  Then running eval would give you back the original dictionary.  If the world were full of with people who danced in flower-filled meadows, this would be ok. The problem is that if you need to pass “s” through an HTTP request, it can be altered into something, like perhaps “os.rmdir(’/&#8217;)”</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">d=<span style="color: black;">&#123;</span><span style="color: #483d8b;">'var1'</span>:<span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'var2'</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span>
s=<span style="color: #483d8b;">&quot;{'var1':1, 'var2':2}&quot;</span>
new_d = <span style="color: #008000;">eval</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span></pre></div></div>

<p>Result: <strong>VULNERABLE</strong> to arbitrary code execution.</p>
<p><strong>Option 2: encode=string-ify, decode=slightly-safter eval</strong><br />
The eval method in python does allow you to tighten it up a bit.  There are several <a href="http://www.google.com/search?q=python+safe+eval&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a" target="_blank">articles</a> detailing how to make it slightly safer, by only allowing a certain subset of methods to be available.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">new_d = <span style="color: #008000;">eval</span><span style="color: black;">&#40;</span>s, <span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;__builtins__&quot;</span>:<span style="color: #008000;">None</span><span style="color: black;">&#125;</span>, <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Result: <strong>VULNERABLE</strong> to arbitrary code execution.</p>
<p><strong>Option 3: encode=pickle, decode=unpickle</strong><br />
So what if instead of just eval’ing, we used the pickle module to serialize and then deserialize the dictionary?  That <em>feels</em> safer at first glance.  But what if the object to be deserialized was no longer a dictionary?  Perhaps an attacker pickled their own evil object, whose constructor or maybe get() method was modified to do wreak havoc.<br />
Result: <strong>VULNERABLE</strong> to arbitrary code execution.</p>
<p><strong>Option 4: encode=jsonify, decode=un-jsonify</strong><br />
One technique that didn’t appear in the results was using simplejson to encode and decode.  (Thanks Mike Pirnat for suggesting the now-obvious).  The simplejson decoder is a much safer one, because it scans the input to make sure it really does look like a dictionary (with all keys and values being safe types) before turning it into a python dict.<br />
User’s can still tamper with the keys and values, but it is no more susceptible than other types of parameter manipulation rampant on the web, so validation still need be there.<br />
Result: much better</p>
<p><strong>Option 5: encode=jsonify(jsonify+hash), decode=un-jsonify plus hash check</strong><br />
To an extra level of comfort, let’s try to make sure that the dictionary wasn’t tampered with.  We can take a hash of what we just json-ified, pack it with the data, and json-ify that result.  Then when we unpack it, we can double-check that the hash that came with the data still matches a new calculation of the hash of the data.  Assuming we have a strong, protected key for our hash algorithm, if the user tried to tamper with the data, they wouldn’t be able to replicate the corresponding change in the hash value, allowing us to raise an exception.<br />
Result: best yet</p>
<p>There ye have it, a safer way of turning a dictionary into a string suitable for passing around the website.  Just make sure your hash function is strong and your key is protected.</p>
<p>You can <a href="/code/encode_dict.py">download encode_dict.py</a> to see the final result.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mike-griffith.com/blog/2008/09/tamper-proof-python-dictionary/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On my mind today</title>
		<link>http://www.mike-griffith.com/blog/2008/09/on-my-mind-today/</link>
		<comments>http://www.mike-griffith.com/blog/2008/09/on-my-mind-today/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 17:36:26 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[software development]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[unit testing]]></category>
		<category><![CDATA[web security]]></category>

		<guid isPermaLink="false">http://blog.rideshootlive.com/?p=68</guid>
		<description><![CDATA[I&#8217;ve got some ideas that I need to find time to work on.  In no particular order:

Port MockMe to the Dojo javascript framework
Utilize browser history sniffing to build a generalized user segmentation framework
Write a Ubiquity plugin for spreeder (to easily speed read a page in Firefox)
Port OWASP&#8217;s AntiSamy project to Python, to provide comprehensive [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got some ideas that I need to find time to work on.  In no particular order:</p>
<ul>
<li>Port <a href="http://johanneslink.net/projects/mockme.html">MockMe</a> to the Dojo javascript framework</li>
<li>Utilize <a href="http://www.niallkennedy.com/blog/2008/02/browser-history-sniff.html">browser history sniffing</a> to build a generalized user segmentation framework</li>
<li>Write a <a href="http://labs.mozilla.com/projects/ubiquity/">Ubiquity</a> plugin for <a href="http://www.spreeder.com/">spreeder</a> (to easily speed read a page in Firefox)</li>
<li>Port <a href="http://code.google.com/p/owaspantisamy/">OWASP&#8217;s AntiSamy project</a> to Python, to provide comprehensive XSS protection</li>
</ul>
<p>None of these are terribly difficult to get started, and with the summer winding down, I might have a few minutes of free time to start working on some.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mike-griffith.com/blog/2008/09/on-my-mind-today/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

