Wordpress Injection Attack

March 3, 2009

VN:F [1.9.3_1094]
Take a moment to Rate and Review this article:
Rating: 0.0/10 (0 votes cast)

March 4, 2009 Update: My plan has worked out very well and every­thing is back to nor­mal with­out too much of an inter­rup­tion. My request for Google site review took a total of 12 hours and it was com­pletely han­dled through Google Web­mas­ter Tools. Google spi­dered the entire site for about 6 hours check­ing every exist­ing page on the site from Moun­tain View Cal­i­for­nia. Around 6pm EST I was given a new notice in my Web­mas­ter Con­trol panel that the notice would be removed with the next update which took place about 90 min­utes later.

I’d like to thanks a few peo­ple who gave me some good advice. If this does hap­pen to you make sure that you:

  1. Remove any old plu­g­ins may have or update them.
  2. Ensure the source of the plu­gin is using best prac­tices for PHP cod­ing. If the plu­gin is not listed In the Offi­cial Word­press Plu­g­ins Direc­tory then be careful.
  3. Add the fol­low­ing plu­g­ins: WP Secu­rity Scan and Word­press Fire­wall (Thanks to Ruud Hein for the suggestion!).
  4. Backup your con­tent, themes, and plu­g­ins on a reg­u­lar basis so a roll back is easy in the event that you are attacked again.
  5. Be care­ful of who you send your site to on Twit­ter! See the end of the post for the offi­cial Twit­ter email I received and this was the source of the attack.
  6. This one is obiv­i­ous but make sure you Word­press ver­sion is cur­rent as many secu­rity fixes are imple­ment in point releases (ie 2.7.1).
  7. Secure you Web Server or have your Sys­tem Admin­is­tra­tor or Web Host ensure that every­thing is in order.

/Update.

I woke up this morn­ing ready to get to work and as per usual I check my sites indexes in Google, Yahoo and MSN. Even though it’s a beau­ti­ful sunny day out­side I was shocked to see the following:

Bad News for Tuesday MorningBad News for Tues­day Morn­ing to be sure. So the ques­tion is what do I do and how do I get this bad mes­sage off my Search Listing?

I’m not too con­cerned to be hon­est except for the fact that my site is vul­ner­a­ble to this injec­tion attack. I would love to smack the hacker that insti­tuted this attack.

So first things first:

What is this mes­sage all about? Well when I viewed the source of my site I saw what is called an obs­fu­cated injec­tion attack on the footer of every sin­gle one of my pages. This is a bit of a pain since I am using Word­press MU with a num­ber of plugins.

That means that  the hack­ers could have injected their lit­tle code block into my theme, my plu­g­ins into the core Word­press MU files. Not a pretty thought to have to go through all of those areas to remove these indi­vid­ual code blocks. Bot­tom line: my site got hacked. What steps do I take to repair the dam­age that’s been done?

Has your Word­press site ever been hacked?

View Results

Loading ... Loading …

My plan to remove the PHP injec­tion attack:

  1. Iden­tify which files on the web server are compromised.
  2. Iden­tify if the com­pro­mised files are plu­g­ins, com­ments, themes, or Word­press Core files.
  3. If the com­pro­mised file is a plu­gin then deter­mine if the plu­gin should be removed com­pletely (is it the source of weak­ness?) or sim­ply a vic­tim and should be reu­ploaded and reactivated.
  4. Upload a clean ver­sion of Word­press MU core files. This pre­vents me from hav­ing to wade through all of the com­pro­mised files.
  5. Go through com­ments and iden­tify any poten­tially mali­cious links to mal­ware sites. I am very lucky since I have recently moved the domain to a new server since my pre­vi­ous hor­ri­ble host dis­abled access to the php­MySQL instance through the cPanel (yes EMC Web Host­ing Sucks NEVER use them). This will not be a huge issue.
  6. Go through my theme which is a cus­tomized ver­sion of Rev­o­lu­tion Theme by Brian Gard­ner. I fre­quently backup this theme since it is a a sim­ple mat­ter  of upload­ing the theme to the web server.
  7. Visit Google Web­mas­ter Tools and sub­mit a request for Google to audit my site to remove the mali­cious tag­ging on my site.
  8. Audit the entire site to ensure the mali­cious code in com­pletely removed.
  9. Back up the theme again, ensur­ing I have the abil­ity to restore clean code in the event that I am on someone’s hack­ing list.
  10. Harden Word­press MU to ensure that this does not hap­pen again.

That’s my plan. I am about half way through it but there are some seri­ous issues at play here since it is not only Google which is tag­ging my site as mali­cious (bad for busi­ness!). Check out the num­ber of blocks which exist:

Google Mali­cious Message:

I'm not Malicious but Google thinks I am

I’m not Mali­cious but Google thinks I am so next step is to click on the SERP that’s when Fire­fox jumps in:

After clicking the SERP Firefox jumps in and says I am bad too!

After click­ing the SERP Fire­fox jumps in and says I am an attack site. How fas­ci­nat­ing but just wait. It’s not over yet when I get to the site:

Firefox toolbar warningFire­fox tool­bar warning

So clearly the pow­ers that be and the tools on my com­puter are work­ing hard to iden­tify mali­cious sites. It is very clear that this site could be mali­cious and even though it was through no intent on my part the bot­tom line is that my site was hacked and turned into an attack site. This is a good line of warn­ings to any user and in the time frame that I am repair­ing the site and hard­en­ing my Word­press to ensure this does not hap­pen again I don’t really mind hav­ing these mes­sages there.

They are good for users.

