TimThumb users and WordPress Theme users using TimThumb, please upgrade

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

I’ve done a ton of work on TimThumb this weekend and there are a few great enhancements. E.g. if you have pngcrush or optipng installed, it will now use 66% less disk space and give you comparable quality images.

Please grab the latest version of TimThumb on this page. Then let me know if you have any feature requests or find any bugs by reporting them here.

Here’s the TimThumb changelog since I released 2.0 about 48 hours ago.

Poem: When I Heard the Learn’d Astronomer

This is a wonderful poem by Walt Whitman where he explores how the formalization of science and nature robs it of it’s mystery and wonder. If you’re a programmer who has done any time at a University, you’ll recognize Whitman’s sentiment.

It first appeared in the “By the Roadside” section of the standard 1892 edition of Leaves of Grass.

When I heard the learn’d astronomer;
When the proofs, the figures, were ranged in columns before me;
When I was shown the charts and the diagrams, to add, divide, and
measure them;
When I, sitting, heard the astronomer, where he lectured with much
applause in the lecture-room,
How soon, unaccountable, I became tired and sick;
Till rising and gliding out, I wander’d off by myself,
In the mystical moist night-air, and from time to time,
Look’d up in perfect silence at the stars.

What does the S&P’s AAA to AA+ downgrade for the United States mean?

If you haven’t heard the news, S&P just downgraded us from AAA to AA+ and gave us a negative outlook to add insult to injury. But it’s not like we didn’t deserve it. In a democracy, people deserve the government they get. Remember that “We the people…” document? Well we the people just got a AA+.

It’s the first time the US has been downgraded since we received a triple-A rating from Moody’s in 1917 and a AAA from S&P in 1941.

Obama says “S&P’s analysis of the United States economy is deeply flawed.”. I think his chances of reelection just got deeply f***ed.

Keep an eye on treasury bond yields on Monday morning. There’s a tension between interest rates going up since they’re now technically more risky and the reflex flight to risk causing treasury buying that drives their rates down. It’ll be interesting to see whether fear or common sense prevail.

So what will happen going forward?

  • Interest rates in this country are bound to rise long term because, what the government pays on debt is the base of all other interest rates in the country.
  • Mortgage rates rising won’t help the housing market “recovery”. Less people will buy houses with the cost of borrowing becoming more expensive.
  • With asset prices falling a few more banks will fail. Their debt to asset ratio will not meet the minimum requirements and the FDIC will show up on Friday afternoon and seize them.
  • Expect to hear about the FDIC fund running short on cash and there to be a vocal debate about how to replenish it. Technically it’s an insurance policy that the banks fund and in normal times the government might just top it up. But what will probably happen as the fund gets depleted is that they will need to raise the rates they charge banks, which may make banking in this country more expensive for consumers and businesses.
  • The latest budget debate made it very clear there will be no more trillion dollar bailouts. The good news is that at least this kills moral hazard (when bankers and execs are irresponsible because they know they’ll get bailed out.
  • It gives us a reasonable facsimile of a free market. Even if you’re going to have to dodge the falling bodies on Wall St….
  • The dollar will fall as foreign investors move to countries like the UK, Germany, France and Canada who all still have their AAA rating intact.
  • Companies that rely on cheap foreign labor or resources will have to radically restructure their supply chains to survive and some might not be able to pull it off.
So where are the opportunities? Well I’ve said it before and I’ll say it again: “Gold prices will hit $1800 in September/October and $2200 or more by year end.
  • Companies that export US goods or services will earn more as the dollar falls.
  • Technology companies who are nimble, efficient and export services will do well.
  • New innovators will replace incumbents who can’t readjust.
  • We might get a new political party in the next half decade.
And for a laugh.. the Federal Reserve just announced that risk weightings for US government securities (how risky the government thinks it is) will remain unchanged:
For risk-based capital purposes, the risk weights for Treasury securities and other securities issued or guaranteed by the U.S. government, government agencies, and government-sponsored entities will not change. The treatment of Treasury securities and other securities issued or guaranteed by the U.S. government, government agencies, and government-sponsored entities under other federal banking agency regulations, including, for example, the Federal Reserve Board’s Regulation W, will also be unaffected.

And finally, lets hope that 500 point drop in the DOW this week was a leak that has now been fully priced into the market, or we’re in for an even bigger drop on Monday.

WordThumb is now TimThumb 2.0

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

On the suggestion of Matt Mullenweg (wordpress founder) Ben Gillbanks (timthumb author) and I have been working for the last day to merge my work on WordThumb into TimThumb 2.0.

That work is now complete and TimThumb 2.0 is now available for download from the TimThumb site.

I’m going to be working with Ben going forward to continue to have TimThumb be the easiest to use, fastest, most popular and most secure thumbnail script on the Web.

Here are a few enhancements in TimThumb 2.0:

  • Includes the ability to take website screenshots if you have Xvfb and CutyCapt installed. (Instructions included how to do this)
  • All filters and resizing can be applied to website screenshots.
  • The cache directory is now secure and is still public for flexibility across platforms.
  • TimThumb creates index files in your cache to prevent directory listings.
  • Filenames are more randomized using data that a hacker doesn’t have access to, making it very hard to guess filenames in cache and access them.
  • Cache files have a .txt extension which means the web server won’t execute them.
  • All cached files have a fixed length record at the beginning which, if a web server tries to execute them, will be interpreted as PHP code and will cause an immediate exit.
  • It includes file locking when files are created in cache to avoid conflicts.
  • The entire code base has been rewritten and refactored for better code scaleability.
  • Lots of other improvements.
So give it a whirl and if you have any suggestions or find any bugs, please file them on the TimThumb issues page. Thanks.

WordThumb now uses a secure public cache for compatibility

UPDATE: WordThumb has now been merged into TimThumb and has become TimThumb 2.0. Please head over to the TimThumb site now for updates and to get the code.

The latest version of wordthumb (just uploaded) uses a public cache again (same place timthumb does) because many system temporary folders are not writeable.

This public cache is part of what caused the timthumb vulnerability, so I’ve made it more secure as follows:

  • Using a .txt extension for all files so servers won’t execute the files when accessed.
  • Using an md5 salt to prevent hackers knowing what filenames are to make things a little harder. On a badly configured server they could still get a directory index and access files that way.
  • Added a <?php die(); ?> to the start of ever file cached. That way if a hacker manages to guess a filename and for some reason the server decides to execute a .txt file, as a last resort it will simply die.