-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
WASM compilation Random() always has the same seed #56609
Comments
Summary: The |
If anybody uses plain Not saying this is not bad. :) |
Found the following code which could indicate the issue: sdk/sdk/lib/_internal/wasm/lib/math_patch.dart Lines 224 to 236 in eff0ece
Kinda an important TODO that most likely should have an issue number attached to it to keep track of it? |
Summary: The |
This is a catastrophic issue that should be fixed and cherry-picked ASAP. Anyone generating UUIDs in Flutter web WASM apps could be unintentionally generating UUID collisions and lose a lot of data. |
Just want to add here that you should never generate UUID using default Random() generator. Use Random.secure() for that. Reason being that the amount of unique seeds for Random() are limited to 32 bits. So if you have lot of clients running, it is actually not that impossible to get two clients running with same seed just by accident. (But UUID should also really be generated by backend...) |
If that's the case then this is a catastrophic issue in the uuid package Our app generates a lot of data while offline, so generating UUIDs server-side doesn't seem like a viable option |
I agree that it would be better if the UUID package did focus on security first and performance can then be enabled with a unsecure flag documented what it does and the consequences of using it. Most projects does not require really fast generation of UUID's. And Random.secure are available on all platforms as far as I know. But yes, I don't disagree that this issue should be fixed with a hotfix on stable. It is quite serious. |
I agree that this is a huge issue. Even beyond the UUID and security/secure issues, the default behavior of Utilizing the same seed for testing stuff is a valid use case but should not be the default behavior. That is the purpose of passing a specific seed you define in the constructor This is unexpected default behavior and I expect most people had no idea this was the case. I knew Random() was not secure and could not always be random but I expected that it not being random was a like 1 in 100 chance not every time. |
Hi, I have released a new version of UUID that makes Some back story: Random.secure() didn't always exist, and I had custom Crypto implementations in the past to do that, but were slow. And once it did exist, there were regressions with IE11 back in the day and people using DartAngular at the time were having issues. So I flipflopped between secure and non-secure Random a lot over the years. To my knowledge, this is no longer an issue, so I have made it default again. the uuid library is 11+ years old, so there is a lot of legacy decisions and iteration. |
@osa1 Thanks for the quick fix of this issue. Have it been considered if this is something that should be cherry-picked to Stable and/or Beta? |
@julemand101 we just considered it, we will try to cherry-pick it into the next beta. I will create the cherry-pick request tomorrow, then it's up to the release team to decide, but I expect it to be merged as it's not a risky patch. (a tiny patch that can't break anyting) |
I think there's a new beta cutoff coming soon and the commit that fixed this issue will be included as well, so we don't need a cherry-pick. The commit should be merged to https://github.com/dart-lang/sdk/commits/beta/ in a few days. |
dart info
)Dart 3.6.0-197.0.dev windows_x64
Windows
Chrome
Today we identified WASM builds were always generating the same UUIDs.
https://github.com/Rexios80/uuid_wasm_test
with an additional test
This will always return:
472
247
387
474
201
when compiled for dart2wasm but will be seeded randomly for dart2js.
I assume this could also be some sort of security problem as well?
The text was updated successfully, but these errors were encountered: