0

In OAuth2, as part of the authorization request, we generate a random string and pass it with the state parameter, so that when we get the response, we can ascertain that the response is a result of our request.

In some examples, I've seen this generated using normal pseudorandom functions. Would there be any benefit in using cryptographically strong random number generators instead?

1 Answer 1

1

It's all dependent on what you're doing with that state information after authorization and what could happen if an attacker modified it.

If you're using it to reassociate a session then you need to make sure an attacker can't just randomly guess the session ID. Or conversely ask yourself what happens when an attacker randomly guesses it?

If you're storing a bit of data like final-sales-price=$142.32 then you need to make it tamper evident through (say) signing so an attacker can't modify.

2
  • So the kind of RNG you use has no real significance in this context?
    – Gigi
    Apr 23, 2020 at 9:07
  • That's not what I said. I said it depends on what you're using the state for. In most cases a CSPRNG is probably going to be safer when generating state that attackers could potentially touch.
    – Steve
    Apr 23, 2020 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.