Update — Twit­ter just sent me the source of this injec­tion attack:

Uh oh! We found a bad apple in your Twit­ter feed.

We detected a link in your account point­ing to a phish­ing site or other harm­ful mate­r­ial that we iden­ti­fied as mal­ware. Here’s the trou­ble­some post:

“@BlogDuJour hey there try out my blog [ your unsafe link was here ] — I am in the process of redesign­ing now but should be back to nor­mal soon!“
March 02, 2009 22:07

We removed this update from Twit­ter. Please be mind­ful of oth­ers in the Twit­ter com­mu­nity, and post only safe links on Twitter.com.

Thanks! Twit­ter Support


Reblog this post [with Zemanta]
VN:F [1.9.3_1094]
Rat­ing: 0 (from 0 votes)

No related posts.

Comments

12 Responses to “Wordpress Injection Attack”

  1. Kimberly @ Small Business Marketing Blog on March 9th, 2009 12:04 pm

    Hi Dan,

    This has hap­pened quite a few times to us, as we have over 70 sites around the internet.

    What a pain…You can always tell because your tags are miss­ing when look­ing at the posts dashboard.

    I like to call it “rogue code”…Uhhh!

    We have done all the things you’ve sug­gested except installing Word­press Firewall.

    Also, I had never heard about the bad Twit­ter shar­ing before…Hmmm

    Thanks for this article!

    Kim­berly :)

  2. Dan Nedelko on March 9th, 2009 12:16 pm

    Hi Kim­berly,

    Thanks for the tip about the tags. I’ve also nar­rowed down the plu­g­ins as well and am much more care­ful about adding a plu­gin which I have not looked at in depth. Hope to see you back here soon and thanks for your input.

    - Dan

  3. Dan Nedelko on March 9th, 2009 12:38 pm

    Hey Kim­berly,

    Since you run quite a few Word­press blog maybe it would be use­ful for you to sub­scribe to my RSS feed. I have a series of use­ful arti­cles com­ing up that might inter­est you.

    Thanks
    Dan

  4. WuWu on March 12th, 2009 1:04 pm

    Very nice post, thanks!!!

  5. Dan Nedelko on March 12th, 2009 3:36 pm

    Thanks WuWu — glad you liked it. Hope to see you back soon!

  6. RaiulBaztepo on March 28th, 2009 4:27 pm

    Hello!
    Very Inter­est­ing post! Thank you for such inter­est­ing resource!
    PS: Sorry for my bad eng­lish, I’v just started to learn this lan­guage ;)
    See you!
    Your, Raiul Baztepo

  7. We Got Hacked… | aimusic.com [the official A.i. website] on April 5th, 2009 12:34 pm

    […] If you own a word­press site that got hacked and are try­ing to fig­ure out what to do, here’s a great arti­cle on how to solve it.  […]

  8. Maxxx on April 5th, 2009 1:46 pm

    Oh, it’s a use­ful page! Thanks for it. (-:

  9. Dave Yates on September 17th, 2009 6:27 am

    Good arti­cle. Hope it works!!

    I have a client’s site that has been get­ting filled up hid­den injected links in the footer for months. I am at my wits end with it. I have been through the code with a fine tooth-comb (I’m not a hard-core code mon­key, but I know my way around), I have deleted any num­ber of plu­g­ins, installed as many pre­ven­ta­tive plu­g­ins, I have changed every user­name and pass­word, done a com­plete rein­stall of WP …and guess what — the hid­den links keep com­ing back. Hope­fully these plu­g­ins will finally see them off.

  10. Dan Nedelko on September 17th, 2009 6:39 am

    Hey Dave,

    These should help alot — I’m also going to email you directly but you’ll want to look at the server con­fig. Years ago I had an account with Neureal, whose servers were hope­lessly out of date. No mat­ter what I did injec­tions kept hap­pen­ing. You might want to try out a new host or have them lock some things down.

    Espe­cially open­basedir restric­tions — add them — lock­ing that down removes some func­tion­al­ity but helps alot.

  11. Dave Yates on September 17th, 2009 8:16 am

    Hi Dan

    Thanks for this and for the email. I am onto the server con­fig advice now. Hos­rt­ing could be an issue — I use Heart in the UK. They are a bit ‘pile it high sell it cheap’, but the sup­port is good and they know what they are doing — I tend to think the prob­lem was of my own mak­ing. For those want­ing to learn, read on…

    His­tor­i­cally, the site was first put up some years ago when I was still mer­rily cre­at­ing sev­eral sites a day, full of enthu­si­asm for the ease and power of Word­Press. Whereas, these days I tend to change every­thing includ­ing the WP-admin folder name, most of the file names and always delete the admin user name straight away and oth­er­wise alter a lot of the out-of-the-box defaults, back then I did not.

    It is not so fea­si­ble to retro-fit some of those prac­tices unfor­tu­nately and once some nasty lit­tle germ has blown a hole in your instal­la­tion, pre­ven­tion doesn’t work any more and a cure can­not always be eas­ily found.

    Cau­tion­ary advice for every­one out there:

    1. Con­sider adding .htpasswd and .htac­cess pro­tec­tion to the wp-admin direc­tory.
    2. Try chang­ing the wp-admin folder name. See: http://wp123.info/modifications/change-wp-admin-folder-name/
    3. I would add the login lock­down plu­gin to Dan’s two excel­lent sug­ges­tions: http://wordpress.org/extend/plugins/login-lockdown/

  12. Wordpress Injection | Free Wordpress Themes on October 30th, 2009 9:55 am

    […] View Results Loading … […]

Join in on the Discussion! Comment Now: