Описание
cipher-base is missing type checks, leading to hash rewind and passing on crafted data
Summary
This affects e.g. create-hash
(and crypto-browserify
), so I'll describe the issue against that package
Also affects create-hmac
and other packages
Node.js createHash
works only on strings or instances of Buffer, TypedArray, or DataView.
Missing input type checks (in npm create-hash
polyfill of Node.js createHash
) 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:
This works with:
But there are other types of input which lead to unchecked results
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, like GHSA-vjh7-7g9h-fjfh)
- Also, other typed arrays results are invalid, e.g. returned hash of
new Uint16Array(5)
is the same asnew Uint8Array(5)
, notnew Uint16Array(10)
as it should have been (and is in Node.jscrypto
) -- same for arrays with values non-zero, their hashes are just truncated to%256
instead of converted to correct bytelength
Пакеты
cipher-base
<= 1.0.4
1.0.5
Связанные уязвимости
Improper Input Validation vulnerability in cipher-base allows Input Data Manipulation.This issue affects cipher-base: through 1.0.4.
Improper Input Validation vulnerability in cipher-base allows Input Data Manipulation.This issue affects cipher-base: through 1.0.4.
Improper Input Validation vulnerability in cipher-base allows Input Data Manipulation.This issue affects cipher-base: through 1.0.4.
Improper Input Validation vulnerability in cipher-base allows Input Da ...
Уязвимость пакета cipher-base программной платформы Node.js, позволяющая нарушителю выполнить произвольный код