Vulnerabilities in pkg:golang/github.com/Masterminds/goutils

PACKAGE
Advisory Identifier: GHSA-xg2h-wx96-xgxr
Advisory Summary

CVE-2021-4238 is a LOW randomalphanumeric and cryptorandomalphanumeric are not vulnerability (CWE-331: Insufficient Entropy) affecting Github.com/Masterminds/goutils libraries in the Go ecosystem. The issue involves randomalphanumeric and cryptorandomalphanumeric are not as random as they should be. Remediation is available by upgrading affected packages to version 1.1.1.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/github.com/Masterminds/goutils

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:golang/github.com/Masterminds/goutils. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-xg2h-wx96-xgxr CVE-2021-4238 LOW RandomAlphaNumeric and CryptoRandomAlphaNumeric are not as random as they should be
GHSA-3839-6r69-m497 - CRITICAL Duplicate Advisory: GoUtils's randomly-generated alphanumeric strings contain significantly less entropy than expected

CVE-2021-4238 at a Glance

CVE Identifier CVE-2021-4238
GHSA Identifier GHSA-xg2h-wx96-xgxr
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-331: Insufficient Entropy
Affected Product Github.com/Masterminds/goutils
Package Ecosystem Go
Published Date
Last Updated

How to Fix CVE-2021-4238

To remediate this vulnerability, upgrade all affected Github.com/Masterminds/goutils dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/Masterminds/goutils fixed: 1.1.1
Upgrade github.com/Masterminds/goutils to 1.1.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/Masterminds/goutils

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-4238, inspect your project dependencies for Github.com/Masterminds/goutils:

inspect dependencies for github.com/Masterminds/goutils

Analyze the terminal output to locate any version of Github.com/Masterminds/goutils in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.1.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-331: Insufficient Entropy, where the product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others. In Github.com/Masterminds/goutils, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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`.)

CVE-2021-4238 Affected Github.com/Masterminds/goutils Versions

1 component(s)
Fixed Versions:
1.1.1
Product / Package Ecosystem Affected Versions Fixed Version
github.com/Masterminds/goutils
Go
< 1.1.1
1.1.1

References

Frequently Asked Questions

What is CVE-2021-4238?
CVE-2021-4238 is a security vulnerability in Github.com/Masterminds/goutils involving RandomAlphaNumeric and CryptoRandomAlphaNumeric are not as random as they should be under CWE-331: Insufficient Entropy.
Which Github.com/Masterminds/goutils versions are affected?
Affected versions include releases prior to 1.1.1 across affected packages: github.com/Masterminds/goutils.
What version fixes CVE-2021-4238?
Upgrading to 1.1.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/Masterminds/goutils affected?
Yes, github.com/Masterminds/goutils is affected in releases prior to 1.1.1. Upgrade your dependency to 1.1.1 or later.
What CWE is associated with CVE-2021-4238?
CVE-2021-4238 is classified under CWE-331: Insufficient Entropy (The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.).
How can I check Go dependencies for CVE-2021-4238?
Run the dependency tree command: 'inspect dependencies for github.com/Masterminds/goutils'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-xg2h-wx96-xgxr",
  "modified" : "2026-01-23T22:52:01Z",
  "published" : "2021-05-21T16:26:06Z",
  "aliases" : [ "CVE-2021-4238" ],
  "summary" : "RandomAlphaNumeric and CryptoRandomAlphaNumeric are not as random as they should be",
  "details" : "### Impact\n\nA security-sensitive bug was discovered by Open Source Developer *Erik Sundell of Sundell Open Source Consulting AB*.\n\nThe 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.\n\nThis 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.\n\nThe 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.\n\n### Patches\n\nThis issue has been corrected in v1.1.1.\n\n### Workarounds\n\nIf 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`.)",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/Masterminds/goutils"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.1.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Masterminds/goutils/security/advisories/GHSA-xg2h-wx96-xgxr"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-4238"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Masterminds/goutils/commit/869801f20f9f1e7ecdbdb6422049d8241270d5e1"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Masterminds/goutils/commit/f1923532a168b8203bfe956d8cd3b17ebece5982"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Masterminds/goutils"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Masterminds/goutils/releases/tag/v1.1.1"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2022-0411"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-331" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-21T14:36:56Z",
    "nvd_published_at" : null
  }
}