<?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>Design Reviver &#187; Security</title>
	<atom:link href="http://designreviver.com/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://designreviver.com</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 14:15:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Taking the Best Measure to Fortifying Your Scripts</title>
		<link>http://designreviver.com/articles/taking-the-best-measure-to-fortifying-your-scripts/</link>
		<comments>http://designreviver.com/articles/taking-the-best-measure-to-fortifying-your-scripts/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 15:47:14 +0000</pubDate>
		<dc:creator>Joel Reyes</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://designreviver.com/?p=7942</guid>
		<description><![CDATA[No matter how hard we try, we always seem to forget to secure certain aspects of our scripts, whether be it an input field or data being inserted into a database. It would definitely be nice to fall back on security precautions that we implement into our scripts whether or not we have sanitized everything [...]]]></description>
			<content:encoded><![CDATA[<div class="KonaBody"><p>No matter how hard we try, <strong>we always seem to forget to secure certain aspects of our scripts</strong>, whether be it an input field or data being inserted into a database. It would definitely be nice to fall back on security precautions that we implement into our scripts whether or not we have sanitized everything needed. Here are some tips and coding styles to achieve just that.<span id="more-7942"></span></p>
<h4>The Solution</h4>
<p><img src="http://designreviver.com/wp-content/uploads/2010/07/securescript-1.jpg" alt="" /></p>
<p>The difference this solution can make is massive depending on how large the script is. <strong>We generally know that the larger or more complicated the script is the more we will miss on securing things.</strong> Using a precautionary solution enables us to have automatically patched many things we may have forgotten to sanitize or secure.</p>
<p>For example, forms provide a way for users to provide data for input into your database or other storage methods. We know that forms are the general cause of security flaws in many scripts that fail to have properly sanitized input due to ignorance or the cause of forgetting to do so. Another common missed aspect is forgetting to sanitize <em>superglobals</em> such as $_POST, $_REQUEST, $_GET, and others.</p>
<p>Furthermore, developing a solution that performs the sanitization and takes security measures for us is an excellent fall back as it could do the patching work for us in many situations, which provides us the time to create a permanent fix.</p>
<h4>Which Scripts Benefit the Most?</h4>
<p><img src="http://designreviver.com/wp-content/uploads/2010/07/securescript-2.jpg" alt="" /></p>
<p>Many scripts we create may be too small to bother developing a fallback component, as it may be larger than the script itself. Thus, it will definitely be a waste of time to do so. However, if you are developing <strong>a fairly large system</strong>, whether hitting the mainstream or not, spending the time to develop a fallback component will definitely be worthwhile, especially if the system being developed handles transactions or is built around user inputted data.</p>
<p>If your script happens to fall in the too small to bother category, you can still take certain precautionary measures while developing it. These precautionary measures include frequently testing your work as you go along for security flaws and going over your work multiple times. These measures should also be taken in any sized project, as checking your work is always a great thing to do.</p>
<h4>Creating These Solutions</h4>
<p><img src="http://designreviver.com/wp-content/uploads/2010/07/securescript-3.jpg" alt="" /></p>
<p><strong>Creating a fallback component</strong> depends on your needs and expectations of how it should function. It can be a complex solution and can automatically detect the input type and sanitize accordingly, or it can be a simple solution implementing a standard sanitization or security method throughout. You should remember that these fallback solutions create temporary security patches to certain security flaws until you can get in and create a permanent patch, thus, you should not rely on this component as your only means of sanitization and security.</p>
<p>When creating these solutions, creating classes is generally a good idea as they act as an interface handler for each of your solutions. In order to better understand and grip this idea I will briefly walk through a simple form handler class that takes a default sanitization method throughout.</p>
<p>Let us dive right in to the way this form handler class was structured and the way it functions. This class was designed to replace creating your own forms with its own infrastructure to assure that the form is handled securely. However, this class lacks auto detection of deciding what security measures to take based on the user inputted data, nevertheless, it does take basic security precautions to assure that the data being handled is not abrasive.</p>
<h4>Examples and Best Practices</h4>
<p>Let us look at one of its methods, the text area handler:</p>
<pre><code>...
//begin a foreach to grab 'em values
foreach($array as $key =&gt; $value)
{
//begin the switch case to identify the values
switch($key)
{
Case 'name':
$name = $value;
Break;

Case 'class':
$class = $value;
Break;

Case 'id':
$id = $value;
Break;

Case 'value':
$i_value = $sanatize-&gt;specialTrim($value);
Break;

Case 'required':
$required = $value;
Break;

Case 'label':
$label = $value;
Break;

Case 'hint':
$hint = $value;
Break;
}
...</code></pre>
<p>As you may have noticed, <strong>it automatically sanitized the user-inputted value</strong>, it is simple, however effective. In the code snippet above, it is running a check on all the possible fields available for a textarea box; this is designed to assure that unwanted fields are filtered out.</p>
<p>Another key aspect to this form handler class is the way it handles some of the <em>superglobals</em> mentioned earlier:</p>
<pre><code>public function post($parameter)
{
$cleanup = @$this-&gt;stripBreak($parameter);
$post = @$_POST[$cleanup];
return $post;
}

/******
* @method public
* @return $_REQUEST
* @param string the $_REQUEST param which is sanatized
* This handles the $_REQUEST variable which also sanatizes its value
*/

public function request($parameter)
{
$cleanup = @$this-&gt;stripTags($parameter);</code></pre>
</div>]]></content:encoded>
			<wfw:commentRss>http://designreviver.com/articles/taking-the-best-measure-to-fortifying-your-scripts/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Valuable Tips for Locking Down Your WordPress Website</title>
		<link>http://designreviver.com/articles/valuable-tips-for-locking-down-your-wordpress-website/</link>
		<comments>http://designreviver.com/articles/valuable-tips-for-locking-down-your-wordpress-website/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 19:00:29 +0000</pubDate>
		<dc:creator>Joel Reyes</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://designreviver.com/?p=2729</guid>
		<description><![CDATA[There are a variety of Content Management Systems (CMS) that can fulfill many of your sites needs, however, WordPress is usually recommended as the leading publishing platform. With popularity comes vulnerability and WordPress sites are usually open to all sorts of potential attacks from hackers, spammers, and other mal-intentioned Internet users trying to compromise the [...]]]></description>
			<content:encoded><![CDATA[<div class="KonaBody"><p>There are a variety of <strong>Content Management Systems (CMS)</strong> that can fulfill many of your sites needs, however, <strong>WordPress</strong> is usually recommended as the leading publishing platform. With popularity comes vulnerability and WordPress sites are usually open to all sorts of potential attacks from hackers, spammers, and other mal-intentioned Internet users trying to compromise the security of your WordPress environment.<br />
<span id="more-2729"></span><br />
Below we&#8217;ve compiled a few Valuable Tips for Locking Down Your WordPress Website allowing you to add several layers of security to your site.</p>
<h2>Update WordPress</h2>
<p>It might seem a little basic and obvious though a surprising number of WordPress users forget to update their site. If you&#8217;re looking or are in need of an update and you&#8217;re super-security-conscious don&#8217;t upgrade to the next big release right away. Have a little patience and wait for the bug fixes to come in and then make the installment. This will save you tons of headaches as you&#8217;re likely to want to fix flaws yourself if they haven&#8217;t been exploited on a large scale.</p>
<p>Truthfully speaking you&#8217;re taking unnecessary risks by not updating, so if you have a WordPress installation that is at least two versions old, update it as soon as possible. It literally takes just about 5 minutes according to WordPress.</p>
<h2>Back-Up Your MySQL Database on a Regular Basis</h2>
<p>It should be at the top of your list to always back up your site files and database. Try to regularly remember having to back-up your MySQL database by exporting your MySQL data as a <strong>.sql</strong> file to be stored in a keep-safe location.  Since it&#8217;s easy to forget having to back-up your files on a regular basis, it&#8217;s much easier to automate this task.</p>
<p>Download and use the plugin called <a href="http://redirectingat.com?id=356X662675&xs=1&url=http%3A%2F%2Fwww.ilfilosofo.com%2Fblog%2Fwp-db-backup%2F&sref=rss"><strong>WordPress Database Backup</strong></a> to automate your backups. This plugin provides you with the options to automate your back-up on hourly, daily, weekly, and monthly intervals. You can find a large variety of tools you can use for database backup automation, it would be a safe-haven to explore these tools and make a selection based on overall performance and effectiveness.</p>
<h2>Using a Strong Password</h2>
<p>Using a password that&#8217;s only easy to remember and offers no form of complex structure is one of the main reasons your WordPress site may be hijacked. A complex password is probably one of the easiest and most overlooked preventative steps you can take towards improving the security of your WordPress install. There are several tools available that gauge the complexity of your password. One of them being Microsoft&#8217;s completely free web-based tool called <a href="http://redirectingat.com?id=356X662675&xs=1&url=http%3A%2F%2Fwww.microsoft.com%2Fprotect%2Fyourself%2Fpassword%2Fchecker.mspx&sref=rss"><strong>Password checker.</strong></a></p>
<h2>The Security &amp; Integrity of Your wp-admin Folder</h2>
<p>It&#8217;s no question that the <strong>wp-admin</strong> folder is a key component in your WordPress install. This file contains all of the elements of design and functionality that deal with the administration aspect of your site. If for any reason the security of the files in this folder were to be compromised, an awful lot of bad things can happen to your WordPress installation, as well as your domain.</p>
<p>You can stop a security breach on the wp-admin folder by limiting the IP addresses that can access it via an <em>.htaccess file</em> (for Apache web servers). Start by creating a new blank document in any text or source code editor. Save this file with the name: <strong><em>.htaccess.</em></strong></p>
<pre><code>order deny, allow
allow from 125.555.55 #Your IP Address
deny from all</code></pre>
<p>Finalize this step by saving the file and placing it inside your wp-admin folder. This will tighten the security of your wp-admin folder along with the integrity of your site.</p>
<h2>Secure Connections to Your WordPress Admin Pages</h2>
<p>Another technique that will allow you to lock-in the security of your site is by logging into your <strong>WordPress Admin Panel</strong> through encrypted SSL connections. If your host doesn&#8217;t include an SSL Certificate along with your plan, they&#8217;re well worth the investment. As soon as you&#8217;ve obtained your SSL connection, run your sessions on <strong>https:// instead of http://</strong> protocols by forcing SSL connections on admin-related pages and functions.</p>
<p>You will also have to access your <strong>wp-config</strong> file and insert the following code:</p>
<pre><code>define('FORCE_SSL_ADMIN', true);</code></pre>
<h2>Hiding Your Current WordPress Version</h2>
<p>Several WordPress developers often like to display the current WordPress version in their source code. By having this information publicly available this makes it easy for attackers to exploit possible known vulnerabilities specific to that WordPress version. In order to remove this from your source code you&#8217;ll have to access your theme’s <strong>header.php</strong> file, search for the string of code that looks similar to the following code block and then remove it:</p>
<p><img class="alignnone size-full wp-image-2732" src="http://designreviver.com/wp-content/uploads/2009/09/code-block-01.jpg" alt="code block-01" width="518" height="60" /></p>
<h2>Using SFTP instead of FTP</h2>
<p>Contrary to what many believe <strong>FTP</strong> isn’t as secure as you may think. By utilizing an FTP application to connect to your site, you’re simply sending your password in plain, readable text every single time you log in. If a hacker wanted to ‘listen in’ or intercept that information, it wouldn&#8217;t be a far-fetched task for them to succeed through your FTP.</p>
<p>You can fix this issure by beginning to use the <strong>Secure File Transfer Protocol (SFTP)</strong> instead of FTP from the moment you decide to access your site. It&#8217;s simplicity is beyond FTP and there are a few web hosts who have this turned on by defualt (2Eleven). If your host does not provide this by default then all you have to do is ask your hosting company which port number to use in order for the SFTP to take effect, then change the settings in your FTP application.</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://designreviver.com/articles/valuable-tips-for-locking-down-your-wordpress-website/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>PHP Security: Guidelines to Lock Down Your Website</title>
		<link>http://designreviver.com/tips/php-security-guidelines-to-lock-down-your-website/</link>
		<comments>http://designreviver.com/tips/php-security-guidelines-to-lock-down-your-website/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 19:00:15 +0000</pubDate>
		<dc:creator>Joel Reyes</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[attacks]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://designreviver.com/?p=1118</guid>
		<description><![CDATA[Security has always been a concern of web developers. No site is safe from hacking attempts. Developers need to take precautions when building their applications so that they don’t become the victim of a hacking attempt. There are a number of things PHP programmers can do to prevent these kinds of attacks. What Is XSS? [...]]]></description>
			<content:encoded><![CDATA[<div class="KonaBody"><p>Security has always been a concern of web developers. No site is safe from hacking attempts. Developers need to take precautions when building their applications so that they don’t become the victim of a hacking attempt. There are a number of things PHP programmers can do to prevent these kinds of attacks.</p>
<p class="showcase">
<p><span id="more-1118"></span></p>
<h2><strong>What Is XSS? </strong></h2>
<p><a href="http://designreviver.com/wp-content/uploads/2009/06/php2.jpg"><img class="alignnone size-full wp-image-1119" src="http://designreviver.com/wp-content/uploads/2009/06/php2.jpg" alt="" width="500" height="300" /></a></p>
<p>XSS stands for Cross Server Scripting, and is the most common technique for hacking into a website. Most of the tips we will be talking about today will be things designed to prevent XSS attacks on your server. XSS is when someone injects code into your website, and gets it to execute. This can be used for a variety of malicious purposes.</p>
<p>Here is an example of a simple XSS attack I was able to perform on my site. I noticed that my user name was contained inside a tag on my profile page. I changed my user name to this:</p>
<p><a href="http://designreviver.com/wp-content/uploads/2009/06/php1.jpg"><img class="alignnone size-full wp-image-1120" src="http://designreviver.com/wp-content/uploads/2009/06/php1.jpg" alt="" width="458" height="60" /></a></p>
<p class="showcase">
<p>This caused an alert fired away every time someone opened my profile page. It would not have been difficult for me to import an external JavaScript file, or write one that did something more malicious.</p>
<p><a href="http://redirectingat.com?id=356X662675&xs=1&url=http%3A%2F%2Fha.ckers.org%2Fxss.html&sref=rss" target="_new"> List of common XSS exploits </a></p>
<p class="showcase">
<h2><strong>Sanitizing Input </strong></h2>
<p><a href="http://designreviver.com/wp-content/uploads/2009/06/php3.jpg"><img class="alignnone size-full wp-image-1121" src="http://designreviver.com/wp-content/uploads/2009/06/php3.jpg" alt="" width="500" height="300" /></a></p>
<p>Most XSS attacks come from manipulating the input of a site. Input comes in two forms: Forms and GET variables.  You need to take care to properly sanitize these inputs before doing anything else with them. Here are a few things you can do to make sure the input you receive is safe:</p>
<p class="showcase">
<h2><strong>Use PHP&#8217;s addslashes Function </strong></h2>
<p><a href="http://designreviver.com/wp-content/uploads/2009/06/php4.png"><img class="alignnone size-full wp-image-1122" src="http://designreviver.com/wp-content/uploads/2009/06/php4.png" alt="" width="500" height="300" /></a></p>
<p>This is a very simple thing you can do that can help prevent attacks. Simply run all of your input through the addslashes method in PHP. The slashes help escape characters that could otherwise be dangerous.</p>
<p class="showcase">
<h2><strong>Use the strip_tags Function </strong></h2>
<p>strip_tags() is another handy PHP function that can help sanitize input. You also have the option of allowing certain tags, so if you have a page where users should be allowed to use some HTML (for example, a blog post) you can still allow them to use some tags. However, be wary of allowing particularly dangerous tags, such as &lt;script&gt; or &lt;iframe&gt;.</p>
<p class="showcase">
<h2><strong>Remove JavaScript From Input </strong></h2>
<p><a href="http://designreviver.com/wp-content/uploads/2009/06/php5.jpg"><img class="alignnone size-full wp-image-1123" src="http://designreviver.com/wp-content/uploads/2009/06/php5.jpg" alt="" width="500" height="300" /></a></p>
<p>By Using regular expressions, we can make sure that no JavaScript gets through to execute. While using strip tags to remove  tags can take care of some JavaScript, it doesn&#8217;t handle instances where people may put a JavaScript event on another tag, such as an &lt;a&gt; tag. Below is a simple function that removes JavaScript from the input it is given, by using regular expressions:</p>
<pre><code>
function removeJavaScript($input){
  return  preg_replace('#]*&gt;.*?#is','',$input);
}
</code></pre>
<p class="showcase">
<h2><strong>Remove Flash From Input </strong></h2>
<p>Much like JavaScript, Flash can also be embedded via XSS and used for malicious purposes. Below is another function, which will strip Flash from the input given:</p>
<pre><code>
function removeFlash($input){
    return preg_replace("/&lt;object[0-9 a-z_?*=\":\-\/\.#\,\\n\\r\\t]+/smi", "", $input);
}

</code></pre>
<p class="showcase">
<h2><strong>Putting It All Together </strong></h2>
<p><a href="http://designreviver.com/wp-content/uploads/2009/06/php6.jpg"><img class="alignnone size-full wp-image-1124" src="http://designreviver.com/wp-content/uploads/2009/06/php6.jpg" alt="" width="500" height="300" /></a></p>
<p>Below is a handy function I&#8217;ve written that can handle all of the above methods of cleaning input. It also gives you the option of allowing JavaScript, Flash, or certain HTML tags:</p>
<pre><code>
function sanitizeInput($input,$allowedTags=””,$allowJavaScript=false,$allowFlash=false){
	$input  =  strip_tags($input,$allowedTags);
	if(!$allowJavaScript){
		$input = preg_replace('#]*&gt;.*?#is','',$input);
	}

	if(!$allowFlash){
		$input = preg_replace("/&lt;object[0-9 a-z_?*=\":\-\/\.#\,\\n\\r\\t]+/smi",
"", $input);
	}
	return $input;

}
</code></pre>
<p class="showcase">
<h2><strong>Check The Referring Page </strong></h2>
<p>Web sites are able to send requests from any server to another, and this can be dangerous. One way of making sure input is coming from where it is supposed to is to use the $_SERVER array in PHP and check what the referring site is. You can also add unique keys to forms and some pages to make sure that the input you are receiving is coming from a reliable source.</p>
<p>NETTuts has a great tutorial on this: <a href="http://redirectingat.com?id=356X662675&xs=1&url=http%3A%2F%2Fnet.tutsplus.com%2Ftutorials%2Fphp%2Fsecure-your-forms-with-form-keys%2F&sref=rss"> Secure Your Forms with Form Keys </a></p>
<p class="showcase">
<h2><strong>Using Encryption </strong></h2>
<p><a href="http://designreviver.com/wp-content/uploads/2009/06/php7.jpg"><img class="alignnone size-full wp-image-1127" src="http://designreviver.com/wp-content/uploads/2009/06/php7.jpg" alt="" width="500" height="300" /></a></p>
<p>One of the biggest no-nos in all of web programming is storing sensitive information in plain text inside of a database. Things like passwords, social security numbers, and credit card numbers are very common pieces of data that should not be stored in a database.<br />
<!--more--><br />
It is doing a disservice to the users of your site, because if your database was ever to be compromised, you have put your users in addition to yourself, at risk.</p>
<p>PHP&#8217;s md5 and crypt functions are great tools for making sure your database is secure. Crypt allows you to use a salt variable, to help make encryption more secure, while md5 does not.  Here is an example of how to encrypt passwords, and how to verify them when a user tries to log on, using the crypt function:</p>
<pre><code>
//encrypt the input
$input  = $_POST['password'];
$salt    =  “makeThisSecure”;
$safePassword  = crypt($input,salt);
//just re encrypt the password to check
$password_attempt = “password”;
if(crypt($password_attempt,$salt) == $safePassword){
	//log the user in
}
</code></pre>
<p class="showcase">
<h2><strong>Using CAPTCHAs </strong></h2>
<p><a href="http://designreviver.com/wp-content/uploads/2009/06/php8.png"><img class="alignnone size-full wp-image-1125" src="http://designreviver.com/wp-content/uploads/2009/06/php8.png" alt="" width="500" height="300" /></a></p>
<p>If you have any kind of form that does not require a user to be logged in, using CAPTCHAs is a good way to prevent spam bots from inputing bogus information.  There are a lot of good CAPTCHA scripts that are freely available, such as : <a href="http://redirectingat.com?id=356X662675&xs=1&url=http%3A%2F%2Fwww.phpcaptcha.org%2F&sref=rss" target="_new"> www.phpcaptcha.org/</a>, and here is a  <a href="http://redirectingat.com?id=356X662675&xs=1&url=http%3A%2F%2Fwww.codewalkers.com%2Fc%2Fa%2FMiscellaneous%2FCreating-a-CAPTCHA-with-PHP%2F&sref=rss" target="_new"> tutorial on how to create your own CAPTCHA </a></p>
<p class="showcase">
<h2><strong>Have Secure Passwords </strong></h2>
<p><a href="http://designreviver.com/wp-content/uploads/2009/06/php9.jpg"><img class="alignnone size-full wp-image-1126" src="http://designreviver.com/wp-content/uploads/2009/06/php9.jpg" alt="" width="500" height="300" /></a></p>
<p>A number of hacking attempts come from people not having very strong passwords. Even Twitter fell victim to this not long ago (link to article).  Make sure that your password has a good mix of letters, numbers, and symbols, and that it isn&#8217;t a word that can be found in the dictionary. This includes passwords that are common words, but are spelled in &#8216;leet speak&#8217;, for example drag0n.</p>
<p>If you take these steps, you should have a much more secure web application. It can sometimes be a hassle to update existing projects, but it is nothing compared to the headache you will suffer if you don&#8217;t, and become the victim of an attack.  It is important that you don&#8217;t think of securing an application as an afterthought, but instead something that is part of your regular development process.</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://designreviver.com/tips/php-security-guidelines-to-lock-down-your-website/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

