News for hackers. Stuff that matters.
Re:Bypassing GitHub's OAuth Flow with a Head Request by tptacek on Thursday November 07, 2019 @02:22PM (#21476395)
What a fantastic bug. Rails routes HEAD to GET, but .get? in a HEAD handler is false. Github uses a postback to /authorize to complete OAuth, distinguishing between the original GET and the completing POST with .get?. Rails sees the HEAD request and assumes it's a POST (because it's not .get?) --- and also assumes that, because it's a POST, it's CSRF protected, which it is not, because it is not actually a POST.
Re:Bypassing GitHub's OAuth Flow with a Head Request by eganist on Thursday November 07, 2019 @02:44PM (#21476595)
It's bad assumptions all the way down.

Also easy to bake into basic static analysis going forward. Knowing GitHub, I'd think a bug like this probably won't show up again in the near future.

Re:Bypassing GitHub's OAuth Flow with a Head Request by jacquesm on Thursday November 07, 2019 @05:09PM (#21477851)
> It's bad assumptions all the way down.

It always is. The moment you can shine light between your model of what the code does and what it actually does you have at least a bug and maybe much worse.

Re:Bypassing GitHub's OAuth Flow with a Head Request by ljm on Thursday November 07, 2019 @06:56PM (#21478741)
It also looks like a Rails bug, unless Github routed the HEAD requests themselves. In that case, it’s a shortcut that bit them in the ass.
Re:Bypassing GitHub's OAuth Flow with a Head Request by ryanisnan on Thursday November 07, 2019 @05:23PM (#21477955)
Rails is not assuming that it's a POST. The conditional logic in the controller explicitly checks for a get, and then else's otherwise. This is an unfortunate consequence of not having routing go to specific methods, e.g. `def post():`.
Re:Bypassing GitHub's OAuth Flow with a Head Request by tptacek on Thursday November 07, 2019 @05:56PM (#21478180)
Rails routing does go to specific methods ordinarily.

What's funny here is, apparently, .get? used to return true for HEAD requests.