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

Infinite loop in randomInt #137

Open
miyaokamarina opened this issue Feb 5, 2024 · 2 comments
Open

Infinite loop in randomInt #137

miyaokamarina opened this issue Feb 5, 2024 · 2 comments

Comments

@miyaokamarina
Copy link

The randomInt() function loops infinitely under certain conditions, this is a serious DoS vulnerability.

The loop in randomInt() always uses the state value that never changes, so if a resulting value fails the threshold test only once, the loop will repeat forever.

It should rather be something like n = pcg.getOutput(nextPcg.state), so that the current state is used, not the initial one.

@miyaokamarina
Copy link
Author

Some details on the probability of infinite loop: https://functor.network/user/790/entry/270#the-exploit

philihp added a commit that referenced this issue Apr 10, 2024
philihp added a commit that referenced this issue Apr 10, 2024
philihp added a commit that referenced this issue Apr 10, 2024
@philihp
Copy link
Owner

philihp commented Apr 10, 2024

Thank for your thorough audit. I'll implement your suggestion, it does look like I made a mistake in not advancing state.

I am not so certain of a DoS vulnerability, but if you could provide an initState, streamID, and with which provided output function it exists that the second state is 0, I would love to add it as a test case.

philihp added a commit that referenced this issue Apr 10, 2024
* 'main' of github.com:philihp/fn-pcg:
  fix issue #137 (#155)
  Update actions/setup-node action to v4 (#90)
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