News for hackers. Stuff that matters.
Re:How Homakov hacked GitHub & the line of code that could h... by rmc on Monday March 05, 2012 @10:26AM (#3666793)
I'm a Python/Django developer and don't really know much Ruby or Ruby on Rails. Does anyone have an outsiders/non-rubyist explaination of how this hack was carried out? Did he modify HTTP headers? POST parameters?
Re:How Homakov hacked GitHub & the line of code that could h... by tizoc on Monday March 05, 2012 @10:57AM (#3666907)
In Django (and Python in general) you have a form abstraction that validates the user input and filters out unwanted fields, preventing problems like this. On Rails (and Ruby in general) they don't use such abstraction (I do myself, using an implementation of forms abstractions[1] very similar to what Django provides).

Instead they send the params dictionary (which contains url captures, POST and GET values) directly to the model instance, and expect the model to deal with it. The problem with this approach is that it gives too much responsability to the model. Other than forms not necessarily mapping directly to models, making this more complicated, it is also prone to security issues, like the one Github suffered. ActiveRecord (Rails ORM) allows you to whitelist and blacklist fields at the model level (which IMO is the wrong way to do this, Django got it right), but a lot of people don't do it.

[1] https://github.com/tizoc/bureaucrat

Re:How Homakov hacked GitHub & the line of code that could h... by carlio on Monday March 05, 2012 @10:31AM (#3666818)
From what I can tell, the 'rails way' of dealing with form data is something akin to user.__dict__.update(request.POST). So you can just add some additional parameters to your POST data and set arbitrary fields on the model.
Re:How Homakov hacked GitHub & the line of code that could h... by danso on Monday March 05, 2012 @10:45AM (#3666867)
I don't think this is the best way to describe this. It is not the "Rails Way" to NOT validate form input. The Github team used a method that allows quick and easy assignment of bulk values. This method is used often in non-public-facing tasks but when it is used in connection with a public facing POST request, then validation logic should be implemented.

It was not, in Github's case. It seems like a glaring error in retrospect but it's easy to see how this code (or the pattern) would move over from the private to public-facing interface and not trigger any errors or notice.

Re:How Homakov hacked GitHub & the line of code that could h... by thecoffman on Monday March 05, 2012 @10:31AM (#3666815)
You would modify the hidden form values (or add parameters that didn't exist) depending on the situation. These new/modified parameters would appear in Rails' params hash which would then be passed to the update function which, by default, will update any fields you hand it.
Re:How Homakov hacked GitHub & the line of code that could h... by SpoonMeiser on Monday March 05, 2012 @11:53AM (#3667159)
This really doesn't sound like a problem with the update function, this just sounds like web applications 101 - don't trust user data.