Advisory Database
  • Advisories
  • Dependency Scanning
  1. golang
  2. ›
  3. github.com/Masterminds/goutils
  4. ›
  5. CVE-2021-4238

CVE-2021-4238: RandomAlphaNumeric and CryptoRandomAlphaNumeric are not as random as they should be

May 21, 2021 (updated January 23, 2026)

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.

References

  • github.com/Masterminds/goutils
  • github.com/Masterminds/goutils/commit/869801f20f9f1e7ecdbdb6422049d8241270d5e1
  • github.com/Masterminds/goutils/commit/f1923532a168b8203bfe956d8cd3b17ebece5982
  • github.com/Masterminds/goutils/releases/tag/v1.1.1
  • github.com/Masterminds/goutils/security/advisories/GHSA-xg2h-wx96-xgxr
  • github.com/advisories/GHSA-xg2h-wx96-xgxr
  • nvd.nist.gov/vuln/detail/CVE-2021-4238
  • pkg.go.dev/vuln/GO-2022-0411

Code Behaviors & Features

Detect and mitigate CVE-2021-4238 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 1.1.1

Fixed versions

  • 1.1.1

Solution

Upgrade to version 1.1.1 or above.

Impact 9.1 CRITICAL

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H

Learn more about CVSS

Weakness

  • CWE-331: Insufficient Entropy

Source file

go/github.com/Masterminds/goutils/CVE-2021-4238.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Thu, 05 Feb 2026 00:18:39 +0000.