sha.js is missing type checks leading to hash rewind and passing on crafted data
Critical severity
GitHub Reviewed
Published
Aug 20, 2025
in
browserify/sha.js
•
Updated Aug 26, 2025
Description
Published by the National Vulnerability Database
Aug 20, 2025
Published to the GitHub Advisory Database
Aug 21, 2025
Reviewed
Aug 21, 2025
Last updated
Aug 26, 2025
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
orstring
, 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
{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.{ length: buf.length, ...buf, 0: buf[0] + 256 }
This will result in the same hash as of
buf
, but can be treated by other code differently (e.g. bn.js){length:'1e99'}
References