Re:Bypassing GitHub's OAuth Flow with a Head Request
by homakov on Thursday November 07, 2019 @11:56AM
(#21474888)
> I wonder if Rails will fix the default implementation of handling HEAD requests
It absolutely should. Nobody expected Rails to covertly turn HEAD into GET. It must be explicit "get_or_head" method in routes.rb
Re:Bypassing GitHub's OAuth Flow with a Head Request
by michaelmior on Thursday November 07, 2019 @01:30PM
(#21475872)
HEAD isn't turned into GET, it's routed the same as a GET request. If it were actually turned into a GET request, then `request.get?` would have been true, and this exploit wouldn't have happened.
But I do agree with your point that routing of HEAD requests should be explicit.
Re:Bypassing GitHub's OAuth Flow with a Head Request
by homakov on Thursday November 07, 2019 @03:44PM
(#21477067)
> HEAD isn't turned into GET, it's routed the same as a GET request
Pardon my poor wording indeed, I intended to mean this too.
Re:Bypassing GitHub's OAuth Flow with a Head Request
by ptoomey3 on Thursday November 07, 2019 @05:46PM
(#21478096)
Rails actually did turn the HEAD into a GET back when this code was written - https://github.com/rails/rails/blob/e17e25cd23e8abd45b170646...
Re:Bypassing GitHub's OAuth Flow with a Head Request
by FanaHOVA on Thursday November 07, 2019 @01:03PM
(#21475572)
Considering that GitHub is one the main Rails maintainers, probably. That might actually be how they fixed it internally and will push it upstream.
Re:Bypassing GitHub's OAuth Flow with a Head Request
by jessaustin on Thursday November 07, 2019 @03:51PM
(#21477126)
ISTM it's reasonable not to force everyone not to write a separate HEAD handler everywhere. The main result of that would be lots of 405 errors. This was a really dumb mistake at the application level. Maybe the library needs better documentation, but it shouldn't be made less functional.
Re:Bypassing GitHub's OAuth Flow with a Head Request
by latortuga on Thursday November 07, 2019 @05:51PM
(#21478136)
Agreed. This is a corner case because Rails encourages you to route different request verbs to different endpoints via the `resource` routing scheme. The situation played out like this because of handling GET and POST via the same action which should not have been done and in general is not something Rails encourages.
I wonder if Rails will fix the default implementation of handling HEAD requests, similar to how they overhauled the default handling of mass assignment of parameters in 2012 (coincidentally, a flaw also exposed via Github) [0]? Obviously, the latter issue posed a much bigger risk to the average Rails app.
[0] https://news.ycombinator.com/item?id=3666564
edit: fixed URL