{"id":"GHSA-7mc2-6phr-23xc","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 \u003chttps://npmjs.com/buffer\u003e\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) =\u003e 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)","aliases":["CVE-2024-49364"],"modified":"2025-07-01T13:13:29Z","published":"2025-06-30T17:43:39Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2025-06-30T17:43:39Z","nvd_published_at":"2025-07-01T03:15:21Z","cwe_ids":["CWE-522"],"severity":"HIGH"},"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"}],"affected":[{"package":{"name":"tiny-secp256k1","ecosystem":"npm","purl":"pkg:npm/tiny-secp256k1"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.1.7"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 1.1.6","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/06/GHSA-7mc2-6phr-23xc/GHSA-7mc2-6phr-23xc.json"}}],"schema_version":"1.9.0","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"}]}