News for hackers. Stuff that matters.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by eggbrain on Monday January 28, 2013 @04:31PM (#5130784)
Would it ever be possible to have a self-updating framework?

As in, I use Rails to develop web applications. In the past months, I've had to painstakingly go back to every single app I've ever worked on, and manually update it in whatever minor way it needed updating. Now, I'm going to do that again.

If you consider that I'm going to continue to build Rails applications, the number of apps I will have to update every time a security vulnerability comes out will be larger and larger. For a framework that prides itself on sane defaults, it doesn't seem quite sane to have to worry about taking down, updating, and then relaunching every app you ever had when one of these vulnerabilities come out.

I don't mean updating a Rails 2.3 app to 3.2 automatically, just applying these security patches automatically, or prompting the user to do so. Our operating systems do it, our IDEs do it, our programs do it, why can't a framework? I'm not saying it would be easy, but I'm sick of having to be subscribed to these email groups just to start the manual process of fixing everything.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by kmfrk on Monday January 28, 2013 @04:40PM (#5130835)
I think it would have to be handled by the platform provider. Someone like Heroku could make it happen.

Or you could set up a cron-like worker to perform a pip-review (https://github.com/nvie/pip-tools) of sorts.

I don't know if I like the idea of a single point of failure; whatever service pushes the update would have a big, fat Wile E. Coyote target on its back.

I am currently trying to figure out something similar for a Django-based app at the moment. I include a version in the settings file that I plan on comparing against some sort of version array on a central website.

If a new security update is available, a conditional notification will show up for admins, but they will still have to update somewhat manually - I can't set up a cron job to trigger the whole procedure, especially because it might wreck their service, depending on how it works.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by eggbrain on Monday January 28, 2013 @04:48PM (#5130883)
'I don't know if I like the idea of a single point of failure; whatever service pushes the update would have a big, fat Wile E. Coyote target on its back.'

This is a solved problem though, right? Antivirus companies deal with this when they push out definition updates that render backdoors ineffective, and yet while they probably are targeted by the virus makers, they have been quite resilient.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by jiggy2011 on Tuesday January 29, 2013 @02:55AM (#5132874)
Not sure about the AV servers themselves but a common thing for malware to do is to MITM or rebind DNS entries so that AV software updates are served from the attackers server.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by michaelmior on Monday January 28, 2013 @05:14PM (#5131027)
Something like Gemnasium? https://gemnasium.com/
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by kmfrk on Monday January 28, 2013 @08:16PM (#5131805)
That still doesn't automate the process, and there is no telling whether 1.0.1 is a small update or a security update. Having said that, I really want a service like this, and I wanted to make one for Python (PIP) at one point, but hopefully someone more competent will do it or has already.

A different version notation is needed to know whether the version delta between your installation and the most recent contains vital security updates.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by millennia on Monday January 28, 2013 @06:34PM (#5131451)
Rails does this already -

bundle update (if gem version is set with ~>)

You could easily automate this (cap,puppet,chef) if you have a lot of installs. If you genuinely don't want to test updates, you could run it on a schedule.

What it doesn't do, and can't do, is guarantee that security updates will never break your app, but they do quite a good job of isolating them, you do have to do some testing. There is possibly an argument for lts releases which receive few new features and focus on bugs, but what you're complaining about here are really the complexities of running multiple web apps/servers, not something a framework can really help with.

I don't think you have to worry about this update if you have already updated tho latest anyway (which you should have done if on 3.2.x).

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by jarin on Monday January 28, 2013 @05:01PM (#5130954)
Yep, there is a pretty easy way to do it. In your Gemfile, put:

  gem "rails", "~>3.2.0"
Then when there's an update, run:

  bundle update rails
Edit: fixed the gem directive
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by eggbrain on Monday January 28, 2013 @05:08PM (#5130995)
That assumes you know about the vulnerability, though. If you aren't subscribed to an email group, you might not find out for some period of time. The majority of Rails programmers, or beginners even, aren't a part of these email groups, so they might leave vulnerable code up on their servers indefinitely -- not good.

It might be better to have a cronjob that nightly runs the bundle update command, then restart the server. But again, this depends on you being smart enough to realize this, which since we are talking about sane defaults, isn't something we might want to assume.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by jarin on Monday January 28, 2013 @06:34PM (#5131452)
It's probably a good idea to subscribe to rails-security.

https://groups.google.com/forum/?fromgroups#!forum/rubyonrai...

I probably wouldn't allow a production app to update itself without human intervention.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by eggbrain on Monday January 28, 2013 @07:43PM (#5131682)
The whole issue is that Rails has tried to package what's 'probably a good idea' into the framework by default for quite a while. Unless every guide ever tells you to subscribe to the rails-security group, only those 'in the know' will know to do so. What's better, to have access to these updates by default, or having half the Rails apps out there potentially being compromised?
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by jlogsdon on Monday January 28, 2013 @05:12PM (#5131019)
You would really want to do

    gem 'rails', '~>3.2.0`
otherwise you could get upgraded to '3.3' or '3.4' which is more likely to break something.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by jarin on Monday January 28, 2013 @06:33PM (#5131444)
Oops, fixed!
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by matthuggins on Monday January 28, 2013 @05:17PM (#5131051)
This assumes you don't commit your app's Gemfile.lock into your repository, which you generally should.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by navyrain on Monday January 28, 2013 @05:27PM (#5131115)
No, bundle update rails will change your Gemfile.lock to the version of rails it upgrades to.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by matthuggins on Monday January 28, 2013 @05:34PM (#5131161)
You're right, my mistake. It's just a matter of running `bundle update rails` on your server as well as making the changes in your repository.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by jarin on Monday January 28, 2013 @06:38PM (#5131469)
As long as you're using a reasonably good deploy script (capistrano, moonshine, Heroku, etc) you shouldn't have to worry about updating gems on your server.

Most deploy scripts will look at your Gemfile.lock and update if necessary during the deploy (or just run bundle install every time, which won't give you a locked version error if your Gemfile.lock matches your Gemfile).

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by matthuggins on Tuesday January 29, 2013 @09:55AM (#5134271)
Definitely, and that's the approach I personally would take. I think jarin was looking for a way to quickly update all his servers without having to redeploy for every app.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by jrochkind1 on Monday January 28, 2013 @06:25PM (#5131417)
> Would it ever be possible to have a self-updating framework?

The problem is, with Rails, you'd never know when the self-updater would update you to a release that broke backwards compat and broke your app.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by altcognito on Monday January 28, 2013 @07:16PM (#5131602)
That's what regression and unit tests are for.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by jiggy2011 on Tuesday January 29, 2013 @02:25AM (#5132818)
Assuming you have perfect tests..

Still doesn't fix the fundamental problem though. Let's say you automatically install updates on a staging server and automatically deploy to production if all tests pass.

What do you do when you're faced with a choice of deploying an app with a few failed tests (for perhaps not totally clear reasons) or leaving an old version up with a vulnerability?

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by altcognito on Thursday January 31, 2013 @10:13AM (#5145305)
I missed this earlier. I think it's a good question and point about tests. More and more companies are relying on having good tests, but the situation you propose certainly can arise. It would be a technical and business decision at that point. What is the exposure? What is the risk? What is missing? How long would it take to replace it? What kind of PR do you want to send out. If I got a message that said -- hey, we know this feature is broken, but your security is more important to us, I probably would accept that as a customer.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by jiggy2011 on Tuesday January 29, 2013 @02:22AM (#5132810)
Because you've built a ton of custom stuff on top of it that may be relying on various quirks or be designed around bad design decisions made in earlier versions.

You will still get this problem with browsers also for example. The amount of times a firefox update has resulting in half of my plugins breaking.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by aidos on Monday January 28, 2013 @04:44PM (#5130857)
Possibly, unfortunately there's every possibility that you'd end up patching up things that broke out of the blue just as frequently that way.

Having said that I've never had problems with the having Linux automatically run the security patches for me.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by eggbrain on Monday January 28, 2013 @04:52PM (#5130904)
Agreed, there is a small possibility that the patching might break the app in a major way, but for the majority of apps (especially those developed by one person just for fun), the benefit of being patched will likely outweigh the chance that the app breaks.

For those with larger organizations and larger apps, it would be the same process that big companies do whenever a windows operating system patch comes out: they test, test, test, and once they are sure the update will work ok, they deploy the patch.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by eric970 on Monday January 28, 2013 @06:11PM (#5131350)
Welcome to the life of a software dev.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by oellegaard on Monday January 28, 2013 @06:13PM (#5131366)
*RoR software dev
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by densh on Monday January 28, 2013 @05:34PM (#5131163)
Stop installing latest shiniest things manually and start using default package manager of your linux distribution. Then all the security maintenance you will probably need is to do equivalent of "apt-get update; apt-get upgrade" once in a while. Yes, it was that easy before all these people who knew better came and decided that they really need latest ruby installed via rvm, latest gems etc. All these ruby/rails deployment "best practices" stroke me as advice given by people who had close to zero experience of maintaining a mission-critical application for a large period of time.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by tptacek on Monday January 28, 2013 @06:36PM (#5131459)
This is the worst possible option and I strongly recommend you minimize your dependencies on your OS package manager; if possible, build your web server from source too.

You need to be prepared at all times to deploy workarounds to newly disclosed security problems. Package managers can and do delay fixes to accommodate the lowest common denominator of users. You cannot run a high profile application and be at the mercy of whoever is administrating your OS package manager.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by stouset on Monday January 28, 2013 @07:17PM (#5131606)
While I usually agree with your advice, I think this approach, while theoretically correct, is actually damaging to the majority of your audience here. The closest analogy I can think of is that it's like requiring users to change passwords every 30 days: great in theory, but in practice it's a disaster.

The problem is that it is simply untenable for all but the highest-profile sites. Finding good ops people, even in the bay area, is extremely hard. Most sites are only going to realize that a security update has been released when their package manager tells them it has, and updating that package is usually a 30s process.

The companies I've seen have a hard enough time keeping track of security updates with package management. For a small to medium team with two, one, or even zero dedicated ops people, asking them to custom-compile (for example) a webserver, ruby implementation, and other critical libraries (openssl, glibc, etc.), subscribe to the relevant security mailing lists, and follow along with updates and security patches is tantamount to having them leave unpatched vulnerabilities on their systems for months or even years.

If you ask your users to change passwords every 30 days, there are inevitably going to be a few who take it seriously and generate and remember secure passwords every single time. But the vast majority are going to use weaker passwords than they otherwise would have, and duplicate those passwords across accounts as much as they can figure out how. Likewise, if you ask already overworked ops guys to manually compile and keep track of security vulnerabilities for their webserver and dozens of libraries, a few are inevitably going to keep on top of things and release fixes minutes after vulnerabilities are announced. But the vast majority are going to simply give up after a month or two and be significantly worse off than if they just use Ubuntu's automatic security package updates.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by tptacek on Monday January 28, 2013 @08:58PM (#5131932)
I don't know what to tell you other than that this is something you actually have to get good at if you're going to run a high-profile app or hold sensitive information of any sort.

I'm not saying you need to be able to find your own nginx vulnerabilities or even write your own patches. But reinstalling nginx or Apache from source shouldn't be a science project for your team; you should know that you can get your prod servers running on a from-source build.

Sink in the time to make sure you can do that now, so you aren't caught totally flat-footed when an emergency happens.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by stouset on Tuesday January 29, 2013 @06:26PM (#5137098)
I agree with your intent. I do. If you're a high-profile site, or you're storing extremely sensitive customer data, this is absolutely something you need to be doing.

But your audience here is startups. Almost always, these startups are cash-strapped, time-crunched, and have zero dedicated ops guys. Ideally, even these types of businesses would prioritize security to the level you're asking.

In reality, as I said in my previous comment, almost none of the startups I've worked at have had the ops capacity necessary to handle this. Even with package management, servers go months without having critical security patches applied. Asking these types of companies to do something that increases the ops overhead necessary to apply patches is going to result in a worse outcome. Keep in mind that it's not simply compiling from source and having infrastructure to apply security patches across multiple boxes. It's also keeping an eye out for reported vulnerabilities — and not all projects have dedicated security mailing lists. Not all projects even report this information via mailing lists.

I wish it were different. I understand where you're coming from. But the incentives are set up ass-backwards, and until companies start having serious liability for data breaches, protecting customer data simply isn't going to be a priority. In the meantime, encouraging them to set up their infrastructure in a way that requires even more ops effort when they're already struggling to keep up is going to have an adverse outcome.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by m0nastic on Monday January 28, 2013 @07:44PM (#5131688)
I'd like to think that if a company doesn't have the resources to properly maintain security patches on their deployed applications, they would use some app hosting platform (like Heroku), but I suspect that there are indeed many companies who are set up like you describe.

That doesn't change the fact that relying on your OS package maintainers to properly update packages results in the same "having them leave unpatched vulnerabilities on their systems for months or even years" (at least the "months" part if Ubuntu is any indication).

This would seem to be a "damned if you do, damned if you don't" scenario.

Also, the 30 day password change thing isn't even something that's "technically correct". It's a "why do we cut the ends of the roast off" vestige from old DoD recommendations.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by ams6110 on Monday January 28, 2013 @07:49PM (#5131708)
Hot-off-the-presses updates often contain serious bugs themselves as well. I lost count of the number of Drupal patches-to-patches-to-updates I've had to deploy, each coming within days or sometimes hours of the prior one. It got to the point where unless it was a critical remote vulnerability I would never apply a fix that had not been out for at least a week with no subsequent serious bug reports.
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by tptacek on Monday January 28, 2013 @08:19PM (#5131813)
How do you know what is or isn't critical? Do you just take it on faith that the vulnerability announcement is correct?
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by wglb on Monday January 28, 2013 @09:02PM (#5131937)
while theoretically correct

It is actually practically correct. Theoretically, there shouldn't be errors. But there are.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by jfb on Monday January 28, 2013 @07:45PM (#5131694)
Perhaps if you can't afford to build a safe system, you should reconsider if you should be in the business of building unsafe ones?
Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by lengarvey on Monday January 28, 2013 @06:05PM (#5131317)
And this common refrain is the shrill cry of someone who hasn't had to manage a Ruby on Rails application. Application libraries are the domain of the developer, not operations. Your job is to give me a stable system for me to deploy on top of, not to dictate what I can and cannot deploy.

Rubygems and bundler makes updating your application stupidly easy. I blogged about it here: http://bottledup.net/2013/01/10/bundler-and-gemfile/ but if you have a good Gemfile and automated CI then all you need to do is `bundle update rails` and then deploy your code. This is at least as easy as using apt to update your stuff.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by rst on Monday January 28, 2013 @07:15PM (#5131594)
Not if you want prompt fixes to the current spate of Rails bugs. As I write, Ubuntu currently has the fix for the last remote code execution vulnerability in Rails marked as being of "undecided" importance, and still "unassigned", even though rails-core shipped a patch weeks ago. This is remote code execution against any vulnerable app, which is pretty much as bad as it gets.

Debian has a fix for the version of Rails 2.3 that they're shipping, but 2.3 is years obsolete, and officially unsupported upstream.

Pointers on both: https://bugs.launchpad.net/ubuntu/+source/rails/+bug/1097643

(comments in the Ubuntu issue reference the Debian fix.)

There are things that the Debian and Ubuntu maintainers do well, but their packaging for Rails and the underlying Ruby language have both been problematic for quite some time, and their use is generally not recommended.

Re:Vulnerability in JSON Parser in Ruby on Rails 3.0 and 2.3 by wglb on Monday January 28, 2013 @08:59PM (#5131933)
This is not a good idea for certain packages. For example, if you are using something that is under seriously active development, such as Rails and Ruby, and in another case, SBCL Lisp, and even often Emacs.

Up-to-date security is one seriously important reason.