Miggo Logo

CVE-2025-9288: sha.js is missing type checks leading to hash rewind and passing on crafted data

N/A

CVSS Score

Basic Information

EPSS Score
0.24348%
Published
8/21/2025
Updated
8/21/2025
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
-
Package NameEcosystemVulnerable VersionsFirst Patched Version
sha.jsnpm<= 2.4.112.4.12

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot 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
The vulnerability lies in the `update` method of the `Hash` class. The original implementation did not properly validate the `data` input. It only checked for strings, leaving it vulnerable to crafted objects. An attacker could provide an object with a manipulated `length` property (e.g., `{ length: -3 }`) to rewind the internal state of the hash calculation. This could be exploited to create hash collisions, where different inputs produce the same hash. The patch addresses this by using the `to-buffer` library, which ensures the input is always converted to a safe Buffer, thus preventing the state manipulation.

WAF Protection Rules

WAF Rule

### Summ*ry T*is is t** s*m* *s [**S*-*pq*-**pm-**r*](*ttps://*it*u*.*om/*rows*ri*y/*ip**r-**s*/s**urity/**visori*s/**S*-*pq*-**pm-**r*) *ut just *or `s**.js`, *s it **s its own impl*m*nt*tion. Missin* input typ* ****ks l*** to it **l*ul*tin* inv*l

Reasoning

T** *n*lysis o* t** provi*** s**urity **visory *n* t** *sso*i*t** *ommit `****************************************` points *ir**tly to t** `**s*.prototyp*.up**t*` *un*tion in `**s*.js` *s t** sour** o* t** vuln*r**ility. T** vuln*r**ility is * *l*ssi