CVE-2024-49364: Tiny secp256k1 Tiny-secp256k1 Vulnerable To Private Key Vulnerability

HIGH
Advisory Identifier: GHSA-7mc2-6phr-23xc
CWE-522
Published
Advisory Summary

CVE-2024-49364 is a HIGH tiny-secp256k1 vulnerable to private key vulnerability (CWE-522: Insufficiently Protected Credentials) affecting Tiny secp256k1 libraries in the npm ecosystem. The issue involves tiny-secp256k1 vulnerable to private key extraction when signing a malicious json-stringifyable message in bundled environment. Remediation is available by upgrading affected packages to version 1.1.7.

CVE-2024-49364 at a Glance

CVE Identifier CVE-2024-49364
GHSA Identifier GHSA-7mc2-6phr-23xc
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-522: Insufficiently Protected Credentials
Affected Product Tiny secp256k1
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2024-49364

To remediate this vulnerability, upgrade all affected Tiny 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.

tiny-secp256k1 fixed: 1.1.7
npm install tiny-secp256k1@1.1.7
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls tiny-secp256k1

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-49364, inspect your project dependencies using npm:

npm ls tiny-secp256k1

Analyze the terminal output to locate any version of Tiny secp256k1 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.1.7), your application is affected.

Note: The npm ls tiny-secp256k1 command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-522: Insufficiently Protected Credentials, where the product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval. In Tiny 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

### Summary Private key can be extracted on signing a malicious JSON-stringifiable object, when global Buffer is [`buffer` package](https://www.npmjs.com/package/buffer) ### Details This affects only environments where `require('buffer')` is <https://npmjs.com/buffer> E.g.: browser bundles, React Native apps, etc. `Buffer.isBuffer` check can be bypassed, resulting in `k` reuse for different messages, leading to private key extraction over a single invalid message (and a second one for which any message/signature could be taken, e.g. previously known valid one) v2.x is unaffected as it verifies input to be an actual `Uint8Array` instance Such a message can be constructed for any already known message/signature pair, meaning that the attack needs only a single malicious message being signed for a full key extraction While signing unverified attacker-controlled messages would be problematic itself (and exploitation of this needs such a scenario), signing a single message still should not leak the private key Also, message validation could have the same bug (out of scope for this report, but could be possible in some situations), which makes this attack more likely when used in a chain https://github.com/bitcoinjs/tiny-secp256k1/pull/140 is a subtle fix for this ### PoC This code deliberately doesn't provide `funnyBuffer` and `extractTiny` for now, could be updated later ```js import secp256k1 from 'tiny-secp256k1' import crypto from 'crypto' const key = crypto.randomBytes(32) const msg0 = crypto.randomBytes(32) const sig0 = secp256k1.sign(msg0, key).toString('hex') const msg1 = funnyBuffer(msg0) const sig1 = secp256k1.sign(msg1, key).toString('hex') const restored = extractTiny(msg0, sig0, sig1) console.log('Guesses:', JSON.stringify(restored, undefined, 2)) const recheck = (k) => secp256k1.sign(msg0, Buffer.from(k, 'hex')).toString('hex') === sig0 console.log('Rechecked:', JSON.stringify(restored.filter(recheck))) console.log('Actual key', key.toString('hex')) ``` Output: ```console Guesses: [ "8f351953047e6b149e0595547e7d10a8a1edc61bd519b5b2514202a495e434ed", "ebc81e1632a1b3255589ba84364949a0a6fd0229444519765570706d394671dd" ] Rechecked: ["ebc81e1632a1b3255589ba84364949a0a6fd0229444519765570706d394671dd"] Actual key ebc81e1632a1b3255589ba84364949a0a6fd0229444519765570706d394671dd ``` ### Impact Full private key extraction when signing a single malicious message (that passes `JSON.stringify`/`JSON.parse` and can come from network)

CVE-2024-49364 Affected Tiny secp256k1 Versions

1 component(s)
Fixed Versions:
1.1.7
Product / Package Ecosystem Affected Versions Fixed Version
tiny-secp256k1
npm
< 1.1.7
1.1.7

References

Frequently Asked Questions

