RSS2.0 Feed button

"I went into a McDonald's yesterday and said, 'I'd like some fries.' The girl at the counter said, 'Would you like some fries with that?'"
Jay Leno

Sam Devol

Running with Scissors

Reading This

6 simple steps to hardening WordPress

Posted on September 16th, 2007
Published in Computers, Things, WordPress
Tagged with:

There are some basic steps you can take to help limit your exposure to malicious behavior directed at your WordPress blog. My intention with this article is not to make your website bullet-proof (if such a thing exists) but to cover the most common exploits/weaknesses. File and directory permissions have been discussed elsewhere but I’ll post a reminder about the basic rule-of-thumb: Set files to 644 and directories to 755. If you have to use less secure settings (for /wp-content/uploads/ for example) you don’t have a good host.

Failure to do the following doesn’t mean your blog will be hacked, it just means it’s more likely. So here we go:
..Cover your privates (or: “Nice knickers there!”)…

  1. Delete unnecessary files /wp-admin/install.php and /wp-admin/upgrade.phpaa
  2. Delete default post and commentaa
  3. Make it harder to reveal your SQL login info and help prevent users browsing where they shouldn’t: In your root directory (where wp-config.php resides) make sure there is a .htaccess file containing the followingaa:
    Options -Indexes
    DirectoryIndex index.php index.html

    Order Deny,Allow
    Deny from all

  4. Change permissions for wp-config.php to 600 (equivalent to rw——-) if possibleaa
  5. Prevent browsing of directories not covered by WordPress: Drop an empty (0-byte) file named index.html in /wp-content/plugins/ or /wp-content/uploads/ (for example)aa
  6. For SPAM prevention, activate Akismetaa (comes with WordPress) and install/activate Bad Behavioraa These two plugins are the minimum in spam prevention in my opinion, but feel free to experiment on your own.

Other considerations for security are your choice in a host. I recommend a professional:
Site5 $5 Hosting Deal

As always: Feedback welcome!a

  1. Once you are finished with the installation or upgrade these files will not be needed and they will be replaced with your next install/upgradeaaa
  2. advertises “New Blog! Come SPAM me!”aaa
  3. Turns off ftp-style browsing;Only recognize index.php index.html as legitimate index files;Don’t allow ANY remote access to wp-config.phpaaa
  4. One of the few exceptions to the standard 644 ruleaaa
  5. The reason we use .html instead of .php is in case PHP breaks on the server we’re still covered at the HTTP levelaaa
  6. Akismet is great at weeding out spam commentsaaa
  7. Bad Behavior stops a lot of spam/malicious-activity before it ever hits your siteaaa

a

Related Posts:

11 Users Commented on " 6 simple steps to hardening WordPress "

Subscribe to these comments Comment RSS or TrackBack URL
J. Pisano says,
9-19-2007 at 20:59:31 from 72.23.224.5    

Sam,

Love the new look of your site!

Regards,

J. Pisano -mustech.net

Sam says,
9-19-2007 at 21:28:58 from 70.110.130.185    

Thanks Joe! I was going to post about it but caught up in tweaking, etc., etc.

Turned off no-follow too (don’t know why I didn’t do that earlier).

Martin says,
9-30-2007 at 12:30:57 from 82.5.224.124    

thanks for this, i have just completed all the steps you listed except for step 3.

could you tell me exactly where i should insert the following in the htaccess file?

Options -Indexes
DirectoryIndex index.php index.html

Order Deny,Allow
Deny from all

Sam says,
9-30-2007 at 13:01:55 from 70.110.189.135    

Hi Martin:

Here’s a copy of my current .htaccess file sans gzip and a php5 AddHandler:

Options -Indexes
Options +FollowSymLinks
DirectoryIndex index.php index.html

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress


Order Deny,Allow
Deny from all

Martin says,
10-1-2007 at 05:59:28 from 82.5.224.124    

thanks Sam, i have added it to my htaccess.

senlin says,
12-29-2007 at 04:39:14 from 125.33.14.61    

Thanks for the great “tutorial” :)

4-3-2008 at 22:52:12 from 72.189.107.67    

With that htaccess file above, can I just add the bottom part starting at and be a bit more safe?

Tommy says,
5-21-2008 at 20:09:50 from 59.173.84.71    

Nice tutorial for who is new to WordPress.

6-17-2008 at 14:54:58 from 87.158.157.85    

Thanks, i usually use mod_security to gain maximum security for any site…but .htaccess and other tools are always welcome…nice mini tutorial, with easy doable steps….cheers mate.

Geoff says,
7-21-2008 at 13:08:34 from 86.141.181.5    

Are there any tools that can automatically check to see if the WP installation has had any extra spam files added etc. One of my sites has been delisted at google because somehow 4152 spam url’s / files had been added in the wp-includes/js/tinymce/themes/advanced/images/xp/ directory.

It would be neat if there was a diff function from the known good WP to the installed WP also some sort of recursive keyword search on the whole installation would be good.

Trackback & Pingback
9-30-2007 at 04:13:26 from 83.137.96.22    

Leave Your Reply Below

 Username

 Email Address

 WebsiteI follow icon

About The Site

myimg

Observations of a Troubleshooting Monkey and

ex IT Director

ex Digital Video Director

ex Missile Mechanic

ex Motorcycle Mechanic

Work Background Contact me