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?

Gigi
  • 1,280
  • 1
  • 11
  • 12

1 Answers1

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.

Steve
  • 15,155
  • 3
  • 37
  • 66
  • So the kind of RNG you use has no real significance in this context? – Gigi Apr 23 '20 at 09: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 '20 at 15:51