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

Open
noplife wants to merge 1 commit from renovate/crate-rand-vulnerability into main
Collaborator

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: https://github.com/rust-random/rand/compare/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.

This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [rand](https://rust-random.github.io/book) ([source](https://github.com/rust-random/rand)) | dependencies | patch | `0.9.0` → `0.9.3` | --- ### Rand is unsound with a custom logger using rand::rng() [GHSA-cq8v-f236-94qc](https://github.com/advisories/GHSA-cq8v-f236-94qc) / [RUSTSEC-2026-0097](https://rustsec.org/advisories/RUSTSEC-2026-0097.html) <details> <summary>More information</summary> #### Details It has been reported (by @&#8203;lopopolo) that the `rand` library is [unsound](https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#soundness-of-code--of-a-library) (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](https://docs.rs/log/latest/log/#implementing-a-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](https://doc.rust-lang.org/stable/nomicon/references.html), the behaviour of optimized builds is hard to predict. #### Severity Low #### References - [https://github.com/rust-random/rand/pull/1763](https://github.com/rust-random/rand/pull/1763) - [https://github.com/rust-random/rand](https://github.com/rust-random/rand) - [https://rustsec.org/advisories/RUSTSEC-2026-0097.html](https://rustsec.org/advisories/RUSTSEC-2026-0097.html) This data is provided by [OSV](https://osv.dev/vulnerability/GHSA-cq8v-f236-94qc) and the [GitHub Advisory Database](https://github.com/github/advisory-database) ([CC-BY 4.0](https://github.com/github/advisory-database/blob/main/LICENSE.md)). </details> --- ### Rand is unsound with a custom logger using `rand::rng()` [GHSA-cq8v-f236-94qc](https://github.com/advisories/GHSA-cq8v-f236-94qc) / [RUSTSEC-2026-0097](https://rustsec.org/advisories/RUSTSEC-2026-0097.html) <details> <summary>More information</summary> #### Details It has been reported (by [@&#8203;lopopolo](https://github.com/lopopolo)) that the `rand` library is [unsound](https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#soundness-of-code--of-a-library) (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](https://docs.rs/log/latest/log/#implementing-a-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](https://doc.rust-lang.org/stable/nomicon/references.html), the behaviour of optimized builds is hard to predict. #### Severity Unknown #### References - [https://crates.io/crates/rand](https://crates.io/crates/rand) - [https://rustsec.org/advisories/RUSTSEC-2026-0097.html](https://rustsec.org/advisories/RUSTSEC-2026-0097.html) - [https://github.com/rust-random/rand/pull/1763](https://github.com/rust-random/rand/pull/1763) This data is provided by [OSV](https://osv.dev/vulnerability/RUSTSEC-2026-0097) and the [Rust Advisory Database](https://github.com/RustSec/advisory-db) ([CC0 1.0](https://github.com/rustsec/advisory-db/blob/main/LICENSE.txt)). </details> --- ### Release Notes <details> <summary>rust-random/rand (rand)</summary> ### [`v0.9.3`](https://github.com/rust-random/rand/releases/tag/0.9.3) [Compare Source](https://github.com/rust-random/rand/compare/0.9.2...0.9.3) This release back-ports a fix from v0.10. See also \[[#&#8203;1763](https://github.com/rust-random/rand/issues/1763)]. ##### Changes - Deprecate feature `log` ([#&#8203;1764](https://github.com/rust-random/rand/issues/1764)) - Replace usages of `doc_auto_cfg` ([#&#8203;1764](https://github.com/rust-random/rand/issues/1764)) **Full Changelog**: <https://github.com/rust-random/rand/compare/0.9.2...0.9.3> ### [`v0.9.2`](https://github.com/rust-random/rand/blob/HEAD/CHANGELOG.md#092---2025-07-20) [Compare Source](https://github.com/rust-random/rand/compare/0.9.1...0.9.2) ##### Deprecated - Deprecate `rand::rngs::mock` module and `StepRng` generator (\[[#&#8203;1634](https://github.com/rust-random/rand/issues/1634)]) ##### Additions - Enable `WeightedIndex<usize>` (de)serialization (\[[#&#8203;1646](https://github.com/rust-random/rand/issues/1646)]) ### [`v0.9.1`](https://github.com/rust-random/rand/blob/HEAD/CHANGELOG.md#091---2025-04-17) [Compare Source](https://github.com/rust-random/rand/compare/0.9.0...0.9.1) ##### Security and unsafe - Revise "not a crypto library" policy again ([#&#8203;1565]) - Remove `zerocopy` dependency from `rand` ([#&#8203;1579]) ##### Fixes - Fix feature `simd_support` for recent nightly rust ([#&#8203;1586]) ##### Changes - Allow `fn rand::seq::index::sample_weighted` and `fn IndexedRandom::choose_multiple_weighted` to return fewer than `amount` results ([#&#8203;1623]), reverting an undocumented change (\[[#&#8203;1382](https://github.com/rust-random/rand/issues/1382)]) to the previous release. ##### Additions - Add `rand::distr::Alphabetic` distribution. ([#&#8203;1587]) - Re-export `rand_core` ([#&#8203;1604]) [#&#8203;1565]: https://github.com/rust-random/rand/pull/1565 [#&#8203;1579]: https://github.com/rust-random/rand/pull/1579 [#&#8203;1586]: https://github.com/rust-random/rand/pull/1586 [#&#8203;1587]: https://github.com/rust-random/rand/pull/1587 [#&#8203;1604]: https://github.com/rust-random/rand/pull/1604 [#&#8203;1623]: https://github.com/rust-random/rand/pull/1623 [#&#8203;1634]: https://github.com/rust-random/rand/pull/1634 [#&#8203;1646]: https://github.com/rust-random/rand/pull/1646 </details> --- ### 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. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yODEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjI4MS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJzZWN1cml0eSJdfQ==-->
noplife force-pushed renovate/crate-rand-vulnerability from 4c88503a63 to 52624d4664 2026-07-29 02:56:38 +00:00 Compare
Author
Collaborator

Edited/Blocked Notification

Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.

You can manually request rebase by checking the rebase/retry box above.

⚠️ Warning: custom changes will be lost.

### Edited/Blocked Notification Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. You can manually request rebase by checking the rebase/retry box above. ⚠️ **Warning**: custom changes will be lost.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin renovate/crate-rand-vulnerability:renovate/crate-rand-vulnerability
git switch renovate/crate-rand-vulnerability

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff renovate/crate-rand-vulnerability
git switch renovate/crate-rand-vulnerability
git rebase main
git switch main
git merge --ff-only renovate/crate-rand-vulnerability
git switch renovate/crate-rand-vulnerability
git rebase main
git switch main
git merge --no-ff renovate/crate-rand-vulnerability
git switch main
git merge --squash renovate/crate-rand-vulnerability
git switch main
git merge --ff-only renovate/crate-rand-vulnerability
git switch main
git merge renovate/crate-rand-vulnerability
git push origin main
Sign in to join this conversation.
No description provided.