net.quic: use crypto.rand instead of rand for connection IDs and TLS random - #28165
Open
quaesitor-scientiam wants to merge 1 commit into
Open
net.quic: use crypto.rand instead of rand for connection IDs and TLS random#28165quaesitor-scientiam wants to merge 1 commit into
quaesitor-scientiam wants to merge 1 commit into
Conversation
…random dial() generated original_dcid, scid, and the TLS 1.3 ClientHello.random using the plain `rand` module, which defaults to WyRandRNG — a fast, explicitly non-cryptographic PRNG. RFC 9000 §8.1 expects real entropy in connection IDs, and ClientHello.random has its own TLS security properties. Swap to crypto.rand, an OS-backed CSPRNG with an identical bytes() signature already used elsewhere in the codebase (e.g. crypto.ecdsa). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dial()invlib/net/quic/conn.vgeneratedoriginal_dcid,scid, and the TLS 1.3ClientHello.randomusing the plainrandmodule, which defaults toWyRandRNG— a fast, explicitly non-cryptographic PRNG (vlib/rand/rand.v).ClientHello.randomhas its own TLS 1.3 security properties — neither is satisfied by a non-cryptographic PRNG.crypto.rand, this repo's existing OS-backed CSPRNG (getrandomon Linux, platform equivalents on Windows/BSD/Solaris/macOS), which already exposes an identicalpub fn bytes(bytes_needed int) ![]u8signature and is already used elsewhere in the codebase (e.g.crypto.ecdsa). This is a drop-in swap — no call-site changes needed.Checked for the same pattern elsewhere:
vlib/net/http/request.valso imports plainrand, but only forrand.ulid()on a multipart form boundary — not security-relevant (needs uniqueness, not unpredictability), and out of scope for this fix.Test plan
./vnewfresh and ran./vnew -silent test vlib/net/quic/— 54/54 passed, both before and after the change (confirmed viagit stashthat the interspersed "v3 compiler memory usage" messages are pre-existing noise from an unrelated experimentalv3compiler bench, unaffected by this change)./vnew fmt -w vlib/net/quic/conn.v— already cleanvlib/net/quic/seedsrandglobally or depends ondial()'s specific randomness for determinismquic's re-exportedrand🤖 Generated with Claude Code