14 ms·
This is a really bad bug. Arbitrary file read on Rails applications can be pretty close to RCE. Worse still, it's present in all the mainstream versions of Rail
by tptacek 8y ago
This is a really bad bug. Arbitrary file read on Rails applications can be pretty close to RCE. Worse still, it's present in all the mainstream versions of Rails, so it'll be lurking in commercial Rails applications for years to come. It's pretty amazing that the bug lasted as long as it did.
- msbarnett 8y agoNotably, though, this only impacts calls which use the `file:` option on render calls, which in my experience is a relatively little-used feature. Not sure how many commercial Rails app this actually impacts in practice.
- tptacek 8y agoI'm not sure why people think this feature is so rare. It's like the Stack Overflow answer for "how do I render a static 404 page that doesn't go through Rails layout templating". You have to do something wrong to have the bug --- render a file without specifying the format --- but you have to do something extra to avoid that mistake, and the feature works just fine if you don't, so I'm not surprised that we've found it in real applications.
- tibbon 8y agoWere I evil, I'd be looking at anyone who has upvoted or commented on such SO posts, and then looking at what companies they work for, and trying to run attacks against every site/repo/app they are linked to to see if they use this technique. Or just, you know, looking in Github for anyone doing this and open sourcing their site.
- draw_down 8y agoYes yes, very clever
- mbell 8y agoIt requires a specific usage of `render` that is extremely rare. I've never seen it in a real application.
- tptacek 8y agoAll it requires is "render :file" without the optional format argument. We found it immediately in applications, and other people on our Slack found it in theirs as well (though not necessarily exploitable, situationally).
- mbell 8y agoI'm aware of the trigger, `render file:` is, in my experience, extremely rare. I can't recall ever wanting to render a template file located outside the application directory.
- aboutruby 8y agoGood call, I went through the top results on Google and edited the answers/posted a comment to signal this vulnerability. Also as others pointed out, this is a pretty rare use of `render` (but any application large enough might have it).