What is CVE-2024-49364?
CVE-2024-49364 is a security vulnerability in Tiny secp256k1 involving tiny-secp256k1 vulnerable to private key extraction when signing a malicious JSON-stringifyable message in bundled environment under CWE-522: Insufficiently Protected Credentials.
Which Tiny secp256k1 versions are affected?
Affected versions include releases prior to 1.1.7 across affected packages: tiny-secp256k1.
What version fixes CVE-2024-49364?
Upgrading to 1.1.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is tiny-secp256k1 affected?
Yes, tiny-secp256k1 is affected in releases prior to 1.1.7. Upgrade your dependency to 1.1.7 or later.
What CWE is associated with CVE-2024-49364?
CVE-2024-49364 is classified under CWE-522: Insufficiently Protected Credentials (The product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval.).
How can I check npm dependencies for CVE-2024-49364?
Run the dependency tree command: 'npm ls tiny-secp256k1'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-7mc2-6phr-23xc",
  "modified" : "2025-07-01T13:13:29Z",
  "published" : "2025-06-30T17:43:39Z",
  "aliases" : [ "CVE-2024-49364" ],
  "summary" : "tiny-secp256k1 vulnerable to private key extraction when signing a malicious JSON-stringifyable message in bundled environment",
  "details" : "### Summary\n\nPrivate key can be extracted on signing a malicious JSON-stringifiable object, when global Buffer is [`buffer` package](https://www.npmjs.com/package/buffer)\n\n### Details\n\nThis affects only environments where `require('buffer')` is <https://npmjs.com/buffer>\nE.g.: browser bundles, React Native apps, etc.\n\n`Buffer.isBuffer` check can be bypassed, resulting in `k` reuse for different messages, leading to private key extraction over a single invalid message (and a second one for which any message/signature could be taken, e.g. previously known valid one)\n\nv2.x is unaffected as it verifies input to be an actual `Uint8Array` instance\n\nSuch a message can be constructed for any already known message/signature pair, meaning that the attack needs only a single malicious message being signed for a full key extraction\n\nWhile signing unverified attacker-controlled messages would be problematic itself (and exploitation of this needs such a scenario), signing a single message still should not leak the private key\n\nAlso, message validation could have the same bug (out of scope for this report, but could be possible in some situations), which makes this attack more likely when used in a chain\n\nhttps://github.com/bitcoinjs/tiny-secp256k1/pull/140 is a subtle fix for this\n\n### PoC\n\nThis code deliberately doesn't provide `funnyBuffer` and `extractTiny` for now, could be updated later\n\n```js\nimport secp256k1 from 'tiny-secp256k1'\nimport crypto from 'crypto'\n\nconst key = crypto.randomBytes(32)\n\nconst msg0 = crypto.randomBytes(32)\nconst sig0 = secp256k1.sign(msg0, key).toString('hex')\n\nconst msg1 = funnyBuffer(msg0)\nconst sig1 = secp256k1.sign(msg1, key).toString('hex')\n\nconst restored = extractTiny(msg0, sig0, sig1)\nconsole.log('Guesses:', JSON.stringify(restored, undefined, 2))\nconst recheck = (k) => secp256k1.sign(msg0, Buffer.from(k, 'hex')).toString('hex') === sig0\nconsole.log('Rechecked:', JSON.stringify(restored.filter(recheck)))\n\nconsole.log('Actual key', key.toString('hex'))\n```\n\nOutput:\n```console\nGuesses: [\n  \"8f351953047e6b149e0595547e7d10a8a1edc61bd519b5b2514202a495e434ed\",\n  \"ebc81e1632a1b3255589ba84364949a0a6fd0229444519765570706d394671dd\"\n]\nRechecked: [\"ebc81e1632a1b3255589ba84364949a0a6fd0229444519765570706d394671dd\"]\nActual key ebc81e1632a1b3255589ba84364949a0a6fd0229444519765570706d394671dd\n```\n\n### Impact\n\nFull private key extraction when signing a single malicious message (that passes `JSON.stringify`/`JSON.parse` and can come from network)",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "tiny-secp256k1"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.1.7"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.1.6"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/bitcoinjs/tiny-secp256k1/security/advisories/GHSA-7mc2-6phr-23xc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-49364"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bitcoinjs/tiny-secp256k1/pull/140"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/bitcoinjs/tiny-secp256k1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-522" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-06-30T17:43:39Z",
    "nvd_published_at" : "2025-07-01T03:15:21Z"
  }
}