Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS05Njl3LXE3NHEtOWo4ds4AAwNT
Unsound API in `secp256k1` allows use-after-free and invalid deallocation from safe code
Because of incorrect bounds on method Secp256k1::preallocated_gen_new
it was possible to cause use-after-free from safe consumer code. It was also possible to "free" memory not allocated by the appropriate allocator.
The method takes a place for storing the context as a mutable reference and returns context containing that reference. Because the code internally uses unsafe
and the bounds were incorrect it was possible to create a context that outlived the passed reference (e.g. 'static
). Because the context can alternatively carry heap-allocated pointer freed on drop it was possible to "deallocate" a pointer that wasn't returned from appropriate allocator. The code decides whether to free the memory based on type parameter but because of missing bound it was possible to construct the context with invalid parameter.
You are unaffected if you either
- don't call
Secp256k1::preallocated_gen_new
- manually checked that your usage of the method is sound
- upgraded to the patched version of
secp256k1
(recommended)
The patched version uses correct bounds which means it is API-breaking. This effectively means adopting the policy of Rust lang itself allowing API-breaking changes to fix soundness bugs. Note however that valid straigthforward usage of the code will continue to compile. Only unsound code or code that propagates the bound in custom generics will fail to compile. If the code is sound fixing the bounds should be sufficient to make the code compile.
See the GitHub issue for example "exploit" code and further discussion.
Permalink: https://github.com/advisories/GHSA-969w-q74q-9j8vJSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS05Njl3LXE3NHEtOWo4ds4AAwNT
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: almost 2 years ago
Updated: over 1 year ago
Identifiers: GHSA-969w-q74q-9j8v
References:
- https://github.com/rust-bitcoin/rust-secp256k1/issues/543
- https://rustsec.org/advisories/RUSTSEC-2022-0070.html
- https://github.com/advisories/GHSA-969w-q74q-9j8v
Blast Radius: 0.0
Affected Packages
cargo:secp256k1
Dependent packages: 394Dependent repositories: 3,786
Downloads: 20,275,878 total
Affected Version Ranges: >= 0.24.0, < 0.24.2, >= 0.23.0, < 0.23.5, >= 0.14.0, < 0.22.2
Fixed in: 0.24.2, 0.23.5, 0.22.2
All affected versions: 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.15.3, 0.15.4, 0.15.5, 0.16.0, 0.17.0, 0.17.1, 0.17.2, 0.18.0, 0.19.0, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0, 0.21.1, 0.21.2, 0.21.3, 0.22.0, 0.22.1, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.24.0, 0.24.1
All unaffected versions: 0.1.0, 0.1.1, 0.1.2, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4.0, 0.4.1, 0.4.2, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.7.0, 0.7.1, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5, 0.9.0, 0.9.1, 0.9.2, 0.10.0, 0.11.0, 0.11.1, 0.11.2, 0.11.3, 0.11.4, 0.11.5, 0.11.6, 0.12.0, 0.12.1, 0.12.2, 0.13.0, 0.22.2, 0.23.5, 0.24.2, 0.24.3, 0.25.0, 0.26.0, 0.27.0, 0.28.0, 0.28.1, 0.28.2, 0.29.0, 0.29.1, 0.30.0