CVE-2021-4238
Insufficient randomness in github.com/Masterminds/goutils
Randomly-generated alphanumeric strings contain significantly less entropy than expected. The RandomAlphaNumeric and CryptoRandomAlphaNumeric functions always return strings containing at least one digit from 0 to 9. This significantly reduces the amount of entropy in short strings generated by these functions.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- None
- User interaction
- None
What an attacker can affect
- Confidentiality
- High
- Integrity
- None
- Availability
- High
Exploit likelihood
What each source reports
NVD Score used
9.1
Randomly-generated alphanumeric strings contain significantly less entropy than expected. The RandomAlphaNumeric and CryptoRandomAlphaNumeric functions always return strings containing at least one digit from 0 to 9. This significantly reduces the amount of entropy in short strings generated by these functions.
- Record
CVE-2021-4238- CVSS 3.1
- 9.1 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H - Weakness
- CWE-331
- Updated
- 2026-11-02
CVE List
9.1
Insufficient randomness in github.com/Masterminds/goutils
Randomly-generated alphanumeric strings contain significantly less entropy than expected. The RandomAlphaNumeric and CryptoRandomAlphaNumeric functions always return strings containing at least one digit from 0 to 9. This significantly reduces the amount of entropy in short strings generated by these functions.
- Record
CVE-2021-4238- CVSS 3.1
- 9.1 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H - Updated
- 2026-11-02
EUVDEUVD-2022-7482
9.1
Randomly-generated alphanumeric strings contain significantly less entropy than expected. The RandomAlphaNumeric and CryptoRandomAlphaNumeric functions always return strings containing at least one digit from 0 to 9. This significantly reduces the amount of entropy in short strings generated by these functions.
- Record
EUVD-2022-7482- CVSS 3.1
- 9.1 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H - Updated
- 2026-11-02
GitHub AdvisoriesGHSA-3839-6r69-m497
9.1
Duplicate Advisory: GoUtils's randomly-generated alphanumeric strings contain significantly less entropy than expected
Duplicate Advisory
This advisory has been withdrawn because it is a duplicate of GHSA-xg2h-wx96-xgxr. This link is maintained to preserve external references.
Original Description
Randomly-generated alphanumeric strings contain significantly less entropy than expected. The RandomAlphaNumeric and CryptoRandomAlphaNumeric functions always return strings containing at least one digit from 0 to 9. This significantly reduces the amount of entropy in short strings generated by these functions.
- Record
GHSA-3839-6r69-m497- CVSS 3.1
- 9.1 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H - Weakness
- CWE-331
- Updated
- 2026-11-02
GitHub AdvisoriesGHSA-xg2h-wx96-xgxr No score
RandomAlphaNumeric and CryptoRandomAlphaNumeric are not as random as they should be
Impact
A security-sensitive bug was discovered by Open Source Developer Erik Sundell of Sundell Open Source Consulting AB.
The functions RandomAlphaNumeric(int) and CryptoRandomAlphaNumeric(int) are not as random as they should be. Small values of int in the functions above will return a smaller subset of results than they should. For example, RandomAlphaNumeric(1) will always return a digit in the 0-9 range, while RandomAlphaNumeric(4) will return around ~7 million of the ~13M possible permutations.
This is considered a security release because programs that rely upon random generators for passwords are at an increased risk of brute force-style password guessing. There is also a higher probability of collision.
The problem was the result of a mistaken regular expression that only accepted random strings if they contained a digit from [0-9]. That restriction has been removed.
Patches
This issue has been corrected in v1.1.1.
Workarounds
If you cannot upgrade to v1.1.1, you can work around the issue by calling RandomAlphaNumericCustom(N, true, true)|CryptoRandomAlphaNumericCustom(N, true, true) instead. (Where N is the desired length, and true is the literal boolean true.)
- Record
GHSA-xg2h-wx96-xgxr- Weakness
- CWE-331
- Updated
- 2026-11-02
OSVAZL-41275
9.1
CVE-2021-4238 affecting package influxdb for versions less than 2.7.3-3
Randomly-generated alphanumeric strings contain significantly less entropy than expected. The RandomAlphaNumeric and CryptoRandomAlphaNumeric functions always return strings containing at least one digit from 0 to 9. This significantly reduces the amount of entropy in short strings generated by these functions.
- Record
AZL-41275- CVSS 3.1
- 9.1 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H - Updated
- 2026-11-05
Show 6 moreShow less
OSV
9.1
Randomly-generated alphanumeric strings contain significantly less entropy than expected. The RandomAlphaNumeric and CryptoRandomAlphaNumeric functions always return strings containing at least one digit from 0 to 9. This significantly reduces the amount of entropy in short strings generated by these functions.
- Record
CVE-2021-4238- CVSS 3.1
- 9.1 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H - Updated
- 2026-11-02
OSVGHSA-3839-6r69-m497
9.1
Duplicate Advisory: GoUtils's randomly-generated alphanumeric strings contain significantly less entropy than expected
Duplicate Advisory
This advisory has been withdrawn because it is a duplicate of GHSA-xg2h-wx96-xgxr. This link is maintained to preserve external references.
Original Description
Randomly-generated alphanumeric strings contain significantly less entropy than expected. The RandomAlphaNumeric and CryptoRandomAlphaNumeric functions always return strings containing at least one digit from 0 to 9. This significantly reduces the amount of entropy in short strings generated by these functions.
- Record
GHSA-3839-6r69-m497- CVSS 3.1
- 9.1 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H - Weakness
- CWE-331
- Updated
- 2026-11-02
OSVRHSA-2023:0540
7.0
Red Hat Security Advisory: Red Hat OpenShift Service Mesh 2.1.6 security update
- Record
RHSA-2023:0540- CVSS 3.1
- 7.0 High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:L - Updated
- 2026-11-02
OSVUBUNTU-CVE-2021-4238
9.1
Randomly-generated alphanumeric strings contain significantly less entropy than expected. The RandomAlphaNumeric and CryptoRandomAlphaNumeric functions always return strings containing at least one digit from 0 to 9. This significantly reduces the amount of entropy in short strings generated by these functions.
- Record
UBUNTU-CVE-2021-4238- CVSS 3.1
- 9.1 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H - Updated
- 2026-11-02
OSVGHSA-xg2h-wx96-xgxr No score
RandomAlphaNumeric and CryptoRandomAlphaNumeric are not as random as they should be
Impact
A security-sensitive bug was discovered by Open Source Developer Erik Sundell of Sundell Open Source Consulting AB.
The functions RandomAlphaNumeric(int) and CryptoRandomAlphaNumeric(int) are not as random as they should be. Small values of int in the functions above will return a smaller subset of results than they should. For example, RandomAlphaNumeric(1) will always return a digit in the 0-9 range, while RandomAlphaNumeric(4) will return around ~7 million of the ~13M possible permutations.
This is considered a security release because programs that rely upon random generators for passwords are at an increased risk of brute force-style password guessing. There is also a higher probability of collision.
The problem was the result of a mistaken regular expression that only accepted random strings if they contained a digit from [0-9]. That restriction has been removed.
Patches
This issue has been corrected in v1.1.1.
Workarounds
If you cannot upgrade to v1.1.1, you can work around the issue by calling RandomAlphaNumericCustom(N, true, true)|CryptoRandomAlphaNumericCustom(N, true, true) instead. (Where N is the desired length, and true is the literal boolean true.)
- Record
GHSA-xg2h-wx96-xgxr- Weakness
- CWE-331
- Updated
- 2026-11-02
OSVGO-2022-0411 No score
Insufficient randomness in github.com/Masterminds/goutils
Randomly-generated alphanumeric strings contain significantly less entropy than expected.
The RandomAlphaNumeric and CryptoRandomAlphaNumeric functions always return strings containing at least one digit from 0 to 9. This significantly reduces the amount of entropy in short strings generated by these functions.
- Record
GO-2022-0411- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
github.com/Masterminds/goutilsGo |
before 1.1.1 | 1.1.1 |
influxdbAzure Linux:3 |
before 2.7.3-3 | 2.7.3-3 |
servicemeshRed Hat:service_mesh:2.1::el8 |
before 0:2.1.6-1.el8 | 0:2.1.6-1.el8 |
servicemesh-cniRed Hat:service_mesh:2.1::el8 |
before 0:2.1.6-1.el8 | 0:2.1.6-1.el8 |
servicemesh-operatorRed Hat:service_mesh:2.1::el8 |
before 0:2.1.6-1.el8 | 0:2.1.6-1.el8 |
servicemesh-pilot-agentRed Hat:service_mesh:2.1::el8 |
before 0:2.1.6-1.el8 | 0:2.1.6-1.el8 |
servicemesh-pilot-discoveryRed Hat:service_mesh:2.1::el8 |
before 0:2.1.6-1.el8 | 0:2.1.6-1.el8 |
golang-github-masterminds-goutilsUbuntu:22.04:LTS |
All versions, plus listed versions 1.1.1-2 |
None known |
golang-github-masterminds-goutilsUbuntu:24.04:LTS |
All versions, plus listed versions 1.1.1-4 |
None known |
golang-github-masterminds-goutilsUbuntu:25.10 |
All versions, plus listed versions 1.1.1-4 |
None known |
golang-github-masterminds-goutilsUbuntu:26.10 |
All versions, plus listed versions 1.1.1-4 |
None known |
golang-github-masterminds-goutilsUbuntu:26.04:LTS |
All versions, plus listed versions 1.1.1-4 |
None known |
History
| Recorded | Changed | Sources |
|---|---|---|
| facts | OSV | |
| affected | ||
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2021-4238 is a critical vulnerability (CVSS 9.1) in Github.com/masterminds/goutils, published May 21, 2021. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 1.41%, the 72nd percentile. Fixed in github.com/Masterminds/goutils 1.1.1.
References
github.com/Masterminds/goutils/commit/869801f20f9f1e7ecdbdb6422049d8241270d5e1
pkg.go.dev/vuln/GO-2022-0411
nvd.nist.gov/vuln/detail/CVE-2021-4238
github.com/advisories/GHSA-3839-6r69-m497
github.com/Masterminds/goutils/security/advisories/GHSA-xg2h-wx96-xgxr
github.com/Masterminds/goutils/commit/f1923532a168b8203bfe956d8cd3b17ebece5982
Show 11 moreShow less
github.com/Masterminds/goutils/releases/tag/v1.1.1
github.com/advisories/GHSA-xg2h-wx96-xgxr
github.com/Masterminds/goutils
access.redhat.com/errata/RHSA-2023:0540
access.redhat.com/security/updates/classification
bugzilla.redhat.com/show_bug.cgi?id=2156729
issues.redhat.com/browse/OSSM-2440
security.access.redhat.com/data/csaf/v2/advisories/2023/rhsa-2023_0540.json
access.redhat.com/security/cve/CVE-2021-4238
cve.org/CVERecord?id=CVE-2021-4238
ubuntu.com/security/CVE-2021-4238