Check for crypto/rand errors and ReadFull io.Readers#417
Conversation
In practice crypto/rand.Read never returns an error, but that is not guaranteed. Check for those errors. In contrast to crypto/rand.Reader, a user-provided io.Reader, might not fill the buffer without returning an error. Though marginal, we should deal with that corner-case as well.
87bfdcc to
7857037
Compare
New version panic()s if reads from crypto/rand fail.
|
#466 asked about why this fix for CVE-2023-1732 was released so late. The reason is that these are not high-severity issues that affect real systems, despite the misleading CVE score. More details below: We indeed missed checking the error for
Failing to read from this random number is quite unlikely. It does not happen in normal environments. On Linux, it could happen if someone blocks the All users of The following might be affected depending on configuration:
The standard practice is to use As you can see, only two users ( |
In practice crypto/rand.Read never returns an error, but that is not guaranteed. Check for those errors.
In contrast to crypto/rand.Reader, a user-provided io.Reader, might not fill the buffer without returning an error. Though marginal, we should deal with that corner-case as well.