A Rails Security Flaw – Destroying The Audit Trail

Recently Rails 2.3 was released, with a number of new features.

One of these was the ability to set the created_at/updated_at time-stamped columns manually. Now, why anybody would want to do this currently escapes me – but that aside, those columns are now attr_accessible.

This means that anybody can set them by manually editing the forms on your site, so you can’t trust them to be correct. Your audit trail is no longer valid.

Now, you may argue that it’s a simple matter of setting those columns to attr_protected in the models. However, how many people do you think will remember to do that? Especially when you’re upgrading pre 2.3 apps.

I’ve talked to the Rails core about this issue, but they’re reluctant to make created_at/updated_at attr_protected by default due to api compatibility problems.

In any case, you can fix it yourself by putting the following script in config/initializers:

See also:

  • No similar posts

About the author

Leave a comment

Our latest tweets

Categories

Recent comments

  • George Gerrard: magic to at last see/read someone with a brain I have been on chatroulette and as soon as I see some...
  • Oli Matthews: Thanks Rob. It's a little like tweet deck but with Flickr included. As mentioned in my post I'm goin...
  • Robz J: Nice work Ol -kinda like Tweetdeck right ? Interested also to hear your comments on browsers >>...
  • Raj: Check out the Tfl London Cycle Hire API @ http://bike-stats.co.uk/...
  • Andrew Denny: Oops, sorry, glitch in my last comment. God, I hate this commenting system, why can't they design a ...