Breaking: Google starts to block hacked WordPress blogs as attack widens

Big News [April 24th, 2012]: I’ve launched Wordfence to permanently fix your WordPress site’s security issues. Click here to learn more.

I’ve had two reports in the last 12 hours of WordPress blogs that were compromised via the Timthumb hack being listed as malware by Google. If you try to visit either site, you are confronted with the following:

 

These sites are listed with the warning that “This site may harm your computer” in Google’s search results and Google blocks access to the site with a warning forcing you to manually type the URL into your location bar if you really do want to visit the site:

One of the site owners sent me the detailed info that Google Webmaster Tools was giving her:

This malicious code is appearing intermittently on this author’s WordPress site. I’ve seen this same pattern recently in blogs I’ve repaired and the way it works is that the site is periodically downloading new PHP code from a remote site run by the attacker and re-injecting it into the wordpress code. That allows the attacker to add, remove and update whatever code he/she is executing on your blog. So they could for example update any spam links every few hours.

To prevent your site being listed as malware clean it as fast as possible

The fastest way to do this, although it doesn’t gaurantee a complete clean, is the following:

  1. Remove all old plugins and themes you aren’t using.
  2. Upgrade all your plugins and themes to the latest versions and make sure none of them use an old version of Timthumb.
  3. Clean any Timthumb cache directories.
  4. Upgrade your entire wordpress installation, even if it’s at the latest version. This overwrites all wordpress files.
  5. Search your directory tree for any remaining suspicious files that contain base64_decode wrapped in an eval() statement or URL encoded data. More info on how to do this search here. Delete any files you find. NOTE: If you don’t find any additional infected files in this step, it’s highly likely that your site is not clean. Every attack that I’ve seen so far using Timthumb gets in by uploading a file into the cache directory and then uploads an additional file into a writeable directory on the blog to ensure continued access once the cache is cleaned. Make sure you find that additional file.
  6. Make sure the only directory that is writeable in your wordpress installation is wp-content/. Directories like wp-admin and wp-includes should be read only by the web server.

If you are already listed as malware by Google, here is what to do

Clean your site using the above steps. You can find more suggestions on how to clean your site on this page.
The fastest way to get your site removed from Google’s malware list is to request a review through Google Webmaster Tools. You can find the help file on requesting a malware review on this page.
The process takes about 24 hours to get your site removed. You can find out more about Google’s Malware list and safe browsing report on this page.

 

Potential long term impact of this vulnerability

The fact that I’ve seen the same domain being used by attackers on multiple blogs suggests this attack may be partially or fully automated. The worst case scenario is that we end up with a WordPress botnet with thousands or tens of thousands of servers on high bandwidth links compromised and able to send spam emails or launch a huge DDoS attack.

Keep in mind that most botnets are compromised windows machines on relatively slow home broadband connections. Their uplink speeds are around 512kbps. These WordPress servers are on links that are a minimum of 10 Megabits per second each, so they have plenty of firepower for a coordinated attack. One WordPress server is equal to at least 20 infected PC’s in terms of pure bandwidth firepower.

 

