GHSA-87MF-9WG6-PPF8
Vulnerability from github – Published: 2023-06-12 18:52 – Updated: 2023-06-16 17:45In 0.15.0 and prior, 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<>.
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "ouroboros"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.16.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [],
"github_reviewed": true,
"github_reviewed_at": "2023-06-12T18:52:23Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "In 0.15.0 and prior, Ouroboros works internally by creating a struct where all uses of \u0027this are replaced by \u0027static. 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\u0027s usually no way to pass a and \u0026a to the same function.\n\nA 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.\n\nThe final solution was to use this fix while wrapping the raw byte array in MaybeUninit\u003c\u003e.",
"id": "GHSA-87mf-9wg6-ppf8",
"modified": "2023-06-16T17:45:05Z",
"published": "2023-06-12T18:52:23Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/joshua-maros/ouroboros/issues/88"
},
{
"type": "PACKAGE",
"url": "https://github.com/joshua-maros/ouroboros"
},
{
"type": "WEB",
"url": "https://rustsec.org/advisories/RUSTSEC-2023-0042.html"
}
],
"schema_version": "1.4.0",
"severity": [],
"summary": "Ouroboros is Unsound"
}
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.