{"id":"GHSA-xg2h-wx96-xgxr","revision":"e134f66ca91e47a88ec941f7c4ea415f","records":[{"revision":"e134f66ca91e47a88ec941f7c4ea415f","observedAt":"2026-10-24T13:19:41.952+00:00","statement":{"source":"osv","id":"GHSA-xg2h-wx96-xgxr","aliases":["CVE-2021-4238","GHSA-3839-6r69-m497","GO-2022-0411"],"title":"RandomAlphaNumeric and CryptoRandomAlphaNumeric are not as random as they should be","description":"### 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`.)","state":0,"publishedAt":"2021-05-21T16:26:06+00:00","modifiedAt":"2026-09-10T03:49:15.0011423+00:00","affected":[{"ecosystem":"Go","name":"github.com/Masterminds/goutils","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0"},{"kind":"fixed","version":"1.1.1"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[{"system":"Publisher rating","vector":null,"score":null,"severity":"LOW"}],"references":["https://github.com/Masterminds/goutils/security/advisories/GHSA-xg2h-wx96-xgxr","https://nvd.nist.gov/vuln/detail/CVE-2021-4238","https://github.com/Masterminds/goutils/commit/869801f20f9f1e7ecdbdb6422049d8241270d5e1","https://github.com/Masterminds/goutils/commit/f1923532a168b8203bfe956d8cd3b17ebece5982","https://github.com/Masterminds/goutils","https://github.com/Masterminds/goutils/releases/tag/v1.1.1","https://pkg.go.dev/vuln/GO-2022-0411"],"sourceUrl":"https://github.com/advisories/GHSA-xg2h-wx96-xgxr","license":"GitHub Advisory Database · CC-BY-4.0","key":"osv:GHSA-xg2h-wx96-xgxr","identifiers":["GHSA-xg2h-wx96-xgxr","CVE-2021-4238","GHSA-3839-6r69-m497","GO-2022-0411"]},"retained":false,"historicalAffected":[]}],"coverage":[]}