Unsound MediumRUSTSEC-2023-0033 · borsh
RUSTSEC-2023-0033: Parsing borsh messages with ZST which are not-copy/clone is unsound
Short answerborsh has an API that can cause undefined behaviour from safe code: Parsing borsh messages with ZST which are not-copy/clone is unsound. Fixed in 0.10.4, 1.0.0-alpha.1.
| Crate | borsh |
|---|---|
| Type | Unsound (memory-corruption) |
| Affected versions | Before 0.10.4; from 0.11.0 before 1.0.0-alpha.1. |
| Fixed in | 0.10.4, 1.0.0-alpha.1 |
| Severity | Medium (GitHub rating) |
| Published | 2023-04-12 |
| Last changed | 2024-09-23 |
| Also known as | GHSA-fjx5-qpf4-xjf2 |
What to do
- See which version you have:
cargo tree -i borsh(it also shows which of your dependencies pulls it in). - Update within your version requirement:
cargo update -p borsh. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for exampleborsh = "1.0.0-alpha.1") or update the dependency that pulls it in. - Check again with
cargo audit, or paste your Cargo.lock into our Cargo.toml checker.
Details from the advisory
Affected versions of borsh cause undefined behavior when zero-sized-types (ZST) are parsed and the Copy/Clone traits are not implemented/derived. For instance if 1000 instances of a ZST are deserialized, and the ZST is not copy (this can be achieved through a singleton), then accessing/writing to deserialized data will cause a segmentation fault.
There is currently no way for borsh to read data without also providing a Rust type. Therefore, if not ZST are used for serialization, then you are not affected by this issue.
References
- Package: crates.io/crates/borsh
- Advisory: rustsec.org/advisories/RUSTSEC-2023-0033.html
- Report: github.com/near/borsh-rs/issues/19
- Web: github.com/near/borsh-rs/pull/136
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 crateborsh: security historyEvery advisory for this crate, and whether it is safe to use today.Read it next →Did this answer your question?