Описание
sha.js is missing type checks leading to hash rewind and passing on crafted data
Summary
This is the same as GHSA-cpq7-6gpm-g9rc but just for sha.js, as it has its own implementation.
Missing 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.
Details
See PoC
PoC
Output:
Or just:
Impact
- 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. - Value miscalculation, e.g. a collision is generated by
{ length: buf.length, ...buf, 0: buf[0] + 256 }This will result in the same hash as ofbuf, but can be treated by other code differently (e.g. bn.js) - DoS on
{length:'1e99'} - 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)
Ссылки
- https://github.com/browserify/sha.js/security/advisories/GHSA-95m3-7q98-8xr5
- https://nvd.nist.gov/vuln/detail/CVE-2025-9288
- https://github.com/browserify/sha.js/pull/78
- https://github.com/browserify/sha.js/commit/f2a258e9f2d0fcd113bfbaa49706e1ac0d979ba5
- https://lists.debian.org/debian-lts-announce/2025/09/msg00016.html
- https://www.cve.org/CVERecord?id=CVE-2025-9287
Пакеты
sha.js
<= 2.4.11
2.4.12
Связанные уязвимости
Improper Input Validation vulnerability in sha.js allows Input Data Manipulation.This issue affects sha.js: through 2.4.11.
Improper Input Validation vulnerability in sha.js allows Input Data Manipulation.This issue affects sha.js: through 2.4.11.
Improper Input Validation vulnerability in sha.js allows Input Data Manipulation.This issue affects sha.js: through 2.4.11.
Missing type checks leading to hash rewind and passing on crafted data
Improper Input Validation vulnerability in sha.js allows Input Data Ma ...