Skip to content

Conversation

@thevilledev
Copy link
Contributor

Motivation

Salt generation used io.Reader.Read and ignored short reads, allowing zero-padded, low-entropy salts when the RNG is swapped.

Changes

Switch salt generation to use io.ReadFull. Performance impact should be negligible.

Prevents CWE-331 "Insufficient Entropy". Fails fast on RNG anomalies.

Testing

Add a short-EOF RNG test to verify failure. All tests pass.

Backwards Compatibility

No API changes. Credential creation will now error if the RNG short-reads instead of silently proceeding.

Switch salt generation to io.ReadFull to reject short reads and
prevent zero-padded, low-entropy salts when the RNG is swapped.
Add a short-EOF RNG test to verify failure.

Signed-off-by: Ville Vesilehto <[email protected]>
Copy link
Owner

@dhui dhui left a comment

Choose a reason for hiding this comment

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

Thanks for the find and fix @thevilledev !
EDIT: also thanks for adding a test to prevent a regression!

@dhui dhui merged commit 08498e3 into dhui:master Sep 21, 2025
3 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.

2 participants