26 thoughts on “Breaking: Google starts to block hacked WordPress blogs as attack widens

  1. I had deleted swift theme which uses timthumb but when i checked my wp content folder, I found timthumb files inside the upload folder.

    It seems if you have used a vulnerable theme before, the timthumb files are left behind even after deleting the themes.

  2. Everyone has such great suggestions.

    @ David Dede – Just tried your scanner, great tool. $90 for a year is pretty reasonable considering how much downtime would cost a company dependent on their website for business.

    @Vid – great trick!!!! I would have been just running a search.

  3. its all messed up, my site went down completely now cant even access it, hackers enjoy this , as its for fun they prove they are better than wordpress guys, this is pathetic, the wordpress guys better workout something fast, before all the sites go down and google blacklists it.damn

    • Joe,
      Not all hosts use mod_security, but other things host can do are..

      1. block outgoing requests from the firewall (we did this)
      2. block remote fopens

      There are many ways to skin this cat, as long as it gets skinned is the goal :) .

  4. If you don’t (or are not allowed to) use Perl on your server, in FileZilla there is a function to do a ‘remote search’ (under the binoculars on the menubar). Do a search for ‘tim’ (just to be sure) and see what it comes up with. It is not very fast, but you can run it in the background, as it displays a list with results.

    In general, here are some tips to secure your blog: http://www.hongkiat.com/blog/hardening-wordpress-security/
    And, for complete backups: http://www.blogvault.net (I can not tell if they scan/detect, so you need to check before your restore your site).

    Thanks for the instructions! I have shared it on G+.

  5. A further suggestion on hardening your site: in addition to making all files and directories outside of wp-content non-writeable by the server, wouldn’t it be a good idea to additionally write-protect all the PHP files *inside* wp-content as well? Let’s say you have the owner of the files as www-data and the group as your user, for convenience; then executing
    sudo chmod u-w wp-content/*.php
    and
    sudo chmod u-w wp-content/*/*.php
    and
    sudo chmod u-w wp-content/*/*/*.php
    and so on (however many layers deep as are needed, and of course executed from the WP root) could prevent the malware from getting a toehold. That is, even if they somehow inject a page with malicious code amongst your nicely cleaned PHP files, it won’t be able to do anything to modify your files, and that should stop the infection until a routine scan can weed out the intruder.

    P.S. I just gotta say, I am SO glad I usually develop with Python in Django and Pinax……….

  6. sry for the dbl comment but I just saw Vid’s suggestion and was wondering if that changes all instances of thmthumb everwhere it is including in the txt of files like functions or just swaps the file to the new safe one? Do we still need to go in and change all the fixed_timthumb.php back to just timthumb for it to work properly?

  7. This message was exactly what alerted me to the problem last Friday. Google must have has been doing it since at least then. Thanks to your posts, I updated my timthumb scripts and scrubbed all the suspicious base64 calls out. I never found an entire suspicious file though, so, I should go back and check. hopefully nothing has “respawned” because I didn’t clean it completely last time.

    Thanks for the info!

  8. My site was hacked through timthumb and it looks like it was all automated..

    I had these files in the compromised theme folder:
    wp.php – the phpshell
    sm3.php
    r1.php
    d.php

    and a changed .htaccess file that pushed all inbound traffic from a list of search engines to a russian site on hitting my site.

    Seems that the mail server was also being used to send out spam and then loads of the emails have bounced back and I can see the content of them – it seems that they are all linking to an sm3.php on other compromised blogs in each email, like a massive automated spam making worm.

    I have hundreds of bounce backs – each with different domains. Many with wp.php still installed on them. These are all sending emails too.

    I’m also getting loads of inbound http requests looking for sm3.php in my theme folder, which is not there anymore so it’s returning a 404 but I’m getting like at least 1 request a minute and this all counts to my bandwidth.

    I guess the only way it will stop is if everyone realises they have been hacked and they tidy up their sites.

    What a massive problem!

    p.s. sorry for the big comment but thought it might help some people.

    Cheers for all the info on your blog too.

    • Thanks David. I ran your scanner on my site and a known infected site as comparison. It shows the site is listed as malware with Google but not that it’s currently running infected code. The attack periodically updates the site with a new payload. For some reason the attackers seem to remove the spam links and reinject them a few hours later, periodically. So the tool seems great, but just want folks to keep in mind that a local filesystem scan is the only sure way to tell if you currently have malicious code running on your site.

  9. Mark and others reading this.. if you host a couple of thousand wordpress sites like us, here’s a quick brute force way of at least making sure you don’t have the vulnerable timthumb on your sites.

    1. Copy the latest timthumb from google code on to your server and called it fixed_timthumb.php
    2. cd /
    3. find . -name timthumb.php | xargs -i cp /your/brand/new/fixed_timthumb.php {}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.