Skip to content

Use cryptographically-secure random number generator #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AndriiDubonos opened this issue Mar 14, 2024 · 5 comments
Closed

Use cryptographically-secure random number generator #63

AndriiDubonos opened this issue Mar 14, 2024 · 5 comments

Comments

@AndriiDubonos
Copy link

Current implementation for OTP generation use Math.random() for random number generation.
It's pseudo-random and should not be used as a number generator in security environment.

const value: number = Math.floor(1000 + Math.random() * 9000)

@yaroslav73
Copy link

But cryptographically-secure is... pseudo-random also 🙃

@nyckyta
Copy link

nyckyta commented Mar 14, 2024

I believe the point here is that it is possible to predict values from crypto insecure generator by observing long enough sequence of previously generated values . In other words, when intruder is able to observe sequence of generated values (even expired one), then he can derive the state of generator from them and thus to start to generate its own values that will be accepcted by the system. As a result, it will compromise users security.

This issue does not appear when you use cryptographically safe algo as doc states.

@alinkedd
Copy link

Related to diia-open-source/be-auth-service#1

@includesec-erik
Copy link

FYI @AndriiDubonos this issue would be closed if this PR is accepted:
#99

@ghost
Copy link

ghost commented Mar 25, 2024

Hi @AndriiDubonos
Thank you for your attention. This is a duplicate issue: diia-open-source/be-auth-service#1. Let's close this issue as a duplicate. Follow up on updates on issues that were opened earlier.

@ghost ghost closed this as completed Mar 25, 2024
@ghost ghost reopened this Mar 25, 2024
@ghost ghost closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants