Summary
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.
Impact
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
secp256k1 to 0.22.2 or later; secp256k1 to 0.23.5 or later; secp256k1 to 0.24.2 or later
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is GHSA-969W-Q74Q-9J8V? GHSA-969W-Q74Q-9J8V is a medium-severity security vulnerability in secp256k1 (rust), affecting versions >= 0.14.0, < 0.22.2. It is fixed in 0.22.2, 0.23.5, 0.24.2.
- Which versions of secp256k1 are affected by GHSA-969W-Q74Q-9J8V? secp256k1 (rust) versions >= 0.14.0, < 0.22.2 is affected.
- Is there a fix for GHSA-969W-Q74Q-9J8V? Yes. GHSA-969W-Q74Q-9J8V is fixed in 0.22.2, 0.23.5, 0.24.2. Upgrade to this version or later.
- Is GHSA-969W-Q74Q-9J8V exploitable, and should I be worried? Whether GHSA-969W-Q74Q-9J8V is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-969W-Q74Q-9J8V is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-969W-Q74Q-9J8V?
- Upgrade
secp256k1to 0.22.2 or later - Upgrade
secp256k1to 0.23.5 or later - Upgrade
secp256k1to 0.24.2 or later
- Upgrade