mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-02-27 07:58:30 +03:00
Token generation may be vulnerable to Modulo Bias #779
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zyuiop on GitHub (Aug 22, 2020).
Modulo Bias is an issue with random numbers generators where some numbers have a higher chance to be found than others. See an article about this bias and how to avoid it here: https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/
Here is the line where the bias arises:
eba22c2d94/src/crypto.rs (L67)From what I saw in the code, this seems to be used (only?) for two factor authentication, so this may not be very problematic.
@dani-garcia commented on GitHub (Aug 22, 2020):
This shouldn't be a problem in practice as long as users don't configure the token generation to be over 16 or so:
For example using a 16 digit length, the numbers at the start would have 1844 chances to appear (2^64 / 10^16), while the ones at the end would have 1855 which is basically close enough to random for this case I think.
But yeah using the max of 19 would give the first numbers in the range 50% more chance to appear, so I think we should at the very list make the limit lower.