{"id":"CVE-2021-4238","aliases":["CVE-2021-4238","GHSA-3839-6r69-m497","GHSA-xg2h-wx96-xgxr","GO-2022-0411"],"related":["CGA-cx55-8x76-2v73","RHSA-2023:0540"],"kind":"vulnerability","state":"published","title":"Insufficient randomness in github.com/Masterminds/goutils","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"## Duplicate Advisory\nThis advisory has been withdrawn because it is a duplicate of GHSA-xg2h-wx96-xgxr. This link is maintained to preserve external references.\n\n## Original Description\nRandomly-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.","format":"markdown","source":"ghsa"},{"lang":"en","text":"### 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`.)","format":"markdown","source":"ghsa"},{"lang":"es","text":"Las cadenas alfanuméricas generadas aleatoriamente contienen significativamente menos entropía de la esperada. Las funciones RandomAlphaNumeric y CryptoRandomAlphaNumeric siempre devuelven cadenas que contienen al menos un dígito del 0 al 9. Esto reduce significativamente la cantidad de entropía en cadenas cortas generadas por estas funciones.","source":"nvd"}],"published":"2021-05-21T16:26:06.000Z","modified":"2026-09-10T03:49:50.235Z","severity":{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H","score":9.1,"rating":"CRITICAL"},"severities":[{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H","score":9.1,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H","score":9.1,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"rating","rating":"LOW"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H","score":9.1,"rating":"CRITICAL"}],"cwes":["CWE-331"],"affected":[{"ranges":[{"type":"semver","introduced":"0","fixed":"1.1.1","status":"affected"}],"vendor":"github.com/Masterminds/goutils","product":"github.com/Masterminds/goutils","package":"github.com/Masterminds/goutils","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.1.1"}],"ecosystem":"Go","package":"github.com/Masterminds/goutils","purl":"pkg:golang/github.com/Masterminds/goutils","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.1.1"}],"ecosystem":"Go","package":"github.com/Masterminds/goutils","purl":"pkg:golang/github.com/Masterminds/goutils","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.1.1"}],"ecosystem":"Go","package":"github.com/Masterminds/goutils","purl":"pkg:golang/github.com/Masterminds/goutils","source":"go"},{"ranges":[{"status":"affected","fixed":"1.1.1"}],"vendor":"goutils_project","product":"goutils","cpe":"cpe:2.3:a:goutils_project:goutils:*:*:*:*:*:go:*:*","source":"nvd"}],"references":[{"url":"https://github.com/Masterminds/goutils/commit/869801f20f9f1e7ecdbdb6422049d8241270d5e1","tags":["fix","patch","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://pkg.go.dev/vuln/GO-2022-0411","tags":["exploit","patch","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-4238","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/Masterminds/goutils","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/Masterminds/goutils/security/advisories/GHSA-xg2h-wx96-xgxr","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/Masterminds/goutils/commit/f1923532a168b8203bfe956d8cd3b17ebece5982","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/Masterminds/goutils/releases/tag/v1.1.1","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"Go","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"total","date":"2025-04-11T16:17:07.316Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-4238","url":"https://www.cve.org/CVERecord?id=CVE-2021-4238","licence":"CVE Terms of Use","modified":"2025-04-11T16:17:46.299Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3839-6r69-m497","url":"https://github.com/advisories/GHSA-3839-6r69-m497","licence":"CC-BY-4.0","modified":"2026-09-10T03:49:50.235Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-xg2h-wx96-xgxr","url":"https://github.com/advisories/GHSA-xg2h-wx96-xgxr","licence":"CC-BY-4.0","modified":"2026-09-10T03:49:15.001Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2022-0411","url":"https://pkg.go.dev/vuln/GO-2022-0411","licence":"CC-BY-4.0","modified":"2026-02-04T03:14:48.656Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-4238","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-4238","licence":"Public domain","modified":"2026-06-17T04:19:19.660Z"}],"updatedAt":"2026-11-25T22:58:08.020Z","epss":{"score":0.01408,"percentile":0.72854,"date":"2026-11-30T12:00:22.000Z"}}