GHSA-969w-q74q-9j8v: Secp256k1 Unsound API Vulnerability
MODERATEGHSA-969w-q74q-9j8v is a MODERATE unsound api vulnerability (General Security Weakness) affecting Secp256k1 libraries in the crates.io ecosystem. The issue involves unsound api in `secp256k1` allows use-after-free and invalid deallocation from safe code. Remediation is available by upgrading affected packages to version 0.22.2, 0.23.5, 0.24.2.
GHSA-969w-q74q-9j8v at a Glance
How to Fix GHSA-969w-q74q-9j8v
To remediate this vulnerability, upgrade all affected Secp256k1 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade secp256k1 to 0.22.2
Upgrade secp256k1 to 0.23.5
Upgrade secp256k1 to 0.24.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for secp256k1
How to Check if You Are Affected
To determine whether your application is affected by GHSA-969w-q74q-9j8v, inspect your project dependencies for Secp256k1:
inspect dependencies for secp256k1
Analyze the terminal output to locate any version of Secp256k1 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.22.2), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under General Security Weakness. In Secp256k1, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-969w-q74q-9j8v Affected Secp256k1 Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
secp256k1
|
crates.io |
≥ 0.14.0
< 0.22.2
|
0.22.2
|
|
secp256k1
|
crates.io |
≥ 0.23.0
< 0.23.5
|
0.23.5
|
|
secp256k1
|
crates.io |
≥ 0.24.0
< 0.24.2
|
0.24.2
|
References
Frequently Asked Questions
What is GHSA-969w-q74q-9j8v?
Which Secp256k1 versions are affected?
What version fixes GHSA-969w-q74q-9j8v?
Is secp256k1 affected?
What CWE is associated with GHSA-969w-q74q-9j8v?
How can I check crates.io dependencies for GHSA-969w-q74q-9j8v?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-969w-q74q-9j8v",
"modified" : "2022-12-08T16:00:29Z",
"published" : "2022-12-08T16:00:29Z",
"aliases" : [ ],
"summary" : "Unsound API in `secp256k1` allows use-after-free and invalid deallocation from safe code",
"details" : "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.\n\nThe 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.\n\nYou are unaffected if you either\n\n* don't call `Secp256k1::preallocated_gen_new`\n* manually checked that your usage of the method is sound\n* upgraded to the patched version of `secp256k1` (recommended)\n\nThe 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.\n\nSee the [GitHub issue](https://github.com/rust-bitcoin/rust-secp256k1/issues/543) for example \"exploit\" code and further discussion.\n",
"severity" : [ ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "secp256k1"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.14.0"
}, {
"fixed" : "0.22.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "secp256k1"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.23.0"
}, {
"fixed" : "0.23.5"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "secp256k1"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.24.0"
}, {
"fixed" : "0.24.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/rust-bitcoin/rust-secp256k1/issues/543"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/rust-bitcoin/rust-secp256k1"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2022-0070.html"
} ],
"database_specific" : {
"cwe_ids" : [ ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-12-08T16:00:29Z",
"nvd_published_at" : null
}
}