{"id":"GHSA-5vhg-9xg4-cv9m","summary":"tiny-secp256k1 allows for verify() bypass when running in bundled environment","details":"### Summary\n\nA malicious JSON-stringifyable message can be made passing on `verify()`, 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 strange objects being accepted as `message`, and those messages could trick `verify()` into returning false-positive `true` values\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\nThere are some restrictions though (also depending on the known message/signature), but not very limiting, see PoC for example\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 `reencode` for now, could be updated later\n\n```js\nimport { randomBytes } from 'crypto'\nimport tiny from 'tiny-secp256k1' // 1.1.6\n\n// Random keypair\nconst privateKey = randomBytes(32)\nconst publicKey = tiny.pointFromScalar(privateKey)\n\nconst valid = Buffer.alloc(32).fill(255) // let's sign a static buffer\nconst signature = tiny.sign(valid, privateKey)\n\n// Prevent processing any unverified data by fail-closed throwing\nfunction verified(data, signature) {\n  if (!Buffer.isBuffer(data)) data = Buffer.from(data, 'hex')\n  if (!tiny.verify(data, publicKey, signature)) throw new Error('Signature invalid!')\n  return new Uint8Array(data)\n}\n\nfunction safeProcess(payload) {\n  const totally = JSON.parse(payload) // e.g. json over network\n\n  const message = verified(totally, signature)\n  console.log(message instanceof Uint8Array)\n  console.log(Buffer.from(message).toString('utf8'))  \n}\n\nconst payload = reencode(valid, \"Secure contain protect\")\nsafeProcess(payload)\n```\n\nOutput (after being bundled):\n```console\ntrue\nSecure contain protect����\n```\n\n### Impact\n\nMalicious messages could crafted to be verified from a given known valid message/signature pair","aliases":["CVE-2024-49365"],"modified":"2025-07-01T13:13:38Z","published":"2025-06-30T17:44:14Z","database_specific":{"cwe_ids":["CWE-347"],"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2025-06-30T17:44:14Z","nvd_published_at":"2025-07-01T03:15:21Z"},"references":[{"type":"WEB","url":"https://github.com/bitcoinjs/tiny-secp256k1/security/advisories/GHSA-5vhg-9xg4-cv9m"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-49365"},{"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":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/06/GHSA-5vhg-9xg4-cv9m/GHSA-5vhg-9xg4-cv9m.json","last_known_affected_version_range":"\u003c= 1.1.6"}}],"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"}]}