Post image for Feeling Secure with the Latest WordPress Version? Think Again (and 7 Tips to Secure it)

Feeling Secure with the Latest WordPress Version? Think Again (and 7 Tips to Secure it)

by Jorge Escobar on September 21, 2009

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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
  7. 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.

21 Comments 6 Tweets 4 Other Comments

{ 2 trackbacks }

How to find a backdoor in a hacked WordPress
September 21, 2009 at 4:14 pm
Otto on WordPress » Blog Archive » How to find a backdoor in a hacked WordPress
March 4, 2010 at 5:28 pm

{ 30 comments… read them below or add one }

Otto September 21, 2009 at 1:20 pm

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

Reply   More from author

sunny kapoor September 21, 2009 at 1:31 pm

I think now should also consider other options available for blogging platforms

This comment was originally posted on FriendFeed

Reply   More from author

sunny kapoor September 21, 2009 at 1:31 pm

I think now should also consider other options available for blogging platform

This comment was originally posted on FriendFeed

Reply   More from author

testbeta September 21, 2009 at 1:40 pm

agree with Otto, people keep their passwds saved in browsers, ftp clients

This comment was originally posted on FriendFeed

Reply   More from author

sunny kapoor September 21, 2009 at 1:42 pm

TestBeta: True, but having more choices is good.

This comment was originally posted on FriendFeed

Reply   More from author

sunny kapoor September 21, 2009 at 1:42 pm

TestBeta: True, but having more choices with good.

This comment was originally posted on FriendFeed

Reply   More from author

testbeta September 21, 2009 at 1:58 pm

choices are always a good idea

This comment was originally posted on FriendFeed

Reply   More from author

testbeta September 21, 2009 at 1:58 pm

choices ae always a good idea

This comment was originally posted on FriendFeed

Reply   More from author

Jorge Escobar September 21, 2009 at 2:01 pm

@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

Reply   More from author

Otto September 21, 2009 at 2:14 pm

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

Reply   More from author

Otto September 21, 2009 at 2:14 pm

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

Reply   More from author

Jorge Escobar September 21, 2009 at 2:53 pm

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

Reply   More from author

Otto September 21, 2009 at 3:03 pm

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

Reply   More from author

Otto September 21, 2009 at 3:03 pm

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

Reply   More from author

Jorge Escobar September 21, 2009 at 3:26 pm

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

Reply   More from author

Otto September 21, 2009 at 3:34 pm

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

Reply   More from author

Jorge Escobar September 21, 2009 at 3:37 pm

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

Reply   More from author

Otto September 21, 2009 at 3:43 pm

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

Reply   More from author

Allen Stern September 21, 2009 at 3:52 pm

wow :(

This comment was originally posted on FriendFeed

Reply   More from author

Jorge Escobar September 21, 2009 at 3:53 pm

That’s what I said!

This comment was originally posted on FriendFeed

Reply   More from author

Allen September 21, 2009 at 4:52 pm

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

Reply   More from author

Webdesigner from Berlin September 25, 2009 at 1:35 am

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

Reply   More from author

Kelli Garner September 25, 2009 at 11:22 pm

Great site, how do I subscribe?

Reply   More from author

Lon September 29, 2009 at 10:02 pm

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

Reply   More from author

p October 1, 2009 at 8:54 pm

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

Reply   More from author

Leave a Comment

Additional comments powered by BackType

Previous post:

Next post: