GHSA-xg2h-wx96-xgxr

Suggest an improvement
Source
https://github.com/advisories/GHSA-xg2h-wx96-xgxr
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2021/05/GHSA-xg2h-wx96-xgxr/GHSA-xg2h-wx96-xgxr.json
JSON Data
https://api.test.osv.dev/v1/vulns/GHSA-xg2h-wx96-xgxr
Aliases
Related
Published
2021-05-21T16:26:06Z
Modified
2024-09-11T06:13:42.199523Z
Summary
RandomAlphaNumeric and CryptoRandomAlphaNumeric are not as random as they should be
Details

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

Database specific
{
    "nvd_published_at": null,
    "cwe_ids": [],
    "severity": "LOW",
    "github_reviewed": true,
    "github_reviewed_at": "2021-05-21T14:36:56Z"
}
References

Affected packages

Go / github.com/Masterminds/goutils

Package

Name
github.com/Masterminds/goutils
View open source insights on deps.dev
Purl
pkg:golang/github.com/Masterminds/goutils

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
1.1.1