CVE-2025-9288: sha.js Critical Vulnerability Due to Missing Type Checks
Summary
CVE-2025-9288: sha.js is missing type checks leading to hash rewind and passing on crafted data. Affects sha.js versions < 2.4.12. Fixed in 2.4.12. How to fix ↓
Also tracked for
- node-sha.js · Debian:11
The same CVE-2025-9288 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
sha.js is a widely used JavaScript library that provides cryptographic hash functions, including SHA-256. It is commonly utilized in various applications for secure data handling and integrity verification. However, the library has a critical vulnerability that arises from missing input type checks, which can lead to severe security issues.
Vulnerability Detail
The vulnerability in sha.js stems from its lack of input type validation, allowing attackers to manipulate the hash calculation process. This can result in hash state rewinding, where a tagged hash can be transformed into an untagged hash, leading to potential data integrity issues. Additionally, attackers can exploit this flaw to generate collisions, causing different inputs to produce the same hash output. The implications of this vulnerability are significant, as it can lead to denial of service (DoS) attacks and even private key extraction in cryptographic libraries, compromising the security of the entire system.
How To Fix
Minimum fixed version
2.4.12
This is the first release that contains the fix.
npm install sha.js@2.4.12
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, you can implement input validation in your application to ensure that only valid data types are passed to the sha.js functions. For example, you can check the type of input before processing it:
const validateInput = (input) => {
if (typeof input !== 'string' && !Buffer.isBuffer(input)) {
throw new Error('Invalid input type.');
}
};
const sha256 = (...messages) => {
messages.forEach(validateInput);
const hash = sha('sha256');
messages.forEach((m) => hash.update(m));
return hash.digest('hex');
};
Conclusion
The vulnerability identified as CVE-2025-9288 in the sha.js library poses significant security risks due to missing input type checks. It is crucial for developers to update to the patched version and implement necessary input validations to safeguard their applications.
See every vulnerability recorded for sha.js →
FAQ
CVE-2025-9288 is a critical vulnerability in the sha.js library that allows attackers to exploit missing input type checks, leading to hash state rewinding and potential data integrity issues.
You can check if your application is affected by using Vulert, which monitors open-source vulnerabilities in your software. Visit Vulert Scanner to analyze your package-lock.json without needing to sign up.
The risks include hash state rewinding, value miscalculations, denial of service attacks, and potential private key extraction, which can compromise the security of cryptographic operations.
To fix this vulnerability, update the sha.js package to version 2.4.12 or later by running the command: npm install sha.js@2.4.12.
If immediate updates are not possible, implement input validation in your application to ensure only valid data types are processed by sha.js functions.