{"id":"GHSA-87mf-9wg6-ppf8","aliases":["RUSTSEC-2023-0042"],"status":"published","title":"Ouroboros is Unsound","description":"In 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 \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.","facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"published":"2023-06-11T12:00:00Z","modified":"2023-11-08T04:17:14Z","fixes":[{"ecosystem":"crates.io","package":"ouroboros","fixed_in":["0.16.0"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"crates.io","package":"ouroboros","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.16.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"ouroboros","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.16.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"ouroboros","ranges":[{"type":"SEMVER","events":[{"introduced":"0.0.0-0"},{"fixed":"0.16.0"}]}]}],"references":[{"url":"https://github.com/joshua-maros/ouroboros/issues/88","tags":["web","report"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2023-0042.html","tags":["web","advisory"]},{"url":"https://github.com/advisories/GHSA-87mf-9wg6-ppf8"},{"url":"https://github.com/joshua-maros/ouroboros","tags":["package"]},{"url":"https://crates.io/crates/ouroboros","tags":["package"]}],"sources":{"ghsa":[{"id":"GHSA-87mf-9wg6-ppf8","title":"Ouroboros is Unsound","description":"In 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 \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.","status":"published","published":"2023-06-12T18:52:23Z","modified":"2023-06-16T17:45:05Z","updated_at":"2026-11-02T14:36:55.184601Z"}],"osv":[{"id":"GHSA-87mf-9wg6-ppf8","title":"Ouroboros is Unsound","description":"In 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 \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.","status":"published","published":"2023-06-12T18:52:23Z","modified":"2023-11-08T04:17:14.008776Z","updated_at":"2026-11-02T15:46:42.077781Z"},{"id":"RUSTSEC-2023-0042","title":"Ouroboros is Unsound","description":"## Summary\n\nOuroboros has a soundness problem, but a fix has been implemented in 0.16.0.\n\n## More details:\n\nIn 0.15.0, Ouroboros works internally by creating a struct where all \nuses of 'this are replaced by 'static. However, a recent addition to \nMiri checks that references passed to functions are valid during the \nentire execution of the function, even when those references are \npassed inside a struct. This poses an issue for dropping \nself-referencing values, as the reference becomes invalid during the \ndropping process. Effectively, since self-referencing structs are \nnot allowed in vanilla Rust, there is no allowance for dropping data\nduring a function that has also been given a reference to that data. \nThere's 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 \nbyte array and only transformed back into the underlying data type \ninside each function. This is allowable as a reference can be \ncreated and die over the body of a function, as long as the \nreference was created inside the function. However, this is also \nnot sound if the original struct contains padding. There is no \nway to initialize padding bytes to a known value that Miri will \naccept, so when it is cast to an array some of the bytes contain \nuninitialized values. This is not acceptable (despite the fact \nthat these bytes are never read) due to the potential for \noptimizations that may read from the uninitialized bytes. Besides \nwhich, this fix does not allow for template or constant parameters \nas there is no way to check the size of a templated type without \ngiving specific, concrete values for the template parameters.\n\nThe final solution was to use this fix while wrapping the raw byte\narray in `MaybeUninit\u003c\u003e`.","status":"published","published":"2023-06-11T12:00:00Z","modified":"2023-11-08T04:17:14.008776Z","updated_at":"2026-11-02T15:53:39.971022Z"}]}}
