WordPress Security Alert – TimThumb Image Resizing Script

In: WordPress

9 Aug 2011

WordPress Security Issue wIth Timthumb

In recent days a significant WordPress security threat has emerged. The root of it is the ability for unsavory types to compromise a very common image resizing script called TimThumb which is used in many WordPress themes and plugins. Through a security flaw, hackers can find a way into your site and cause havoc. Or, in more specific terms according to Vaultpress:

“The vulnerability allows third parties to upload and execute arbitrary PHP code in the TimThumb cache directory. Once the PHP code has been uploaded and executed, your site can be compromised however the attacker likes.”

Are you at risk?

The list of themes and plugins that use this script is too long for any one source to have catalog-ed as yet. Securi has a partial list here. In my own researching I’ve found several major theme vendors to be vulnerable (WooThemes, Themify.me, Headway) although they have acted quickly to update their themes.  WebSite defender has a list of plugins and themes they know to be using timthumb.

If your theme uses multiple sizes of the same image in different parts of your site, such as thumbnails,based on one image you’ve uploaded into a post or as a featured image, it could be using the timthumb script to generate the other sizes.

If you’re using a plugin that generates different image sizes, for use in, for example a list of recent posts with a thumbnail image – this plugin could be using timthumb.

How to check if your theme uses TimThumb

1) The easy, but not foolproof way

In your WordPress admin, go to the Appearance menu and click on Editor. Look in the list on the right for a file called either timthumb.php or thumb.php – this is generally what most themes call this file. This will let you know if your current, active theme uses timthumb. However, if you have other themes installed, but are not active, you will have to select those from the drop-down menu and check them one-by-one.

It is entirely possible a theme creator is using the script but just named the file something else such as img.php, thumbnail.php etc. So to be sure, you can open any file you come across that you suspect may have something to do with image resizing, and at the top you may see something like this:
TimThumb script created by Ben Gillbanks, originally created by Tim McDaniels and Darren Hoyt

This lets you know that it’s the same timthumb script, regardless of the filename and so the fix still needs to be applied.

2) The super-novice way

Another way you can check is to right click on an image on your site (one that you think could be being automatically generated by a theme or plugin). Copy the image url into a text doc or your broswer and look at the whole thing. Do you see something like this in the url:

thumb.php?src=

or

timthumb.php?src=

click image below for full size:
timthumb security flaw wordpress
If so, that means your theme is using the script to resize that image and you must take the security steps below.

3) The only way to know for sure

Additionally there are cases where a theme could include the script in a subfolder which would NOT show up in the WordPress theme editor. For example, in the Headway Theme, they named the file thumbnail.php and it’s about 2 subfolders deep so you only see it via FTP. Fortunately they issued an update to the theme in the past few days which addresses the issue.

So the only way to know for sure is to thoroughly review your theme files using the FTP File Manager in your hosting account, or an FTP program.

What should you do if your site is at risk?

1) Check if your theme provider has handled the issue.

If your theme has issued an update in the past few days it could well be to take care of this issue – check the details of the update and if it’s related then update your theme immediately. Visit the website of your theme vendor and check their blog and support forums for information on the topic. If in doubt, send them an email. WPMU has a note on some of the major theme shops and how they have handled the issue.

A note about Thesis – this popular theme does use a version of the TimThumb script but it does NOT include the ability to use images from external sites (which is where the security flaw is), so unless you’ve hacked this script yourself, Thesis users should be fine.

I noticed that themes from Themify.me are vulnerable and they have issued updates to their themes, but the strange thing is that they don’t seem to push the update to the user by way of a notification – you actually have to check your version of the theme with their website to see if you have the latest, and then go and download and re-install the newly updated theme – not very convenient.

2) Fix It Yourself

An updated and secure version of TimThumb has been released so you can fix the issue yourself by replacing the old version in your theme with the new code. You can download the newly updated version here:
http://code.google.com/p/timthumb/

If you are using the WordPress editor and have located the old version of timthumb there, you can simply copy the code from the new file above and replace everything in the old file.  You can also do this via FTP if you know how to use it.

