<?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>eDesign.nl &#187; Security</title>
	<atom:link href="http://www.edesign.nl/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.edesign.nl</link>
	<description>Thoughts and concepts on software development</description>
	<lastBuildDate>Wed, 22 May 2013 17:08:34 +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>Avoid becoming a spam source</title>
		<link>http://www.edesign.nl/2010/08/21/avoid-becoming-a-spam-source/</link>
		<comments>http://www.edesign.nl/2010/08/21/avoid-becoming-a-spam-source/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 22:03:17 +0000</pubDate>
		<dc:creator>Jurgen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Spam protection]]></category>

		<guid isPermaLink="false">http://www.edesign.nl/?p=818</guid>
		<description><![CDATA[The number one rule in programming is not to trust external data, especially not user data. One of the reasons not to trust user data is the threat of hackers searching for injection possibilities. When you start develloping web applications you&#8217;ll soon learn the dangers of SQL injection. This might be the most important form [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.edesign.nl/wp-content/uploads/2010/08/spam.jpg"><img class="alignleft size-thumbnail wp-image-819" title="SPAM" src="http://www.edesign.nl/wp-content/uploads/2010/08/spam-150x150.jpg" alt="" width="150" height="150" /></a>The number one rule in programming is not to trust external data, especially not user data. One of the reasons not to trust user data is the threat of hackers searching for injection possibilities. When you start develloping web applications you&#8217;ll soon learn the dangers of SQL injection. This might be the most important form of injection, but by far it is not the only one out there: cross site scripting is another good example. If your application sends out mail, you might want to make sure you sanitize user input as well as the application could be a magnet for spammers who&#8217;ll send spam mail using your IP.<span id="more-818"></span></p>
<p>Mail is formatted using <a href="http://en.wikipedia.org/wiki/MIME" target="_blank">MIME</a>, a content discription format. In this format, all properties of an email are specified in the header of the message. Examples include &#8216;From:&#8217;, &#8216;Subject:&#8217; and &#8216;Date:&#8217; for instance and also &#8216;To:&#8217; and &#8216;Cc:&#8217; are headers in the MIME.</p>
<p>Mail is generally sent using SMTP. In contrast to MIME, the message format description, SMTP is a protocol. One can tell a mail server (SMTP) the recipients of an email using this protocol. Therefor these recipients set with SMTP can be different than the ones specified in the MIME message (ever noticed a header like &#8216;undisclosed recipients&#8217;, which is clearly not a valid email address).</p>
<p>Because it is redundant at a high programming level, like PHP, to set recipients twice (once in MIME and once in SMTP), methods are defined for sending mail. PHP&#8217;s mail() function for example accepts &#8216;to&#8217;, &#8217;subject&#8217; and &#8216;message&#8217; parameters. Also, since the number of different MIME headers are virtually infinite, it also accepts an &#8216;additional headers&#8217; parameter. This is one part of introducing a potential security breach.</p>
<div style="float: right; width: 300px; border: 1px solid #CCCCCC; padding: 3px; font-family: calibri; line-height: 20px; font-size: 12px;">This actually is a disputable &#8216;violation&#8217; of the headers. As you might have noticed, this way you&#8217;ll have to add Bcc recipients to the message&#8217;s header. As by definition, you don&#8217;t want other recipients to be able to see Bcc recipients as part of the message they recieve so the smtp client will have to strip it before sending.</div>
<p>The other part is in the function&#8217;s handling of the additional headers parameter. Of course it has to be possible to send mail using recipients specified as Cc or Bcc instead of To. To this end mail() examines the parameter for these headers and extracts them. As headers are specified per line in the MIME format, you can inject headers to the &#8216;additional headers&#8217; parameter if one has access to a field in it, let&#8217;s say &#8216;Date:&#8217; or &#8216;From:&#8217;. Headers are separated using a line feed character (LF), \n in PHP or %0A url encoded.</p>
<p>A MIME email usually has the following layout:</p>
<pre>To: you@yourdomain.com
From: me@mydomain.com
Subject: Hi there

I'm just mailing to say hello!</pre>
<p>Now if you have your website visitors send you mail and have them set the &#8216;From:&#8217; header contents for instance, they might fill out an arbitrary email address and add &#8216;%0ABcc: extra@email.com; extra2@email.com;&#8230; (etc)&#8217;. Now also an Bcc header is set and your mail form just became a spam robot. Workaround is simple: don&#8217;t allow newlines in MIME header fields! Another post about this common pittfall can be found on <a href="http://www.websiterepairs.net/smtpinjection.php" target="_blank">websiterepairs.net</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edesign.nl/2010/08/21/avoid-becoming-a-spam-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No robots beyond this line</title>
		<link>http://www.edesign.nl/2010/04/23/no-robots-beyond-this-line/</link>
		<comments>http://www.edesign.nl/2010/04/23/no-robots-beyond-this-line/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 17:43:30 +0000</pubDate>
		<dc:creator>Jurgen</dc:creator>
				<category><![CDATA[Spam protection]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://www.edesign.nl/?p=729</guid>
		<description><![CDATA[Online communities are hot. Globally recognized examples are easy to give: websites like Facebook, LinkedIn and are very popular, manufacturers have online fora to have their customers support each other, newspapers let you leave comments on their articles on their websites and you can share everything with tools like Delicious, Digg and Reddit. This development [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-751" href="http://www.edesign.nl/2010/04/23/no-robots-beyond-this-line/customs/"><img class="alignleft size-thumbnail wp-image-751" title="Customs passport check" src="http://www.edesign.nl/wp-content/uploads/2010/04/customs-150x150.jpg" alt="Customs passport check" width="150" height="150" /></a>Online communities are hot. Globally recognized examples are easy to give: websites like <a href="http://www.facebook.com/" target="_blank">Facebook</a>, <a href="http://www.linkedin.com/" target="_blank">LinkedIn</a> and are very popular, manufacturers have <a href="http://vip.asus.com/forum/default.aspx?SLanguage=en-us" target="_blank">online fora</a> to have their customers support each other, newspapers let you leave <a href="http://community.nytimes.com/comments/bits.blogs.nytimes.com/2010/04/06/yelp-makes-changes-to-appease-small-business-owners/?sort=newest&amp;scp=1&amp;sq=captcha&amp;st=cse#postComment" target="_blank">comments</a> on their articles on their websites and you can share everything with tools like <a href="http://delicious.com/" target="_blank">Delicious</a>, <a href="http://digg.com/" target="_blank">Digg</a> and <a href="http://www.reddit.com/" target="_blank">Reddit</a>. This development on the Internet supports new possibilities which were unknown before. Of course this also counts for rogues. <a href="http://en.wikipedia.org/wiki/Spam_%28electronic%29" target="_blank">Spam</a> is a commonly known phenomenon and global annoyance. Beside spamming unwanted messages by mail, spamming the comment boxes and fora is an issue web programmers have to deal with too. Spamming often is automated and this is a feature which can be used to counter spam. The goal is to identify a messenger being human or robot.</p>
<p>For this purpose the <a href="http://en.wikipedia.org/wiki/CAPTCHA" target="_blank">captcha</a> was invented. Besides the fact that captcha sounds nice enough to be a buzz word it actually is short for Completely Automated Public Turing test to tell Computers and Humans Apart, although this is a bit contrived. This means that a captcha is a challenge response mechanism but it doesn&#8217;t need to be in the form of an image depicting distorted text which has to be copied in a text box which is the most common form of captchas. Creative new captchas can be found, like a transistor image which has to be read.<span id="more-729"></span></p>
<h3>Technology</h3>
<p>Wikipedia mentions a couple of features a captcha must have to qualify as one. A captcha is a <a href="http://www.edesign.nl/2009/05/05/challenge-hash/" target="_self">challenge-response</a> test between a system and a user of which</p>
<ol>
<li>current software is unable to solve accurately,</li>
<li>most humans can solve, and</li>
<li>does not rely on the type of CAPTCHA being new to the attacker.</li>
</ol>
<p>The first one remarks a captcha as temporal. This means that with increasing processing power and increasing insight in artificial intelligence challenges we now consider to be captchas might not be in the (near) future. Philosophically, this means that captchas are a temporary phenomenon because mankind will eventually be able to build robots which are at least as intelligent as humans are. But for now they&#8217;ll do.</p>
<p>The second one emphasises the differences we see between humans and robots. This is actually quite an interesting point because mankind actually admits its current limitations in its own intelligence being unable to write software which is able to solve &#8216;puzzles&#8217; which are easy to solve for humans.</p>
<p>Which bridges to the last bullet on the list. Of course you could just add a simple checkbox labeled &#8220;Do not check this box if you are human&#8221;. No attacker would think of a spam protection this weak but because of that it might just work. The robot stumbling across your comment submission form does not expect such a protection and therefor cannot bypass it. Although this does not qualify as a captcha because the novelty of the protection will only make the attacker look into it to solve it in an instance. Of course a captcha can be a captcha when it is an innovative challenge but it should not rely on being unknown. <a href="http://en.wikipedia.org/wiki/Security_through_obscurity" target="_blank">Security through obscurity</a> is not security at all.</p>
<h3>Processing power and algorithms</h3>
<p>As time passes by technology advances resulting in more processing power in both processor quantity and quality and more mathematical developments. These are the engine propelling artificial intelligence development. On the other hand, having this field of computer science developing the struggle for making captchas to tell humans and computers apart becomes harder and harder. Who knows when software becomes as advanced as to be able to not only solve puzzles or identify puzzle types but to be really intelligent and thereby be able to find ways to solve a puzzle without knowing the puzzle&#8217;s rules in advance? 20 years? 30? 5?!</p>
<h3>Usefulness</h3>
<p>Captcha&#8217;s can be useful too. The <a href="http://recaptcha.net/" target="_blank">Recaptcha</a> program for instance helps digitizing books by showing snippets scanned from books which they are unable to parse with their <a href="http://en.wikipedia.org/wiki/Optical_character_recognition" target="_blank">OCR software</a>. This way the snippets are &#8216;decyphered&#8217; by hundreds of people insuring accuracy and helping the system in which it is implemented to be bot-free.</p>
<p>Other examples of captchas might be usefull to the website&#8217;s theme such as a math class forum&#8217;s captcha challenging users with simple math like <img src="http://www.edesign.nl/wp-content/cache/tex_f8f58d4d35433e1e2eaf7438fd68073d.png" align="absmiddle" class="tex" alt="3 + 5 =" /> or <img src="http://www.edesign.nl/wp-content/cache/tex_8dae6646d5937556b6a8bcc3c53f935c.png" align="absmiddle" class="tex" alt="4 * 3 =" />. Another example of such a situated captcha is Adafruit&#8217;s. <a href="http://www.adafruit.com/blog/" target="_blank">Adafruit</a> is a website and webshop on the <a href="http://www.arduino.cc/" target="_blank">Arduino</a>, which is a do it yourself programmable breadboard. You&#8217;ll need to &#8216;read&#8217; the resistor&#8217;s value in order to post a comment.</p>
<div id="attachment_758" class="wp-caption alignleft" style="width: 526px"><a rel="attachment wp-att-758" href="http://www.edesign.nl/2010/04/23/no-robots-beyond-this-line/capture/"><img class="size-full wp-image-758" title="Adafruit's resistor captcha" src="http://www.edesign.nl/wp-content/uploads/2010/04/capture.png" alt="Adafruit's resistor captcha" width="516" height="351" /></a><p class="wp-caption-text">Adafruit&#39;s resistor captcha makes you slide the four sliders to match the color code on the resistor above.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.edesign.nl/2010/04/23/no-robots-beyond-this-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Challenge Hash</title>
		<link>http://www.edesign.nl/2009/05/05/challenge-hash/</link>
		<comments>http://www.edesign.nl/2009/05/05/challenge-hash/#comments</comments>
		<pubDate>Tue, 05 May 2009 07:47:51 +0000</pubDate>
		<dc:creator>Jurgen</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.edesign.nl/?p=202</guid>
		<description><![CDATA[The Internet is a crowd and everybody in it can potentially hear what you say. Methods have been developed to prevent this and ensure identity, integrity and authenticity. Often these three can be seen as properties of encryption. Encryption implies the possibility of decryption. Passwords are precious things you don&#8217;t want others to decrypt and [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-59" href="http://www.edesign.nl/2009/05/05/challenge-hash/hide_a_key/"><img class="alignleft size-medium wp-image-59" title="Hide a key" src="http://www.edesign.nl/wp-content/uploads/2009/03/hide_a_key-300x199.jpg" alt="Hide a key" width="167" height="110" /></a>The Internet is a crowd and everybody in it can potentially hear what you say. Methods have been developed to prevent this and ensure <a href="http://www.edesign.nl/2009/04/24/security-basics/" target="_self">identity, integrity and authenticity</a>. Often these three can be seen as properties of encryption. Encryption implies the possibility of decryption. Passwords are precious things you don&#8217;t want others to decrypt and read. With a technique called challenge hashing you don&#8217;t need to have any worries about it. Challenge hashing is a technique used to verify a password on site B which was sent from site A without sending the password in plain text. This article covers how.<span id="more-202"></span></p>
<h2>Hash</h2>
<p>A <a href="http://en.wikipedia.org/wiki/Cryptographic_hash_function" target="_blank">cryptographic hash function</a> is a deterministic procedure that takes an arbitrary block of data and returns a fixed-size bit string, the (cryptographic) hash value, such that an accidental or intentional change to the data will change the hash value. The data to be encoded is often called the &#8220;message&#8221;, and the hash value is sometimes called the message digest or simply digest. (<a href="http://en.wikipedia.org/wiki/Cryptographic_hash_function" target="_blank">Wikipedia</a>, retreived may 2009). In other words a hash (digest) is the result of a hashing function from a certain input (password, file, etc.).</p>
<h2>Challenge</h2>
<p>The <a href="http://en.wikipedia.org/wiki/Challenge-response_authentication" target="_blank">challenge</a> is a question presented to a party who needs to provide the correct answer. A common form of this algorithm is where the challenge is asking for the password and the valid response is the correct password. Also <a href="http://recaptcha.net/" target="_blank">CAPCHAs</a> are a well known implementation.</p>
<h2>One step further</h2>
<p>When you combine these two an intuitive way of keeping a password secret while being sent along a publicly accessible area and still being valid for authentication checks emerges.</p>
<p>A system has stored user information (username, password, email, etc.) in a database and has the password stored as an MD5 hash. MD5 is the name of the function as there are more hashing functions. When a user requests a login prompt, the server generates a random string (the challenge) and sends it along with the login prompt. Also it stores the string in the session of that request.</p>
<p>The user enters his username and password and hits &#8216;login&#8217;. Just before submitting, a client side script is triggered which calculates the MD5 hash of the password, concatenates the challenge to the digest and hashes that result. This is submitted as the &#8216;password&#8217; in code.</p>
<p>Now the server has to verify the password. As there is no way to reverse the MD5 digest, the coded password is matched agains the database in a special way. The database needs to concatenate the previously generated challenge to the stored digests and calculate the MD5 hash of that. When the result is the same as the submitted coded password a login is successful.</p>
<h2>Discussion</h2>
<p>A downside to this technique is the database server processing capacity is required as password digests need to be hashed every login attempt. Worst case (most processing time) is when such an attempt fails or the last hit is a success as every password in the database needs to be checked. Therefore this system is not really scalable to systems aiming for masses of users.</p>
<p>Client scripting must be available. This is not really a critical downside as e.g. JavaScript is common, but you can not assume everybody supports it.</p>
<h2>Demonstration</h2>
<p>A <a href="http://www.edesign.nl/examples/challengehash/" target="_blank">demonstration of challenge hashing</a> is available in JavaScript and PHP for you to investigate.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edesign.nl/2009/05/05/challenge-hash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Security basics</title>
		<link>http://www.edesign.nl/2009/04/24/security-basics/</link>
		<comments>http://www.edesign.nl/2009/04/24/security-basics/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 09:51:20 +0000</pubDate>
		<dc:creator>Jurgen</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.edesign.nl/?p=227</guid>
		<description><![CDATA[Security is an issue on every level of communication. If you order a bread at the bakery you pay and receive your bread. This face to face approach doesn&#8217;t really need any security. What does it matter if your neighbor, in line next to you, overhears you ordering a bread and sees you pay as [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-233" href="http://www.edesign.nl/2009/04/24/security-basics/securdef/"><img class="alignleft size-thumbnail wp-image-233" title="Security" src="http://www.edesign.nl/wp-content/uploads/2009/04/securdef-150x150.gif" alt="Security" width="150" height="150" /></a>Security is an issue on every level of communication. If you order a bread at the bakery you pay and receive your bread. This face to face approach doesn&#8217;t really need any security. What does it matter if your neighbor, in line next to you, overhears you ordering a bread and sees you pay as long as you get your bread? But what if this would be done online and it involves not a bread but a loan or a transfer from your savings account? You wouldn&#8217;t want a John Doe messing with the data you need to communicate with your bank, would you?<span id="more-227"></span></p>
<p>If (a lot of) money is involved, criminality is or at least tries to be. To prevent burglars from coming into your house you can install anti theft equipment. To prevent third parties from messing with your mail you can send it by registered delivery (as long as you trust your logistics company). You can do the same in the virtual word: online environments like websites or social applications. For example, you could encode a telephone conversation to prevent someone from listening in as cable companies encode their television signals to grant only paying viewers access to the content. When talking about security some basic terms must be clear.</p>
<h2>Identity</h2>
<p>An identity is a unique value which refers to an entity. A username for instance, is unique on a system and refers to the owner (user). A license plate identifies a car and a book from the library probably has it&#8217;s own book id. Id is commonly used to shorten identity or identifier.</p>
<h2>Integrity</h2>
<p>This is a term which in general is subjective. Integrity is a scale how an entity can be trusted. For example, mail mans are considered to be very integer as they are expected not to read and/or alter letters the they deliver. Because of this, a letter has a high level of integrity. You expect the letter you read was written the way you read it.</p>
<h2>Authentication</h2>
<p>This is a term reflecting the authenticity of an entity. Is a painting the original or is it a fake? (Note the words &#8216;the&#8217; and &#8216;a&#8217;). Is a passport counterfeit or is it legal?</p>
<h2>Authorization</h2>
<p>A certain method to allow or deny privileges to an entity. Examples: If you are a site administrator you are authorized to make changes to the site and if you bought a concert ticket you are granted access to the concert perimeter. &#8220;HTTP Error 403: You are not authorized&#8221; and &#8220;Access denied&#8221; are common messages as a result of a failed authorization operation.</p>
<h2>Online utilization</h2>
<p>Often clearance to something (e.g. access to your e-mails) is granted based on proven authentication of an authorized identity. In the example of ordering a bread face to face, you are sure you pay your money to the baker and you are sure you receive your bread. But what if this would not be face to face? What if you would order your bread online and pay by credit card? How can you be sure you paid the bakery and not mister Thief? How can you be sure mister Thief didn&#8217;t listen in and knows your credit card credentials by now? And if you paid the bakery, how can you be sure you receive your bread, which has not been messed with? If you receive anything at all. Every aspect of the four terms mentioned above need to be covered.</p>
<p>Identity is something you can do nothing about. But this can be covered by authentication. The primitive resources to authenticate an identity (verify that someone is who he says to be)  are limited. Basically you can rely on three categories:</p>
<ul>
<li>Physically: Prove that someone is. Examples are fingerprints, retina scans, voice prints and DNA.</li>
<li>Property: Prove by possession. Examples are passports and credit cards.</li>
<li>Knowledge: Prove by memory. Examples are passwords and PIN codes.</li>
</ul>
<p>In digital telecommunication only property and knowledge based tests can be performed. This is because the physical properties will need to be sampled in order to be transmitted to the checking authority. This sample can be seen as a (long) password, which can be copied, stored, etc and therefore as safe as a password. This is in contradiction to face to face communication, where e.g. finger prints, behavioural habits or facial expressions cannot easily be copied.</p>
<p>Usually only something from the knowledge domain is required for login on the Internet (combination of username and password) and does therefore not always guarantee a satisfying safety level. How more techiques from this field are used will be discussed in the follow up article on security basics. Techniques like SSL, public key/private key, certificates, hashing, etc&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edesign.nl/2009/04/24/security-basics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
