Read the docs
TI-2022-26700 Aliases GHSA-969w-q74q-9j8v

Unsound API in `secp256k1` allows use-after-free and invalid deallocation from safe code

Priority LOW 38Published · Updated

Key facts

Attack vector
—
Privileges required
—
User interaction
—
Attack complexity
—
Impact type
—
Confidentiality · integrity · availability
—
Fix status
Fixed

No CVSS vector from any source. Fix status from GitHub.

Summary

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](https://github.com/rust-bitcoin/rust-secp256k1/issues/543) for example "exploit" code and further discussion.

Why it matters now

Fix Fixed secp256k1 (crates.io): 0.22.2, 0.23.5, 0.24.2

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
—secp256k1 (crates.io)0.14.0 to before 0.22.20.22.2Patch availableGHSA-969w-q74q-9j8v
—secp256k1 (crates.io)0.23.0 to before 0.23.50.23.5Patch availableGHSA-969w-q74q-9j8v
—secp256k1 (crates.io)0.24.0 to before 0.24.20.24.2Patch availableGHSA-969w-q74q-9j8v
  • secp256k1 (crates.io) Vendor— Affected 0.14.0 to before 0.22.2 Fixed in 0.22.2 Patch available GHSA-969w-q74q-9j8v
  • secp256k1 (crates.io) Vendor— Affected 0.23.0 to before 0.23.5 Fixed in 0.23.5 Patch available GHSA-969w-q74q-9j8v
  • secp256k1 (crates.io) Vendor— Affected 0.24.0 to before 0.24.2 Fixed in 0.24.2 Patch available GHSA-969w-q74q-9j8v

Remediation

  • Fix · GHSA-969w-q74q-9j8v secp256k1 (crates.io) Fixed in 0.22.2 Advisory →
  • Fix · GHSA-969w-q74q-9j8v secp256k1 (crates.io) Fixed in 0.23.5 Advisory →
  • Fix · GHSA-969w-q74q-9j8v secp256k1 (crates.io) Fixed in 0.24.2 Advisory →

Timeline

  1. 2026-10-03 Threatist record created from GHSA-969w-q74q-9j8v

References

Sources

This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences