<?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>CSSKarma &#187; Security</title> <atom:link href="http://www.csskarma.com/blog/category/security/feed/" rel="self" type="application/rss+xml" /><link>http://www.csskarma.com/blog</link> <description>display your style</description> <lastBuildDate>Tue, 31 Jan 2012 15:18:44 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Form Security with Autocomplete</title><link>http://www.csskarma.com/blog/autocomplete-off/</link> <comments>http://www.csskarma.com/blog/autocomplete-off/#comments</comments> <pubDate>Fri, 10 Apr 2009 15:57:04 +0000</pubDate> <dc:creator>Tim</dc:creator> <category><![CDATA[Security]]></category> <category><![CDATA[forms]]></category> <category><![CDATA[ui]]></category><guid
isPermaLink="false">http://www.csskarma.com/blog/?p=480</guid> <description><![CDATA[I was looking through my blog this morning because I could have sworn I already wrote this post. I know I&#8217;ve had this conversation with Phil Nash of Unintentionally Blank. But I guess I never wrote it down? Oh well&#8230; One of my pet peeves when filling out a form is when I click in [...]]]></description> <content:encoded><![CDATA[<p><img
src="http://www.csskarma.com/images/articles/autocomplete.jpg" alt="article banner"/></p><p>I was looking through my blog this morning because I could have sworn I already wrote this post. I know I&#8217;ve had this conversation with Phil Nash of <a
href="http://www.unintentionallyblank.co.uk/">Unintentionally Blank</a>. But I guess I never wrote it down? Oh well&#8230;</p><p>One of my pet peeves when filling out a form is when I click in the payment field and my credit crard / bank account number drops down because it was saved in the browser from last time I made a payment on that site. How is it that developers on these sites overlook that <strong>huge</strong> security issue?</p><p>There&#8217;s a very simple fix for it, and it&#8217;s called &#8220;autocomplete off&#8221;:</p><h5>The XHTML</h5><pre><code>&lt;input id="pmt" name="payment" type="text" autocomplete="off"/&gt;</code></pre><p>The <code>autocomplete="off"</code> makes sure the text field doesn&#8217;t expose any saved data. Of course, it would be too easy if this was valid XHTML so it&#8217;s not. If you&#8217;re concerned with writing 100% valid XHTML, there are valid ways to do this.</p><h4>Writing valid code</h4><p>To make this valid, we need to do it with JavaScript. Since I&#8217;m pretty sure most people who read this are jQuery freaks (like me), I&#8217;ll show the jQuery version of this:</p><h5>The XHTML</h5><pre><code>&lt;input id="pmt" name="payment" type="text" /&gt;</code></pre><h5>The jQuery</h5><pre><code>$(function() {
$("input#pmt").attr("autocomplete","off");
});</code></pre><h4>The problem with added security with JavaScript</h4><p>I don&#8217;t really recommend using javaScript for this, only because it&#8217;s easily disabled. And then you&#8217;re back at square one with the payment info dropping down in the text field</p><p>Ideally, I&#8217;d like to use PHP to do this, but I can&#8217;t find it anywhere so I&#8217;m using &lt;noscript&gt;:</p><h5>The jQuery</h5><pre><code>$(function() {
$("form#paymentform").html("&lt;input id="pmt" name="payment" type="text" autocomplete="off"/&gt;);
});</code></pre><h5>The XHTML (placed inside the form)</h5><pre><code>&lt;label for="pmt"&gt;Credit Card Number&lt;/label&gt;
&lt;noscript&gt;</code><code>&lt;input id="pmt" name="payment" type="text" autocomplete="off"/&gt;</code><code>&lt;/noscript&gt;</code></pre><p>That way, if javascript is enabled you&#8217;ll use the jQuery to write the textfield, and if it&#8217;s not, you&#8217;ll just write it out normally, which will be invalid, but more secure.</p><p>Let me know if anyone knows the PHP way to check for JS.</p> ]]></content:encoded> <wfw:commentRss>http://www.csskarma.com/blog/autocomplete-off/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Using .htaccess to Prevent Bandwidth Theft</title><link>http://www.csskarma.com/blog/preventing-bandwidth-theft/</link> <comments>http://www.csskarma.com/blog/preventing-bandwidth-theft/#comments</comments> <pubDate>Thu, 02 Apr 2009 15:29:26 +0000</pubDate> <dc:creator>Tim</dc:creator> <category><![CDATA[Security]]></category> <category><![CDATA[htaccess]]></category> <category><![CDATA[HTTP]]></category><guid
isPermaLink="false">http://www.csskarma.com/blog/?p=447</guid> <description><![CDATA[Every once in a while Google Analytics will turn up a peculiar behavior where you can tell someone is linking directly to an image hosted on your Web server. Sometimes it can be for good reasons like giving you credit for a project, or make sure files are synced up (cross-domain projects); but it&#8217;s usually [...]]]></description> <content:encoded><![CDATA[<p><img
src="http://www.csskarma.com/images/articles/bandwidth-theft.jpg" alt="article banner"/></p><p>Every once in a while Google Analytics will turn up a peculiar behavior where you can tell someone is linking directly to an image hosted on your Web server. Sometimes it can be for good reasons like giving you credit for a project, or make sure files are synced up (cross-domain projects); but it&#8217;s usually just out of ignorance or laziness (or myspace).</p><p>Either way, hotlinking images like that steals your bandwidth and can effect the performance of your server. So you want to stop it.</p><p>There are a few ways you can do this; some people output a special image to a bandwidth thief that says something like &#8220;Stop stealing my images&#8221;. I don&#8217;t like that mainly because you&#8217;re intentionally degrading your bandwidth to teach someone a lesson about hotlinking? Bleh.</p><p>I prefer using a 403 error, it works just as well in my opinion, and gets the point accross.</p><h5>.htaccess code</h5><pre><code>RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?csskarma\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]</</code></pre><p>Put that in your .htaccess file (in your root directory). If you don't have an .htaccess file, just create an empty file in the root and name it ".htaccess". Then put this code in there and you'll be good to go.</p><p>Don't forget to change out "csskarma" for your web site. You'll definitely notice if you forget that bit.</p><h4>What's going on</h4><p>Turn on the rewrite condition:</p><pre><code>RewriteEngine On</code></pre><p>Match any request for csskarma.com (NC means "no case" it will match upper or lower case requests):</p><pre><code>RewriteCond %{HTTP_REFERER} !^http://(.+\.)?csskarma\.com/ [NC]</code></pre><p>Allow empty requests, these are harmless and often 404 errors anyway</p><pre><code>RewriteCond %{HTTP_REFERER} !^$</code></pre><p>Replace the stolen image with a 403 "forbidden" error</p><pre><code>RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]</code></pre>]]></content:encoded> <wfw:commentRss>http://www.csskarma.com/blog/preventing-bandwidth-theft/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>Securing your Development Space</title><link>http://www.csskarma.com/blog/securing-your-development-space/</link> <comments>http://www.csskarma.com/blog/securing-your-development-space/#comments</comments> <pubDate>Mon, 15 Sep 2008 17:16:47 +0000</pubDate> <dc:creator>Tim</dc:creator> <category><![CDATA[Security]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[htaccess]]></category> <category><![CDATA[htpasswd]]></category><guid
isPermaLink="false">http://www.csskarma.com/blog/?p=90</guid> <description><![CDATA[You can hide your development space from the public many ways, a weird URL no one will find, use a local testing server (localhost), or set up a development server. Up until my last redesign I was just using a directory called dev under csskarma.com. And that was fine, but my file paths would all [...]]]></description> <content:encoded><![CDATA[<p><img
src="http://www.csskarma.com/images/articles/securing-your-development-space.jpg" alt="article banner"/></p><p>You can hide your development space from the public many ways, a weird URL no one will find, use a local testing server (localhost), or set up a development server. Up until my last redesign I was just using a directory called <strong>dev</strong> under csskarma.com. And that was fine, but my file paths would all have to be adjusted when I went live (not a huge deal, but annoying none-the-less).</p><p>If you&#8217;re a frequent reader, you might remember that in my last post I mentioned that I was coming out of laziness and cleaning up some stuff on my server. So I finally set up my dev server. It&#8217;s just a sub-domain, but seems to work well so far.</p><p>Not that I have anything on it. but I felt like I should use some best practice stuff and password protect it. In password protecting a directory, you use an .htaccess file coupled with an .htpasswd file (to store the usernames and passwords)</p><p>The first thing you need is a list of users you want to grant access to. Let&#8217;s say I want to set up a general account for people to access my directories. We&#8217;ll make the username <strong>guest</strong> and the password <strong>dontstaylong</strong>.</p><p>Next, we have to go to a site that will encrypt the password for us, I use <a
href="http://www.htaccesstools.com/htpasswd-generator/" rel="external">htpasswd generator</a>. After plugging in the username and password, you&#8217;ll come out with something like this:</p><h5>Your full .htpasswd file</h5><pre><code>guest:ZGu8x2pjH62Pk</code></pre><p>Take that code and place it in a file called .htpasswd (you&#8217;ll need to create this). You can put that file anywhere on your server, but it&#8217;s best to make sure it&#8217;s not web accessible (so no one can steal your password). So, if you have a public_html directory or a www, put the file one level higher than that.</p><p>Now that we have our .htpasswd file on our server, we can start cutting off access to various parts of our site using an .htaccess file. You can also add multiple users by following the same process as the first one, but put one user per line in the .htpasswd file.</p><p>Let&#8217;s say I have a directory at <a
href="http://www.csskarma.com/articles/htpasswd/">http://www.csskarma.com/articles/htpasswd/</a> that I want to password protect. To do that I would put an .htaccess file in that directory with this code in it:</p><h5>Your full .htaccess file</h5><pre><code>AuthType basic
AuthName "This directory is protected"
AuthUserFile /full_server_path_to_file/.htpasswd
Require valid-user</code></pre><p>Important: the AuthUserFile must be an absolute server path to the file, relative will not work (at least it didn&#8217;t for me).</p><p>Lastly, you visit your new <a
href="http://www.csskarma.com/articles/htpasswd/">password protected directory</a> (username: guest &#8211; password: dontstaylong) and marvel at your greatness. This password should apply to all sub directories as well.</p><p>In my experience, this is the easiest way to secure an area of your site. However, if you&#8217;re passing sensitive information through, you may want something a little more secure than this. Yahoo! provides a good <a
href="http://developer.yahoo.com/security/" rel="external">best practices security</a> write-up you can use as a reference.</p><p>Anyone have any thoughts/suggestions for beefing up the .htpasswd file?</p> ]]></content:encoded> <wfw:commentRss>http://www.csskarma.com/blog/securing-your-development-space/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 7/15 queries in 0.089 seconds using disk: basic

Served from: www.csskarma.com @ 2012-02-09 16:42:06 -->
