Skip to content

Add script: UUIDv4 #175

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
wants to merge 1 commit into from
Closed

Add script: UUIDv4 #175

wants to merge 1 commit into from

Conversation

nhnicwaller
Copy link
Contributor

Version 4 of UUID is nice and easy because every bit is random (except the version identifier). No need to worry about MAC addresses or chosen namespace identifiers.

Fixes #77

Version 4 of UUID is nice and easy because every bit is random (except the version identifier). No need to worry about MAC addresses or chosen namespace identifiers.

Fixes #77
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 1 Security Hotspot to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@nhnicwaller
Copy link
Contributor Author

0 Vulnerabilities (and 1 Security Hotspot to review)

The security hotspot is use of Math.random() which is not great for cryptographic applications. The suggested workaround is to use window.crypto on the client side or require('crypto'); on the server side, but I think neither of those are available in this runtime.

Anyways, I don't think it's a very big deal because people will be generating very few UUIDs inside Boop, compared to a web application that might be used by many people at once.

@IvanMathy
Copy link
Owner

That's kind of the problem, we cannot guarantee that those UUIDs will be unique enough to be safe for use. Similar to #88, there is a question of whether this feature actually improves security or makes it worse.

Crypto not being available makes me a bit worried about those scripts and the potential uses, since they should not be trusted. Your suggestion about it being less likely to collision since it is not running at the same time is a very good point, I just want to make sure that the results are not constrained to only a subset of available UUIDs, being deteministic is not necessarily an issue.

I would also suggest we try tweaking the algorithm a bit (maybe by shifting the random number before consuming it?) so that we reduce the likelihood of collision with software that uses that same snippet (considering it's the top result there is probably a huge amount of places that use it as-is).

@nhnicwaller
Copy link
Contributor Author

I think this PR isn't very scary. I will try to convince you.

Similar to #88, there is a question of whether this feature actually improves security or makes it worse.

I think UUIDs and PGP keys have dissimilar threat models. PGP keys are used for cipher operations and generation of cryptographic signatures; UUIDs are not. PGP private keys are commonly reused, and the period of reuse may span years. Discovering a PGP private key causes a breakdown in confidentiality for a (potentially large) collection of messages. UUIDs are typically generated once to identify an object, and do not apply to multiple objects (messages) like PGP keys do.

Crypto not being available makes me a bit worried about those scripts and the potential uses, since they should not be trusted. Your suggestion about it being less likely to collision since it is not running at the same time is a very good point, I just want to make sure that the results are not constrained to only a subset of available UUIDs, being deteministic is not necessarily an issue.

For what it's worth, I ran 1 million iterations of this script and every result was unique. Of course, that only tests a tiny fraction of 1% of the huge UUID space, so experiments like this aren't a good way of proving that a given PRNG has the desired characteristics.

It is worth pointing out, however, that the PRNG in WebKit which underlies JavascriptCore is originally seeded with a cryptographically secure random number.

Between 2009 and 2015, WebKit used a relatively weak PRNG called GameRand. (How bad was GameRand? Pretty bad.) But in 2015, WebKit upgraded to Xorshift+ which is really quite good.

I would also suggest we try tweaking the algorithm a bit (maybe by shifting the random number before consuming it?) so that we reduce the likelihood of collision with software that uses that same snippet (considering it's the top result there is probably a huge amount of places that use it as-is).

Tweaking the PRNG output like this would probably offer no benefit (remember, it's already seeded with a cryptographically secure RNG), and could potentially cause some entropy bits to be discarded, weakening the resulting UUID.

@luisfontes19
Copy link
Contributor

I also created a script for this, but closed the PR as I noticed this was already made and I had the same issue as there isn't an easy way to do secure random. I clearly stated in my script that it wasn't secure for crypto related functions.

But my use case for uuids is to generate things like "flags" for challenges, or just random ID's for small scenarios...
If these are the intended uses, an approach would be to just call something like "Insecure UUIDV4" or "UUIDV4 (Predictable)"

Depending on the cases that's good enough and better then not having it, in my opinion :)

@zoeyfyi zoeyfyi mentioned this pull request Jan 12, 2021
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

Successfully merging this pull request may close these issues.

Feature Request: Generate UUID
3 participants