CVE-2021-3538 Overview
A critical insecure random number generation vulnerability was discovered in the github.com/satori/go.uuid Go library. The flaw exists in versions from commit 0ef6afb2f6cdd6cdaeee3885a95099c63f18fc8c to d91630c8510268e75203009fe7daf2b8e1d60c45. Due to insecure randomness in the g.rand.Read function, the generated UUIDs are predictable for an attacker, potentially allowing session hijacking, authentication bypass, or other security compromises in applications relying on UUID uniqueness and unpredictability.
Critical Impact
Predictable UUID generation allows attackers to guess or forge valid UUIDs, potentially compromising authentication tokens, session identifiers, and other security-critical identifiers in affected applications.
Affected Products
- Satori UUID library for Go (github.com/satori/go.uuid)
- Applications using affected commits between 0ef6afb2f6cdd6cdaeee3885a95099c63f18fc8c and d91630c8510268e75203009fe7daf2b8e1d60c45
- Go projects with transitive dependencies on the vulnerable satori/go.uuid versions
Discovery Timeline
- 2021-06-02 - CVE-2021-3538 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2021-3538
Vulnerability Analysis
The vulnerability stems from a cryptographic weakness in the UUID generation implementation within the Satori go.uuid library. The g.rand.Read function responsible for generating random bytes for UUIDs does not use a cryptographically secure random number generator (CSPRNG). This weakness falls under CWE-338 (Use of Cryptographically Weak Pseudo-Random Number Generator).
UUIDs are frequently used as security-critical identifiers in web applications, including session tokens, API keys, password reset tokens, and unique resource identifiers. When these values are predictable, attackers can enumerate or guess valid identifiers, leading to unauthorized access or impersonation attacks.
The vulnerability is exploitable remotely without any authentication or user interaction, making it particularly dangerous for internet-facing applications. An attacker who understands the weak randomness pattern can potentially predict future UUIDs or reconstruct past ones.
Root Cause
The root cause of this vulnerability is the use of a weak pseudo-random number generator (PRNG) in the g.rand.Read function. Instead of utilizing Go's crypto/rand package which provides cryptographically secure randomness, the implementation relied on a predictable source of entropy. This design flaw allows an attacker with knowledge of the internal state or sufficient observations of generated UUIDs to predict subsequent values.
Attack Vector
The attack vector is network-based and requires no privileges or user interaction. An attacker can exploit this vulnerability by:
- Observing multiple UUIDs generated by a target application
- Analyzing the pattern to determine the internal state of the weak PRNG
- Predicting future UUIDs or calculating past UUIDs
- Using predicted UUIDs to forge authentication tokens, hijack sessions, or access protected resources
The vulnerability manifests in the g.rand.Read function where random bytes are generated for UUID creation. Instead of using a cryptographically secure random number generator, the implementation uses a weak PRNG that produces predictable output. For technical details, refer to the GitHub Issue Discussion #73 and the Snyk Vulnerability Report.
Detection Methods for CVE-2021-3538
Indicators of Compromise
- Applications generating UUIDs with observable patterns or repetition
- Unexpected session hijacking or authentication bypass incidents
- Evidence of attackers accessing resources using predicted identifiers
- Anomalous API activity with sequential or predictable request identifiers
Detection Strategies
- Audit Go project dependencies using go list -m all to identify use of github.com/satori/go.uuid
- Implement Software Composition Analysis (SCA) tools to detect vulnerable library versions
- Review application logs for suspicious patterns in UUID-based authentication attempts
- Use static analysis tools to identify direct usage of the vulnerable g.rand.Read function
Monitoring Recommendations
- Enable detailed logging for authentication and session management systems
- Monitor for unusual patterns in token generation and validation failures
- Implement anomaly detection for resource access patterns that might indicate UUID prediction
- Configure alerts for multiple failed authentication attempts with UUID-based tokens
How to Mitigate CVE-2021-3538
Immediate Actions Required
- Audit all Go projects for dependencies on github.com/satori/go.uuid
- Replace the vulnerable satori/go.uuid library with a maintained alternative such as github.com/google/uuid
- Regenerate any security-critical tokens or identifiers that may have been compromised
- Review and rotate session tokens, API keys, and other UUID-based credentials
Patch Information
The satori/go.uuid library appears to be unmaintained. Organizations should migrate to actively maintained UUID libraries for Go that use cryptographically secure random number generation. The recommended replacement is github.com/google/uuid which properly implements secure randomness.
For additional technical details, consult the Red Hat Bug Report #1954376 and the Snyk Vulnerability Report.
Workarounds
- Migrate to github.com/google/uuid or another maintained UUID library with secure randomness
- If immediate migration is not possible, implement additional entropy sources for critical identifiers
- Add rate limiting to prevent attackers from observing large numbers of generated UUIDs
- Implement additional validation layers for UUID-based authentication mechanisms
# Replace vulnerable satori/go.uuid with google/uuid
go get github.com/google/uuid
# Update import statements in Go files
# Old: import "github.com/satori/go.uuid"
# New: import "github.com/google/uuid"
# Verify the dependency change
go mod tidy
go list -m all | grep uuid
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


