Skip to content
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

Lack of randomness in rand() #541

Open
guijan opened this issue Dec 8, 2023 · 1 comment
Open

Lack of randomness in rand() #541

guijan opened this issue Dec 8, 2023 · 1 comment

Comments

@guijan
Copy link
Contributor

guijan commented Dec 8, 2023

rand() has a dozen issues even when you seed it with a RNG, most of which are not relevant here, but there's still at least one issue with it that is still relevant to proxychains.

If different instances of proxychains get the same result from time() or clock_gettime() and call srand(current_time) at the same time, then as long as their rand()s use the same algorithm, they will get the same result. This could be on the same machine or across different machines.

The easiest solution is to use a proper RNG.
arc4random_uniform() is present on all the BSDs, macOS, Illumos, musl, dietlibc, recent glibc, Android, recent Haiku, but not Windows. On Windows, there's the equivalent BCryptGenRandom(). On Haiku, it's tucked inside a BSD compat library that is part of the system (you still have to link to it manually because it's not libc): https://review.haiku-os.org/c/haiku/+/32/3

@rofl0r
Copy link
Owner

rofl0r commented Dec 8, 2023

If different instances of proxychains get the same result from time() or clock_gettime()

that problem was observed with the use of time() (one-second granularity), but it's been resolved by the use of clock_gettime() which has nanosecond granularity, which makes it impossible to have the same value twice.

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

2 participants