CVE-2025-9288: sha.js is missing type checks leading to hash rewind and passing on crafted data
N/A
Basic Information
Technical Details
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
sha.js | npm | <= 2.4.11 | 2.4.12 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The analysis of the provided security advisory and the associated commit f2a258e9f2d0fcd113bfbaa49706e1ac0d979ba5
points directly to the Hash.prototype.update
function in hash.js
as the source of the vulnerability. The vulnerability is a classic case of improper input validation (CWE-20). The function was designed to accept data for hashing but failed to account for malicious, non-standard inputs. The Proof of Concept demonstrates that by passing an object with a negative length
property to the update
function, an attacker can effectively rewind the hashing process, leading to a scenario where different inputs can produce identical hashes. This fundamentally breaks the cryptographic security guarantees of the hashing algorithm. The fix, which involves replacing a simple string check with a call to the to-buffer
library, confirms that the weakness was in the handling of the input data. The to-buffer
library is designed to safely convert various JavaScript types into a Buffer, thereby sanitizing the input before it is processed by the hashing logic. Therefore, any runtime profile or stack trace captured during the exploitation of this vulnerability would show the Hash.update
function as the entry point for the malicious data.
Vulnerable functions
Hash.update
hash.js