CVE-2025-9287: cipher-base Hash Rewind Vulnerability Due to Missing Type Checks
Summary
CVE-2025-9287: cipher-base is missing type checks, leading to hash rewind and passing on crafted data. Affects cipher-base versions < 1.0.5. Fixed in 1.0.5. How to fix ↓
Also tracked for
- node-cipher-base · Debian:11
The same CVE-2025-9287 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
cipher-base is a widely used package in the Node.js ecosystem that provides a base class for cryptographic hash functions. It is utilized in various libraries, including create-hash and crypto-browserify, to facilitate secure data handling. However, it has been identified that cipher-base lacks proper input type checks, making it susceptible to vulnerabilities that can compromise data integrity and security.
Vulnerability Detail
The vulnerability arises from missing input type checks in the npm create-hash polyfill of Node.js createHash. This oversight allows for the calculation of invalid hash values, potentially leading to hash state rewinding and the acceptance of maliciously crafted data. Attackers can exploit this by sending specially formatted JSON data that can manipulate the hash state, resulting in collisions, denial of service, and even private key extraction in cryptographic libraries. The vulnerability can be triggered by inputs like {length: -x} or {length: '1e99', causing unexpected behavior in the hashing process.
How To Fix
Minimum fixed version
1.0.5
This is the first release that contains the fix.
npm install cipher-base@1.0.5
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, ensure that all inputs to the hashing functions are validated and sanitized before processing. For example, you can implement a check to confirm that inputs are instances of Buffer, TypedArray, or DataView before passing them to the hashing function. Here is a sample code snippet:
const createHash = require('create-hash/browser.js');
const { randomBytes } = require('crypto');
const sha256 = (...messages) => {
const hash = createHash('sha256');
messages.forEach((m) => {
if (Buffer.isBuffer(m) || ArrayBuffer.isView(m)) {
hash.update(m);
} else {
throw new Error('Invalid input type');
}
});
return hash.digest('hex');
};
Conclusion
The cipher-base vulnerability CVE-2025-9287 poses significant risks due to its potential for hash state manipulation and data integrity issues. It is crucial for developers to update their packages and implement proper input validation to safeguard their applications.
See every vulnerability recorded for cipher-base →
FAQ
CVE-2025-9287 is a vulnerability in the cipher-base package that allows for hash state rewinding due to missing input type checks.
Exploitation of this vulnerability can lead to incorrect hash calculations, denial of service, and potential exposure of sensitive data.
You should update to version 1.0.5 or later to mitigate the risk associated with this vulnerability.
Yes, you can implement input validation to ensure that only valid types are processed by the hashing functions.
You can use Vulert, which monitors and alerts for open-source vulnerabilities in your software. You can check your application using the Vulert playground without any signup.