Re:Why the Latest Rails Exploit Is Indicative of a Bigger Pr...
by stouset on Thursday February 14, 2013 @04:35PM
(#5222509)
I consider myself an expert in Ruby style and best practices. And I have never and would never write code that uses `eval`, outside of toy projects.
There are probably ways you can use it safely. But it's not worth the risk.
ActionDispatch::Routing::RouteSet::NamedRouteCollection.add calls 'eval' on the property name passed to it. This invites exploitation. It also fails 'static_typed's desideratum of each component having a single responsibility. And I don't think calling it "magic" is too strong.
I don't know to what extent the Ruby culture encourages calling 'eval' in random API routines like this, but when I previously argued here on HN that that had to be a bad idea, I got some pushback. I would certainly call this a dangerous anti-pattern.
EDITED to add: reference: http://rubysource.com/anatomy-of-an-exploit-an-in-depth-look...