Email me

Rust advisories / ouroboros

Unsound MediumRUSTSEC-2023-0042 · ouroboros

RUSTSEC-2023-0042: Ouroboros is Unsound

Short answerouroboros has an API that can cause undefined behaviour from safe code: Ouroboros is Unsound. Fixed in 0.16.0.

Crateouroboros
TypeUnsound
Affected versionsBefore 0.16.0.
Fixed in0.16.0
SeverityMedium (GitHub rating)
Published2023-06-11
Last changed2023-11-08
Also known asGHSA-87mf-9wg6-ppf8

What to do

  1. See which version you have: cargo tree -i ouroboros (it also shows which of your dependencies pulls it in).
  2. Update within your version requirement: cargo update -p ouroboros. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for example ouroboros = "0.16.0") or update the dependency that pulls it in.
  3. Check again with cargo audit, or paste your Cargo.lock into our Cargo.toml checker.

Details from the advisory

Summary

Ouroboros has a soundness problem, but a fix has been implemented in 0.16.0.

More details:

In 0.15.0, Ouroboros works internally by creating a struct where all uses of 'this are replaced by 'static. However, a recent addition to Miri checks that references passed to functions are valid during the entire execution of the function, even when those references are passed inside a struct. This poses an issue for dropping self-referencing values, as the reference becomes invalid during the dropping process. Effectively, since self-referencing structs are not allowed in vanilla Rust, there is no allowance for dropping data during a function that has also been given a reference to that data. There's usually no way to pass a and &a to the same function.

A fix was attempted, where the struct would be turned in to a raw byte array and only transformed back into the underlying data type inside each function. This is allowable as a reference can be created and die over the body of a function, as long as the reference was created inside the function. However, this is also not sound if the original struct contains padding. There is no way to initialize padding bytes to a known value that Miri will accept, so when it is cast to an array some of the bytes contain uninitialized values. This is not acceptable (despite the fact that these bytes are never read) due to the potential for optimizations that may read from the uninitialized bytes. Besides which, this fix does not allow for template or constant parameters as there is no way to check the size of a templated type without giving specific, concrete values for the template parameters.

The final solution was to use this fix while wrapping the raw byte array in MaybeUninit<>.

References

From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.

Up next

Same crateouroboros: security historyEvery advisory for this crate, and whether it is safe to use today.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