For extra security make sure that the line of code allowing access to external images is set to false, not true. It should look like this:

define( 'ALLOW_EXTERNAL', false );

Secondly look for this code:

$allowedSites = array(
'flickr.com',
'picasa.com',
'img.youtube.com',
);

Replace it with this code:

$allowedSites = array();

3) Clean up your site
If you have old themes that you’re not using sitting on your server that may be using the script, you should either update them all or just delete them.

If you need help locating or fixing a vulnerability please let me know.

 

** header image courtesy: http://www.flickr.com/photos/mamchenkov/302301657/

I hope you found this post useful. If you enjoyed it, consider signing up for updates via email (includes a free SEO ebook). I help entrepreneurs and businesses learn how to use WordPress - with patience and hand-holding, I turn technophobes into technopros. I also help businesses develop an effective online marketing strategy and compelling web presence.

If you enjoyed this post, I'd be thrilled if you clicked one of these buttons!:


1 Response to WordPress Security Alert – TimThumb Image Resizing Script

Avatar

Chris Raymond

October 10th, 2011 at 7:00 am

You should know that if you wish to show your Flickr stream on your blog, you can't disallow external sites, and MUST include Flickr in the array of allowed sites.

Comment Form

How I Can Help You

Hi! I'm Lucy Beer. I believe that technology is liberating when you know how to use it, and bewildering when you don’t. That’s where I come in. I help non-techies understand and use the web to empower their personal or business mission. Whether you need to build a website, optimize your existing site, or create a marketing strategy that works, I'll help you understand, in plain English, what you need to do to achieve your goals. Don’t let lack of technical know-how hold you back! I’ll lead you on a clear, practical path that you can master, without the confusing geek-speak. Find out more.

Are you in the Los Angeles area? Get customized training to suit your needs.

WordPress Training - 1 on 1, private groups
Get in-person help and training for WordPress

WordPress Classes, Workshops in Los Angeles
Get discounts and info on upcoming WordPress workshops

Online Marketing Consulting & Training
Need more clients, leads, sales, promotion ideas? Get more quality web traffic and improve your visibility. I’ll help you reach your goals.

Blogging For Small Business Training Program
Customized 1-on-1 training program to get your small biz blog up and running with a strategy.

Social Media For Small Business Training Program
Customized 1-on-1 training program to formulate and implement a social media strategy for your business.

Blogging For Beginners
Just starting out? Learn all the blogging basics

Sometimes I Talk To People


GroundUp Business Meetup - Why Use WordPress For Your Business


Seattle WordCamp - Going Beyond The Basics


Orange County WordCamp - Fun With Gravity Forms


  • @nybinc: Thanks for sharing this information Lucy, it really cleared up my confusion. [...]
  • iamabdus: Awesome, thanks Lucy for the great tutorial. It helped me a lot to backup my sites. [...]
  • Shaun Snapp: Very cool Lucy. I have been looking for a replacement for Amazon S3 which runs me around $100 per mo [...]
  • Jon: What an excellent way to use Dropbox! Already a user and this makes perfect sense, thanks for the p [...]
  • LucyBeer: Hey there - thanks for checking out my blog! Display Widgets will definitely make your life easier a [...]

Sign up for updates and workshop info

Sign up to the email list and you will receive a free copy of my ebook "Practical SEO." I respect your privacy and your information will not be sold, rented or abused in any way. You will receive a weekly update of posts from the blog and, if you provide your location, occasional emails about events in your area.
join my mailing list
* indicates required field

Let’s Talk On Facebook

Follow Me On Twitter

Connect With Me

Where to find me and what to expect:

Email Me:
lucy [AT]webtrainingwheels.com

 

Discussions on WordPress, blogging, online marketing

 

blog updates, useful articles and tips

 


business networking

 


bookmark collection contains WordPress & online marketing resources

Login Status

You are not currently logged in.






» Register
» Lost your Password?
Hosted by WPEngine