
<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>PHP, Web and IT stuff &#187; Security</title>
	<atom:link href="http://www.webdigi.co.uk/blog/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdigi.co.uk/blog</link>
	<description>Little words of wisdom</description>
	<lastBuildDate>Sat, 04 Sep 2010 22:35:29 +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>Stupidity versus Malice</title>
		<link>http://www.webdigi.co.uk/blog/2009/stupidity-versus-malice/</link>
		<comments>http://www.webdigi.co.uk/blog/2009/stupidity-versus-malice/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 16:25:55 +0000</pubDate>
		<dc:creator>iphp</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Disaster]]></category>

		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/?p=531</guid>
		<description><![CDATA[As a web developer, I am required to build web applications and secure websites. One of the key requirement is to create a secure and well protected system to keep attackers at bay. Although securing the website from malice is important, it is also important to secure the web application from stupidity. Stupidity from the [...]]]></description>
			<content:encoded><![CDATA[<p>As a web developer, I am required to build web applications and secure websites. One of the key requirement is to create a secure and well protected system to keep attackers at bay. Although securing the website from malice is important, it is also important to secure the web application from stupidity. Stupidity from the privileged users, administrators, developers, etc. The cost of stupidity is often underestimated. By stupidity I mean lack of average intelligence assumed for a particular task or not thinking through atleast a few worst case scenarios prior to doing something.</p>
<p>Let me give you a few <strong>big</strong> examples from history and recent times.</p>
<p><strong>1) Data worth 2 billion dollars lost in courier</strong><br />
In 2007, 25 million child benefit records was sent from one government department to another and was lost by the courier company. The discs were sent by a junior staff member <strong>unencrypted and unregistered</strong>. The discs contained all kinds of personal data, names and ages of children, bank savings account numbers, partners details and even National Insurance Numbers (Equivalent to the Social Security Numbers).  The costs that this caused UK is not clear but it did involve high profile resignations, weeks and weeks of political debates, banks monitoring millions of accounts for fraudulent activity, etc. Some estimate the data alone could be worth over <a href="http://news.bbc.co.uk/1/hi/uk_politics/7117291.stm">$2 billion</a> in criminal hands.</p>
<p><strong>2) The Honda Point Disaster (Off California Coast)</strong></p>
<div id="attachment_533" class="wp-caption alignleft" style="width: 310px"><a href="http://www.webdigi.co.uk/blog/wp-content/uploads/2009/09/honda_point.gif"><img class="size-medium wp-image-533" title="honda_point" src="http://www.webdigi.co.uk/blog/wp-content/uploads/2009/09/honda_point-300x237.gif" alt="Aerial view showing all seven destroyers" width="300" height="237" /></a><p class="wp-caption-text">Aerial view showing all seven destroyers</p></div>
<p>This was the largest peacetime loss of U.S. Navy ships in which <strong>seven destroyers were lost</strong>. This tragedy was not caused by malice. Twenty-three sailors died in the mishap. Two other destroyers were slightly damaged. The navy court ruled it as a fault of the navigators and the captains of each ship. <strong>How did this happen? </strong>The flagship was equipped with a radio navigational receiver, but ignored the bearings, believing them to be erroneous. No effort was made to take soundings or depth measurements. These operations were not performed due to the <strong>need to slow the ships to take readings</strong>. The ships were performing an exercise that simulated wartime conditions, hence the decision not to slow down. In this case, the dead reckoning (method of estimating position) was wrong and the mistake fatal. The need to slow the ship might also reminds us of another disaster, the Titanic!</p>
<p><strong>3) Aviation Accidents<br />
<span style="font-weight: normal;"><a href="http://www.boeing.com/news/techissues/pdf/statsum.pdf">Boeing studied</a> commercial jet accidents (not including hijacking, test flights, etc) between 1959 to 2008. They determined the primary cause of Airline hull loss accidents (aircraft beyond repair) to be the following:<br />
</span></strong></p>
<li><strong>55%: Flight crew error</strong></li>
<li>17%: Airplane</li>
<li>13%: Weather</li>
<li>7%: Misc./Other</li>
<li><strong>5%: Air traffic control</strong></li>
<li>3%: Maintenance</li>
<p><strong><span> </span> </strong></p>
<p>Clearly a lot of these are preventable and a lot of lives could have been saved. Flight crew error and the Air traffic control accounts to about 60% of all hull loss accidents.</p>
<p><strong>In Conclusion<br />
</strong>Accidents do and will happen, I would recommend developers to think about stupidity and not just malice when building systems. I have two interesting quotes to leave you with.<br />
Albert Einstein - <em>Two things are infinite: the universe and human stupidity; and I&#8217;m not sure about the universe.</em><br />
Hanlon&#8217;s Razor<strong> </strong>- <em>Never attribute to malice that which can be adequately explained by stupidity.</em></p>
<p>Do share incidents that you have come across during your career.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdigi.co.uk/blog/2009/stupidity-versus-malice/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to detect if your webserver is hacked and get alerted</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-detect-if-your-webserver-is-hacked-and-get-alerted/</link>
		<comments>http://www.webdigi.co.uk/blog/2009/how-to-detect-if-your-webserver-is-hacked-and-get-alerted/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 15:36:53 +0000</pubDate>
		<dc:creator>php-manual</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/?p=31</guid>
		<description><![CDATA[We all do our best to write excellent code and also keep our installations of popular open source tools like Wordpress, Joomla, Oscommerce, Drupal, phpmyadmin and all its plugins always updated to prevent any attack or hackers using known exploits on them. This article is not aimed at going through all those methods to help you secure [...]]]></description>
			<content:encoded><![CDATA[<p>We all do our best to write excellent code and also keep our installations of popular open source tools like Wordpress, Joomla, Oscommerce, Drupal, phpmyadmin and all its plugins always updated to prevent any attack or hackers using known exploits on them. This article is not aimed at going through all those methods to help you secure your website BUT focuses on how to send you an alert once your website is hacked and running &#8220;hidden&#8221; code that you didnt write.</p>
<p><span id="more-31"></span></p>
<p><span style="text-decoration: underline;">The problem</span></p>
<p>Once hackers get into your website either by exploiting known vulnerabilities in any of the installed programs OR by getting FTP access to your server, the first thing they usually do is to plant backdoor scripts to log them in again at a later date. They need some executable script on the server to gain access to MySQL passwords, installation passwords or even edit settings in your wordpress or other installations.  We have also seen situations where the site was left largely unchanged except for malicious javascript code added to the bottom of the index.php or index.html files.</p>
<p>So in short the bad guys have taken over your server and running anything from a backdoor script or launching phishing attacks or sending tons of spam emails. You will not know that your server is hacked until you get blacklisted on spamhaus or your customers get redirected to some random site or worser still when you are contacted by ebay/paypal/some bank saying that your website is phisihing their customers. <strong>The problem is that we dont even have an idea that our site is hacked until it is too late or too embrassing.</strong></p>
<p><span style="text-decoration: underline;">Simple Solution &#8211; Website Change Detection System</span></p>
<p>We need a script on the server that detects any changes or to any executable file on the server or any new file on the server from HTML, JS, to PHP, ASP, Perl, Python files etc.  If we generate a <strong>hash </strong>value of all our files and then compare them periodically, then we will be able to detect when our codebase has changed on the server.</p>
<p>These are the steps that our change detection system performs (It takes about 500ms to execute on a typical server):</p>
<ol>
<li>Load configuration file (contains password, exclude list)</li>
<li>Check password from request before starting (recommended)</li>
<li>Recursively run through every file and sub folder on the server within the current directory of the script.</li>
<li>Generate a hash for each file and arrive at the master hash.</li>
<li>Compare master hash with hash the user has and alert if different!</li>
</ol>
<p>Notes:</p>
<ul>
<li>This script at this simple level is almost 100% fool proof in detecting changes to the codebaes give that the hacker or bots don&#8217;t know of websiteCDS presence.</li>
<li>At this stage the script cannot detect SQL injection attacks and changes to code that are saved to the database.</li>
<li>The users hash is not stored on the server at any time, the comparison with master hash can be done at cron script level or using siteup as discussed below.</li>
</ul>
<p>We have the following code written in PHP but you can do the same with any other scripting language to perform similar checks. We have started the project under google code and is available here: <a title="websiteCDS version in PHP" href="http://websitecds.googlecode.com/files/websitecds%20version1.zip" target="_blank">PHP code for WebsiteCDS</a><br />
See the readme file in the download for help with setup.</p>
<p><span style="text-decoration: underline;">Different ways to automate the alert system</span></p>
<p>Method 1: Using our trusted cron job<br />
A cron job can be setup to run the website CDS, compare the results with the last known valid hash and send out an email alert.</p>
<p>Method 2: With Siteup<br />
Siteup is a free tool for windows systems that can be set to periodically check if your website is reachable. This is recommended for those of us who don&#8217;t want to setup a cron job. It can be downloaded here <a rel="nofollow" href="http://www.xequte.com/other/index.html#siteup"  target="_blank">http://www.xequte.com/other/index.html#siteup</a> We can use this to frequently call our change detection system and then use the siteup word search to check if the hash value is the same as what we have from our last codebase update. ( <a title="websiteCDS setup in SiteUP" href="http://blogcdn.webdigi.co.uk.s3.amazonaws.com/blog/wp-content/uploads/2009/screenshot/SiteUPeditSite.jpg" target="_blank">See screenshot</a> )</p>
<p>NOTE: The project &amp; code included is the first version of the change detection system and kindly submit your ideas and comments here or an issue or feature request in <a title="WebsiteCDS issue tracking" href="http://code.google.com/p/websitecds/issues/list" target="_blank">google code project for websitecds</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdigi.co.uk/blog/2009/how-to-detect-if-your-webserver-is-hacked-and-get-alerted/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>PHP session fixation attacks</title>
		<link>http://www.webdigi.co.uk/blog/2009/php-session-fixation-attacks/</link>
		<comments>http://www.webdigi.co.uk/blog/2009/php-session-fixation-attacks/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 12:45:05 +0000</pubDate>
		<dc:creator>php-manual</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/?p=6</guid>
		<description><![CDATA[Session fixation attacks attempt to exploit the vulnerability of a system which allows one person to fixate (set) another person's session identifier (SID). Most session fixation attacks are web based, and most rely on session identifiers being accepted from URLs (query string) or POST data.]]></description>
			<content:encoded><![CDATA[<p>Session fixation attacks attempt to exploit the vulnerability of a system which allows one person to fixate (set) another person&#8217;s session identifier (SID). Most session fixation attacks are web based, and most rely on session identifiers being accepted from URLs (query string) or POST data.</p>
<p><span style="text-decoration: underline;">Example of such an attack</span>: Lets take an example of a banking website which provides login to access banking features. (this can be any site which allows users to login).<br />
EG: http://www.poorbanking.com</p>
<p>1) Hacker<br />
Creates a very a link and sends visitors to the site as http://www.poorbanking.com/index.php?PHPSESSID=1234<br />
Lets assume PHPSESSID is the name of the cookie / variable used to store session information. It is very easy for anyone to find this by just visiting the site once.</p>
<p>2) Hacker sends link to the target user.<br />
http://www.poorbanking.com/index.php?PHPSESSID=1234 by email or placed in a blog etc.</p>
<p>3) Victim<br />
Sees the link and clicks on it. The site looks genuine and the victim logs in to the site. At this stage the PHPSESSID is set to PHPSESSID=1234 and user is logged in.</p>
<p>4) The happy hacker<br />
Hacker can keep checking if they can login by simply going to http://www.poorbanking.com/showmeaccount.php?PHPSESSID=1234<br />
where showmeaccount.php is the page after login. They can see that once the user has logged in they can easily get access to the page.</p>
<p><span style="text-decoration: underline;">Work around to this problem</span></p>
<p>Just prior to setting such a session variable, a call to session_regenerate_id() can help to protect against a session fixation attack.</p>
<p>See more information at http://en.wikipedia.org/wiki/Session_fixation</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdigi.co.uk/blog/2009/php-session-fixation-attacks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
