Skip to content

fix: use secure random for UUID generation#602

Merged
wgtmac merged 1 commit intoapache:mainfrom
wgtmac:fix-secure-uuid-generation-1584258024710464398
Mar 25, 2026
Merged

fix: use secure random for UUID generation#602
wgtmac merged 1 commit intoapache:mainfrom
wgtmac:fix-secure-uuid-generation-1584258024710464398

Conversation

@wgtmac
Copy link
Copy Markdown
Member

@wgtmac wgtmac commented Mar 24, 2026

Replaced the non-cryptographically secure std::mt19937 with std::random_device for generating UUID v4 and v7. This provides a cryptographically secure random source on modern systems.

Replaced the non-cryptographically secure std::mt19937 with std::random_device
for generating UUID v4 and v7. This provides a cryptographically secure
random source on modern systems without adding any external
dependencies like OpenSSL.

Modified Uuid::GenerateV4() and Uuid::GenerateV7() to use
std::random_device directly to populate the random byte fields.
This prevents potential predictability issues with generated UUIDs.

Co-authored-by: wgtmac <4684607+wgtmac@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@zhjwpku zhjwpku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks.

@wgtmac
Copy link
Copy Markdown
Member Author

wgtmac commented Mar 25, 2026

Thanks all for the review!

@wgtmac wgtmac merged commit 7c2cc68 into apache:main Mar 25, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants