Skip to content

Conversation

@sjrd
Copy link
Member

@sjrd sjrd commented Apr 1, 2022

Writing this up in advance.

@sjrd sjrd requested a review from gzm0 April 1, 2022 15:23

**This releases addresses a security vulnerability in `java.util.UUID.randomUUID()`.**
We strongly recommend that all users upgrade to Scala.js 1.10.0 as soon as possible.
Read [the security advisory](https://github.com/scala-js/scala-js/security/advisories) for more details.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure that somewhere, we list the affected Scala.js versions of this (IIUC, basically all of them, but it's still important we make that clear).


### `java.util.UUID.randomUUID()` now depends on `java.security.SecureRandom`, which is provided by external libraries

Until Scala.js 1.9.x, `java.util.UUID.randomUUID()` was implemented using `java.util.Random`, which was not cryptographically secure, and was therefore a security issue.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd propose using present tense:

which is not cryptographically secure.

There is ambiguity in whether "which" refers to the randomUUID implementation or ju.Random. If interpreted as referring to ju.Random, this might be construed as ju.Random now being cryptographically secure. If interpreted as referring to the implementation, it is merely a change of tense about the previous statement.

This means that code that was previously calling `java.util.UUID.randomUUID()` will now fail to link.
To preserve binary compatibility, we introduce two variants of a library that provides `java.security.SecureRandom`:

* [`scalajs-java-securerandom`](https://github.com/scala-js/scala-js-java-securerandom) provides a *correct*, cryptographically secure implementation of `java.security.SecureRandom`, but relies on the Node.js `crypto` package or the Web Crypto API `crypto.getRandomValues` to be available (e.g., in browsers).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/package/module/ ? IIUC a package in this context would mean something you need to install via npm. Which is not necessary.


As mentioned above, this will only work in environments that either provide the Web Crypto API, or Node.js' `crypto` package.

If you need random UUID generation in other environments, we encourage you to implement it yourselves, in a way that corresponds to your requirements in terms of security and collision likelihood.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is good that we try to provide guidance that goes beyond "use fake insecure otherwise". However, wouldn't the next step here be something like: "Find if your environment has a cryptographic random primitive and PR it to scalajs-java-securerandom"? Maybe with an intermediate "shim it onto crypto.getRandomValues".


If you need random UUID generation in other environments, we encourage you to implement it yourselves, in a way that corresponds to your requirements in terms of security and collision likelihood.

If you have **no other choice**, depend on `scalajs-fake-insecure-securerandom` instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good that this cannot be copy pasted from the release notes.


If you have **no other choice**, depend on `scalajs-fake-insecure-securerandom` instead.
As its name implies, this is an *insecure* implementation, and you should get rid of this dependency as soon as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for completeness, a short paragraph about the optimizations you're teasing in the introduction would be nice I think.

@sjrd sjrd force-pushed the scalajs-1.10.0 branch 2 times, most recently from 0d8e702 to c9e5c45 Compare April 4, 2022 10:22
@sjrd
Copy link
Member Author

sjrd commented Apr 4, 2022

Updated. I think I have addressed all comments. I also added release notes and documentation for SmallModulesFor.

@sjrd sjrd requested a review from gzm0 April 4, 2022 10:23
@sjrd sjrd force-pushed the scalajs-1.10.0 branch 3 times, most recently from fb903b4 to c2d0512 Compare April 4, 2022 11:52
@sjrd sjrd force-pushed the scalajs-1.10.0 branch from c2d0512 to 44076ae Compare April 4, 2022 13:59
@sjrd sjrd marked this pull request as ready for review April 4, 2022 20:41
@sjrd sjrd force-pushed the scalajs-1.10.0 branch from 44076ae to 813180a Compare April 4, 2022 20:43
@sjrd sjrd merged commit 25eddca into scala-js:main Apr 4, 2022
@sjrd sjrd deleted the scalajs-1.10.0 branch April 4, 2022 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants