daviddesberg / PHPoAuthLib

PHP 5.3+ oAuth 1/2 Client Library
Other
1.08k stars 454 forks source link

Better nonce generator #537

Open paragonie-scott opened 6 years ago

paragonie-scott commented 6 years ago

Offending code:

How to do it instead:

https://paragonie.com/blog/2015/07/how-safely-generate-random-strings-and-integers-in-php

PeeHaa commented 6 years ago

Am I missing something here?

The nonce in oauth is more used to prevent the service from processing the same request multiple times and not to prevent some security issue.

Worst case means valid requests will be flagged as invalid.

Without a way for the attacker to use their own new nonce and ability to create a new valid signature with it what good is it to the attacker.

Not arguing it's a suboptimal solution

paragonie-scott commented 6 years ago

Am I missing something here?

Nope. I just wanted to call attention to it and suggest using random_int() and bin2hex(random_bytes(16)) respectively.