Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use state to mitigate CSRF #612

Closed
homakov opened this Issue · 13 comments

4 participants

Egor Homakov Alexander Pavlenko Benjamin Atkin Esteban Pastorino
Egor Homakov

I have a question, why omniauth doesn't provide 'state' param to prevent CSRF? For example facebook supports it and returns it back to make sure you are who started auth process. There should be 2 params: code and state. Now it's only code. And it is vulnerable. Should I add one?

Egor Homakov homakov closed this
Egor Homakov homakov reopened this
Alexander Pavlenko

Someone, please get assigned, or we'll get hundred pull-requests at once :)

Egor Homakov

@AlexanderPavlenko we need fix asap :)
omniauth should automatically generate random state, save it in user session and check equality on callback_phase
10 LOC + tests..

Egor Homakov

it looks good solution. 3.times.map{ rand.to_s[2..-1] }.reduce(&:concat) strange random..

Alexander Pavlenko

@homakov

strange random

nice one, for me :)

About solution — the only thing I fear is some dumb providers that just wouldn't pass back that state param. But if it's rare and code really works (I didn't have a chance to test it with the real OAuth providers, that's why I asked for your help), we can create pull request for it.

Benjamin Atkin

:+1:

To read more, go here and search for "state" (keep the double quotes).

http://tools.ietf.org/html/draft-ietf-oauth-v2-27

Esteban Pastorino

@AlexanderPavlenko Seems good. Tried it and works :)
Why not use ruby's built in SecureRandom instead of generating the random by hand? Something like SecureRandom.hex(24)? (just be sure to require 'securerandom')

Esteban Pastorino

Excellent!
Hope this gets merged! Are you going to send a pull request?

Alexander Pavlenko

@homakov aaand it's merged, so this issue can be closed

Egor Homakov

good job guys

Egor Homakov homakov closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.