Ask WordPress Girl

Custom themes, tips, classes, and resources
  • Facebook
  • Feedburner
  • Google
  • Linkedin
  • Pinterest
  • Twitter
  • Home
  • Hosting
  • Security
  • Installing
  • Customizing
  • Plugins
  • Links
  • About
Home / Security / TimThumb WordPress Security Vulnerability

TimThumb WordPress Security Vulnerability

August 30, 2011 / Angela / Security / 2 Comments

Zero Day Vulnerability in Many WordPress Themes


TimThumb is a popular image resizing utility used on millions of sites worldwide. It is inherently vulnerable because it allows hackers to upload and execute arbitrary PHP code in your timthumb cache directory.

To prevent this from happening, it is urgent that you either update your TimThumb script to the latest version, remove it or edit it and set the $allowedSites array to be empty.

I already know several people whose sites have been hacked from this vulnerability. My WordPress Firewall plugin alerts show that robots are surfing the net and targeting all WordPress sites looking for this script to exploit. It does not matter that your site is unpopular or receives no visitors or that the theme containing it is not active. Hackers don’t care if you don’t use your site any longer. If you have this script, you will likely get hacked sooner or later.

How do you know if you are at risk?

1 – First, login into your site using your FTP application or SSH (SSH instructions here).

2 – Check ALL the files in your themes folder on your server to see if you have any file named timthumb.php or thumb.php (different theme developers named this differently).

3 – Open the file in your html editor and look for

* TimThumb script created by Ben Gillbanks, originally created by Tim McDaniels and Darren Hoyt
* http://code.google.com/p/timthumb/

If that is in the file, then you are looking at the correct file.

Here are a list of free themes on the wordpress.org site that contain(ed) this script: http://blog.sucuri.net/2011/08/timthumb-security-vulnerability-list-of-themes-including-it.html

Also, all Elegant Themes downloaded prior to August 2011 contain this script. Elegant Themes has updated all of their themes to no longer use this script.

How do you fix it?

One simple fix that will keep your Timthumb script updated easily and quickly is to install the Timthumb Vulnerability Scanner plugin: http://wordpress.org/extend/plugins/timthumb-vulnerability-scanner/

If you want to update it manually, use the following process. Keep in mind that there have been a couple updates to Timthumb since the original vulnerability was discovered, so you may have to update this again.

1 – Go to http://timthumb.googlecode.com/svn/trunk/timthumb.php and copy all of the code on the page.

2 – Open your theme’s timthumb.php file and delete the content. Paste the code you just copied into it.

3 -Next, set allow external sites to false. This will prevent image fetching from external sites.

if(! defined('ALLOW_EXTERNAL') )         define ('ALLOW_EXTERNAL', false);            // Allow image fetching from external websites. Will check against ALLOWED_SITES if ALLOW_ALL_EXTERNAL_SITES is false

4 – Next scroll to the top of the file and start to slowly scroll down until you see an area that says $allowedSites.  Remove all of the sites listed in the array:

Before:

$allowedSites = array (
'flickr.com',
'picasa.com',
'blogger.com',
'wordpress.com',
'img.youtube.com',
'upload.wikimedia.org',
'photobucket.com',
);

After:

$allowedSites = array (

);

5 – Save and upload the file.

6 – Repeat for ALL timthumb.php files found on your server, even the ones for themes you are not using.

Note: If you are not using the theme, then you should probably remove it from the server. Also, do NOT leave a backup of the OLD timthumb.php file on your server. If you want to keep a backup, then store it on your local computer, not on the server.

More Information and Resources

  • Scan your site at http://sucuri.net
  • Read more about how this vulnerability was discovered at: http://markmaunder.com/2011/08/01/zero-day-vulnerability-in-many-wordpress-themes/
  • Subscribe to WP Security Lock to stay on top of the latest WordPress Security issues: http://www.wpsecuritylock.com/
  • Install the WordPress Firewall Plugin: http://wordpress.org/extend/plugins/wordpress-firewall-2/

Share this:

  • More

2 comments on “TimThumb WordPress Security Vulnerability”

  1. ChrisR says:
    October 10, 2011 at 7:44 am

    My theme, Gridnik, uses a custom widget dependent on timthumb to pull and resize images from my Flickr photostream. So if I disallow remote images, no photos in my widget. What code could I use to replace use of timthumb for Flickr?

    Reply
    • Anonymous says:
      October 10, 2011 at 11:17 am

      Hi Chris,

      You should probably go into the code of the theme to find where the timthumb script is actually located and replace it with the new timthumb from Google. I see that support for this theme has been discontinued, so you might want to shop around for a new, more active theme to use, because it’s possible you’ll encounter problems later down the road since the theme is no longer being updated.

      Reply

Leave a Reply Cancel reply

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 34 other subscribers

Upcoming Classes

with Ask WP Girl

  • Customizing WordPress Themes

    February 18-March 6, 2013
    Hands On Intensive

  • WordPress – Essential Plugins

    March 20 or June 6, 2013

  • WordPress Security and Backup

    April 15, 2013

  • WordPress – Creating Image Galleries

    Summer 2013 (tba)

Share this:

  • More

Share this:

  • More

Recent Posts

  • How to Protect Your Site from the Botnet Hack

    April 13, 2013
  • Create an Image Gallery in WordPress Using a Lightbox Plugin

    February 7, 2013
  • Fancy Borders for NextGEN Gallery Galleries

    November 9, 2012
  • Gravity Forms Placeholder Text that Works with IE

    January 20, 2012
  • Moving WordPress from Subdirectory to Root – FAQ

    November 19, 2011
  • Customizing Studio Press Child Themes

    September 5, 2011
  • TimThumb WordPress Security Vulnerability

    August 30, 2011
  • 25 Top WordPress Plugins You Should Know About

    August 2, 2011
  • How do I move WordPress from a subdirectory to the root directory?

    January 25, 2011
  • Finding a Web Host and Installing WordPress

    January 6, 2011

Categories

  • Answers to Your Questions
  • Customizing
  • Getting Started
  • Hosting
  • Installing
  • NextGen Gallery
  • Plugins
  • Resources
  • Security
(c) 2013 Ask WP Girl - Angela Bowman
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.