CVE-2024-48930
Description
secp256k1-node is a Node.js binding for an Optimized C library for EC operations on curve secp256k1. In elliptic-based version, loadUncompressedPublicKey has a check that the public key is on the curve. Prior to versions 5.0.1, 4.0.4, and 3.8.1, however, loadCompressedPublicKey is missing that check. That allows the attacker to use public keys on low-cardinality curves to extract enough information to fully restore the private key from as little as 11 ECDH sessions, and very cheaply on compute power. Other operations on public keys are also affected, including e.g. publicKeyVerify() incorrectly returning true on those invalid keys, and e.g. publicKeyTweakMul() also returning predictable outcomes allowing to restore the tweak. Versions 5.0.1, 4.0.4, and 3.8.1 contain a fix for the issue.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
secp256k1npm | >= 5.0.0, < 5.0.1 | 5.0.1 |
secp256k1npm | >= 4.0.0, < 4.0.4 | 4.0.4 |
secp256k1npm | < 3.8.1 | 3.8.1 |
Patches
38bd6446e000felliptic: fix key verification in loadCompressedPublicKey
3 files changed · +11 −1
lib/elliptic.js+4 −0 modified@@ -18,6 +18,10 @@ function loadCompressedPublicKey (first, xbuf) { let y = x.redSqr().redIMul(x).redIAdd(ecparams.b).redSqrt() if ((first === 0x03) !== y.isOdd()) y = y.redNeg() + // x*x*x + b = y*y + const x3 = x.redSqr().redIMul(x) + if (!y.redSqr().redISub(x3.redIAdd(ecparams.b)).isZero()) return null + return ec.keyPair({ pub: { x: x, y: y } }) }
package.json+1 −1 modified@@ -40,7 +40,7 @@ "node-gyp": "=10.1.0", "nyc": "^15.0.0", "prebuildify": "^6.0.1", - "prebuildify-cross": "github:fanatid/prebuildify-cross#9f7af67698f06e07d42304d9813a6f19aee5812c", + "prebuildify-cross": "^5.1.1", "standard": "^14.3.1", "tap-dot": "^2.0.0", "tape": "^4.10.1",
test/publickey.js+6 −0 modified@@ -32,6 +32,12 @@ module.exports = (t, secp256k1) => { invalidLength[0] = publicKey.compressed[0] t.false(secp256k1.publicKeyVerify(invalidLength), 'invalid length') + const zeroUncompressed = Buffer.concat([Buffer.from([0x04]), Buffer.alloc(64)]) + t.false(secp256k1.publicKeyVerify(zeroUncompressed), 'zero uncompressed') + + const zeroCompressed = Buffer.concat([Buffer.from([0x02]), Buffer.alloc(32)]) + t.false(secp256k1.publicKeyVerify(zeroCompressed), 'zero compressed') + t.end() })
e256905ee649elliptic: fix key verification in loadCompressedPublicKey
2 files changed · +14 −0
lib/elliptic/index.js+4 −0 modified@@ -20,6 +20,10 @@ function loadCompressedPublicKey (first, xBuffer) { var y = x.redSqr().redIMul(x).redIAdd(ecparams.b).redSqrt() if ((first === 0x03) !== y.isOdd()) y = y.redNeg() + // x*x*x + b = y*y + const x3 = x.redSqr().redIMul(x) + if (!y.redSqr().redISub(x3.redIAdd(ecparams.b)).isZero()) return null + return ec.keyPair({ pub: { x: x, y: y } }) }
test/publickey.js+10 −0 modified@@ -171,6 +171,16 @@ module.exports = function (t, secp256k1) { t.end() }) + t.test('zero key', function (t) { + const zeroUncompressed = Buffer.concat([Buffer.from([0x04]), Buffer.alloc(64)]) + t.false(secp256k1.publicKeyVerify(zeroUncompressed), 'zero uncompressed') + + const zeroCompressed = Buffer.concat([Buffer.from([0x02]), Buffer.alloc(32)]) + t.false(secp256k1.publicKeyVerify(zeroCompressed), 'zero compressed') + + t.end(); + }) + util.repeat(t, 'random tests', util.env.repeat, function (t) { var privateKey = util.getPrivateKey() var publicKey = util.getPublicKey(privateKey)
9a15fff274f8elliptic: fix key verification in loadCompressedPublicKey
3 files changed · +11 −1
lib/elliptic.js+4 −0 modified@@ -18,6 +18,10 @@ function loadCompressedPublicKey (first, xbuf) { let y = x.redSqr().redIMul(x).redIAdd(ecparams.b).redSqrt() if ((first === 0x03) !== y.isOdd()) y = y.redNeg() + // x*x*x + b = y*y + const x3 = x.redSqr().redIMul(x) + if (!y.redSqr().redISub(x3.redIAdd(ecparams.b)).isZero()) return null + return ec.keyPair({ pub: { x: x, y: y } }) }
package.json+1 −1 modified@@ -40,7 +40,7 @@ "node-gyp": "=10.1.0", "nyc": "^15.0.0", "prebuildify": "^6.0.1", - "prebuildify-cross": "github:fanatid/prebuildify-cross#9f7af67698f06e07d42304d9813a6f19aee5812c", + "prebuildify-cross": "^5.1.1", "standard": "^14.3.1", "tap-dot": "^2.0.0", "tape": "^4.10.1",
test/publickey.js+6 −0 modified@@ -32,6 +32,12 @@ module.exports = (t, secp256k1) => { invalidLength[0] = publicKey.compressed[0] t.false(secp256k1.publicKeyVerify(invalidLength), 'invalid length') + const zeroUncompressed = Buffer.concat([Buffer.from([0x04]), Buffer.alloc(64)]) + t.false(secp256k1.publicKeyVerify(zeroUncompressed), 'zero uncompressed') + + const zeroCompressed = Buffer.concat([Buffer.from([0x02]), Buffer.alloc(32)]) + t.false(secp256k1.publicKeyVerify(zeroCompressed), 'zero compressed') + t.end() })
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
8- github.com/advisories/GHSA-584q-6j8j-r5pmghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2024-48930ghsaADVISORY
- github.com/cryptocoinjs/secp256k1-node/blob/6d3474b81d073cc9c8cc8cfadb580c84f8df5248/lib/elliptic.jsnvdWEB
- github.com/cryptocoinjs/secp256k1-node/blob/6d3474b81d073cc9c8cc8cfadb580c84f8df5248/lib/elliptic.jsnvdWEB
- github.com/cryptocoinjs/secp256k1-node/commit/8bd6446e000fa59df3cda0ae3e424300747ea5ednvdWEB
- github.com/cryptocoinjs/secp256k1-node/commit/9a15fff274f83a6ec7f675f1121babcc0c42292fnvdWEB
- github.com/cryptocoinjs/secp256k1-node/commit/e256905ee649a7caacc251f7c964667195a52221nvdWEB
- github.com/cryptocoinjs/secp256k1-node/security/advisories/GHSA-584q-6j8j-r5pmnvdWEB
News mentions
0No linked articles in our index yet.