Late on Friday, I read a post from Allen Stern in FriendFeed saying that his blog, CenterNetworks had been, once again, injected with spam links. Allen runs his blog on the latest WordPress installation, 2.8.4, which we all figured was really secure.
I had upgraded barely a week ago, so I instantly checked my blog and lo and behold, I had been hacked as well.
There is something inherently wrong with WordPress’ code if it’s this easy to hack it, even with the tightest security measures, which in my case, include the top 5 of the 7 items listed below. I felt completely let down by WordPress and for a moment thought that it’s time for me to move on to something else for my blog.
I am giving WordPress a last chance, and have enforced the following security measures to see how it goes, and I highly recommend you enable these as well if you are running WordPress.
So here’s the list:
- Use a strong admin password and change it to something else that’s not ‘admin’. WordPress will let you know how strong your password is. Do not leave the password form without seeing a green indicator and the word “Strong” in it.
- Do not use FTP. It sucks, especially for the easy upgrading, but leaving FTP port open on any server is an invitation to easy hacking. Use SSH only to get into your server.
- Do a search on your blog for possible backdoors that are left usually on theme directories (and sometimes in the WordPress core files). To do this just type ‘grep -rin “eval(base64″ path-to-blog/*‘ or download your blog files to a local Windows/Mac machine and use a text search tool. There’s also a tool called WP Security Scan that might work for this purpose.
- Check your blog often with my spamcheckr tool. Even though I’m eventually going to write an automatic monitoring tool, for now just use it once a week to make sure you’re not hacked.
- When hacked, always start with a clean install. Do not copy files from your previous attacked folder. The only safe thing to do is to copy your images and that’s it. Install WordPress and the necessary plugins from scratch.
- If possible, close your wp-admin directory to specific IPs. This one comes from Matt Cutt’s blog and it doesn’t make sense if you are always accessing your blog from different sites. But if you usually login from home and work, create an .htaccess file on your wp-admin directory with the following text (this will only allow you to open your admin panel from the specified IP’s:
AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName “Access Control”
AuthType Basic
order deny,allow
deny from all
# whitelist home IP address
allow from xx.xx.xx.xx
# whitelist work IP address
allow from xx.xx.xx - Only make wp-content/uploads writable by Apache. Make everything else (including your themes) only writable by your SSH user. You don’t need to edit your themes everyday, right? So when you do need to edit your themes, just SSH in and change the ownership while you work on them and then protect them again. That way you’re guaranteeing that hackers won’t be able to rewrite your themes from the WordPress Dashboard if they manage to get in.
There are many other security guides out there, but I think these seven should be enough to protect blogs from 99% of the attacks out there.
I promise I will edit this post when and if I get hacked again, so that this guide stays on air only if it’s proven effective to deter these pests from our blogs. If it doesn’t, it means WordPress has had its time, and we might need to move to something more secure.
{ 2 trackbacks }
{ 30 comments… read them below or add one }
WordPress 2.8.4 is secure, there’s no known holes in it yet. That said, if somebody gets a password… I’ve seen spyware specifically designed to sniff FTP passwords from the local computer, and somebody once forwarded me an interesting script kiddie tool that could take a list of sites and FTP passwords and then autohack WordPress websites with nothing more than that. WordPress doesn’t have to be insecure for them to get in, there’s other ways as well.
This comment was originally posted on FriendFeed
More from author
I think now should also consider other options available for blogging platforms
This comment was originally posted on FriendFeed
More from author
I think now should also consider other options available for blogging platform
This comment was originally posted on FriendFeed
More from author
agree with Otto, people keep their passwds saved in browsers, ftp clients
This comment was originally posted on FriendFeed
More from author
TestBeta: True, but having more choices is good.
This comment was originally posted on FriendFeed
More from author
TestBeta: True, but having more choices with good.
This comment was originally posted on FriendFeed
More from author
choices are always a good idea
This comment was originally posted on FriendFeed
More from author
choices ae always a good idea
This comment was originally posted on FriendFeed
More from author
@Otto — the server I host the blog at has no FTP access to it, so the only thing I can think of is 1. An HTTP sniffer (I do enter my credentials to wp-admin via clear HTTP and not HTTPS) or 2. A new type of backdoor (I did a search on the attacked installation and couldn’t find any base64 snippets)
This comment was originally posted on FriendFeed
More from author
Jorge: I recently saw a rather interesting backdoor hidden after a site got hacked. Try searching all files on the system for "strrev", see what pops up. WordPress does contain it, but only in a few places (no more than 6-8 or so). Alternatively, search the database for the text "edoced_46esab". The PHP code to run it was hidden in the wp-content/uploads directory, in a file called "wp-cache.old".
This comment was originally posted on FriendFeed
More from author
Jorge: I recently saw a rather interesting backdoor hidden after a site got hacked. Try searching all files on the system for "strrev", see what pops up. WordPress does contain it, but only in a few places (no more than 6-8 or so). Alternatively, search the database for the text "edoced_46esab".
This comment was originally posted on FriendFeed
More from author
I didn’t have any wp-cache.old, but I did get some strrev references. I pasted here: http://etherpad.com/zst3X1w7Nb
This comment was originally posted on FriendFeed
More from author
Whammo! I find these highly disturbing: wp-content/plugins/subscribe-to-comments/extras/.subscribe-to-comments.old.php and wp-content/images/email.bak . Both of those look suspicious to me. Post their contents over on wordpress.pastebin.com so I can see them. I’ll lay odds that there’s also a malicious entry in your wp_options table, from examining the files I can tell you what it is.
This comment was originally posted on FriendFeed
More from author
Whammo! I find these highly disturbing: wp-content/plugins/subscribe-to-comments/extras/.subscribe-to-comments.old.php and wp-content/images/email.bak . Both of those look suspicious to me. Post their contents over on http://wordpress.pastebin.com (and then post the link back here) so I can see them. I’ll lay odds that there’s also a malicious entry in your wp_options table, from examining the files I can tell you what it is.
This comment was originally posted on FriendFeed
More from author
I have pasted 3 (I found a new suspicious one called .readme.bak on the subscribe-to-comments plugin folder). .readme.bak: http://wordpress.pastebin.com/d3fabc9fb, subscribe-to-comments.old.php: http://wordpress.pastebin.com/d795009b8, email.bak: http://wordpress.pastebin.com/m413c7152 — thanks Otto!
This comment was originally posted on FriendFeed
More from author
Jorge: Look in the wp_options table for a row with a key of "rss_f541b3abd05e7962fcab37737f40fad8". Remove it. It’s almost certain to contain (reversed) malicious code (look for the "edoced_46esab" like I said before in the value column).
This comment was originally posted on FriendFeed
More from author
Yep, found it and deleted it. I see a bunch of records similar to this one with "Magpie". What is this table supposed to do?
This comment was originally posted on FriendFeed
More from author
Options holds lots of stuff, the rss_ entries are caches for the feeds displayed in the main dashboard area.
This comment was originally posted on FriendFeed
More from author
wow :(
This comment was originally posted on FriendFeed
More from author
That’s what I said!
This comment was originally posted on FriendFeed
More from author
great post otto – i will link it up when/if i make an update post.
This comment was originally posted on Nothing to see here
More from author
7 Tips to Secure WordPress 2.8.4 http://bit.ly/7k6gc by @jungleg
This comment was originally posted on Twitter
More from author
Feeling secure with WordPress 2.8.4? Think again. http://icio.us/mdgb3e
This comment was originally posted on Twitter
More from author
Feeling Secure with the Latest WordPress Version? Think Again (and 7 Tips to Secure it)
[ jungleg.com ]
.. http://bit.ly/FSJE9
This comment was originally posted on Twitter
More from author
Liked “Feeling Secure with the Latest WordPress Version? Think Again (and 7 Tips to Secure it)” http://ff.im/-8tQ7L
This comment was originally posted on Twitter
More from author
Hey, thanks for sharing. That’s probably less work than clearing that stuff of an successful attack…
This comment was originally posted on Nothing to see here
More from author
Great site, how do I subscribe?
More from author
Before switching to 2.8.4, our site was compromised. The @*%$! spammers deployed two files to our system /wp-admin/fotter.php and /wp-admin/inclode.php (note the purposeful misspellings). These were encrypted files that were web-based backdoors. These were causing our theme footer to be overwritten nightly.
This comment was originally posted on Nothing to see here
More from author
great post, let me wonder about potential ways to avoid – at least – some hack attemps. first one: deny via htaccess any GET querystring with, let’s say, base64 or 46esab (actually, who need them?). second one: a little plugin that looks around for the same things in POST queries.
Just thougths, of course. But cleaning is so boring…
This comment was originally posted on Nothing to see here
More from author
News Update: Feeling Secure with the Latest WordPress Version? Think Again (and 7 Tips to Secure it) – jungleG http://ow.ly/15TBac
This comment was originally posted on Twitter
More from author