Skip to content

fix(security): Update Rust crate rand to 0.9.3 [SECURITY] - #22

Open
vxfemboy wants to merge 1 commit into
mainfrom
renovate/crate-rand-vulnerability
Open

fix(security): Update Rust crate rand to 0.9.3 [SECURITY]#22
vxfemboy wants to merge 1 commit into
mainfrom
renovate/crate-rand-vulnerability

Conversation

@vxfemboy

@vxfemboy vxfemboy commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Mirrored from Forgejo — originally by @noplife. https://virus.ad/vxfemboy/purrcrypt/pulls/27

This PR contains the following updates:

Package Type Update Change
rand (source) dependencies patch 0.9.00.9.3

Rand is unsound with a custom logger using rand::rng()

GHSA-cq8v-f236-94qc / RUSTSEC-2026-0097

More information

Details

It has been reported (by @​lopopolo) that the rand library is unsound (i.e. that safe code using the public API can cause Undefined Behaviour) when all the following conditions are met:

  • The log and thread_rng features are enabled
  • A custom logger is defined
  • The custom logger accesses rand::rng() (previously rand::thread_rng()) and calls any TryRng (previously RngCore) methods on ThreadRng
  • The ThreadRng (attempts to) reseed while called from the custom logger (this happens every 64 kB of generated data)
  • Trace-level logging is enabled or warn-level logging is enabled and the random source (the getrandom crate) is unable to provide a new seed

TryRng (previously RngCore) methods for ThreadRng use unsafe code to cast *mut BlockRng<ReseedingCore> to &mut BlockRng<ReseedingCore>. When all the above conditions are met this results in an aliased mutable reference, violating the Stacked Borrows rules. Miri is able to detect this violation in sample code. Since construction of aliased mutable references is Undefined Behaviour, the behaviour of optimized builds is hard to predict.

Severity

Low

References

This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).


Rand is unsound with a custom logger using rand::rng()

GHSA-cq8v-f236-94qc / RUSTSEC-2026-0097

More information

Details

It has been reported (by @​lopopolo) that the rand library is unsound (i.e. that safe code using the public API can cause Undefined Behaviour) when all the following conditions are met:

  • The log and thread_rng features are enabled
  • A custom logger is defined
  • The custom logger accesses rand::rng() (previously rand::thread_rng()) and calls any TryRng (previously RngCore) methods on ThreadRng
  • The ThreadRng (attempts to) reseed while called from the custom logger (this happens every 64 kB of generated data)
  • Trace-level logging is enabled or warn-level logging is enabled and the random source (the getrandom crate) is unable to provide a new seed

TryRng (previously RngCore) methods for ThreadRng use unsafe code to cast *mut BlockRng<ReseedingCore> to &mut BlockRng<ReseedingCore>. When all the above conditions are met this results in an aliased mutable reference, violating the Stacked Borrows rules. Miri is able to detect this violation in sample code. Since construction of aliased mutable references is Undefined Behaviour, the behaviour of optimized builds is hard to predict.

Severity

Unknown

References

This data is provided by OSV and the Rust Advisory Database (CC0 1.0).


Release Notes

rust-random/rand (rand)

v0.9.3

Compare Source

This release back-ports a fix from v0.10. See also [#​1763].

Changes

Full Changelog: rust-random/rand@0.9.2...0.9.3

v0.9.2

Compare Source

Deprecated
  • Deprecate rand::rngs::mock module and StepRng generator ([#​1634])
Additions
  • Enable WeightedIndex<usize> (de)serialization ([#​1646])

v0.9.1

Compare Source

Security and unsafe
  • Revise "not a crypto library" policy again (#​1565)
  • Remove zerocopy dependency from rand (#​1579)
Fixes
  • Fix feature simd_support for recent nightly rust (#​1586)
Changes
  • Allow fn rand::seq::index::sample_weighted and fn IndexedRandom::choose_multiple_weighted to return fewer than amount results (#​1623), reverting an undocumented change ([#​1382]) to the previous release.
Additions
  • Add rand::distr::Alphabetic distribution. (#​1587)
  • Re-export rand_core (#​1604)

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate.

@vxfemboy
vxfemboy force-pushed the renovate/crate-rand-vulnerability branch from 4c88503 to 52624d4 Compare July 29, 2026 02:56
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