# node-forge: RSA PKCS#1 v1.5 signature forgery via extra elements in nested DigestAlgorithm

node-forge's PKCS#1 v1.5 verify ignored extra elements in the nested DigestAlgorithm, letting e=3 keys forge signatures for arbitrary messages without the private key.

- Payout: Research
- Severity: high
- Program: node-forge
- Found by (vendor credit): George Chen
- Found by: geo-chen
- Disclosed: 2026-12-01
- CVE: CVE-2026-85393
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-2g46-22mc-6gwp
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-2g46-22mc-6gwp
- Tags: area:oss domain:oss impact:integrity kind:research platform:ghsa sev:high tech:nodejs technique:incomplete-fix technique:parser-differential technique:source-review vuln:crypto vuln:signature-replay

**Target:** RSA signature verification (publicKey.verify, X.509/PKCS#7 verification) in lib/rsa.js
**Root cause:** asn1.validate() against digestInfoValidator ignored extra children of the nested DigestAlgorithm SEQUENCE; the prior CVE-2026-33894 fix only counted elements of the outer DigestInfo SEQUENCE, leaving attacker-chosen bytes inside an accepted DigestInfo.
**Steps:**
1. Recover the EMSA-PKCS1-v1_5 block as signature^e mod n for a 2048-bit key with SHA-256.
2. Observe the block: `00 01 FF...FF 00 30 81 F2 30 81 CD 06 09 60 86 48 01 65 03 04 02 01 05 00 04 81 BD <189 bytes> 04 20 <SHA-256(m)>` — an extra element after the OID and NULL params.
3. For an e=3 key, use the 189 free bytes to find a signature whose cube has this form for any message, without the private key.
4. Call `publicKey.verify(digest, signature)`; before 1.4.1 it returns true.
5. After 1.4.1 verification throws 'ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.'
**How found:** Noticed the CVE-2026-33894 fix only checked the outer DigestInfo SEQUENCE element count; asn1.validate() ignores extra children of the nested DigestAlgorithm SEQUENCE, so elements after the OID/NULL were neither validated nor counted — giving free attacker bytes inside an accepted DigestInfo.
**Exploitation:** Attacker with only the victim's e=3 RSA public key crafts a signature whose cube yields a DigestInfo containing an attacker-chosen extra element plus the target message digest; node-forge accepts it as valid, forging signatures for arbitrary messages without the private key.
**Insight:** When a parser-based signature check is patched by counting elements, check every nested SEQUENCE for unvalidated trailing children; free bytes inside an accepted structure plus a small exponent (e=3) enable Bleichenbacher-style forgery. Compare re-encoded expected bytes rather than validating parsed structure.

## Proof of concept (copied exactly from the original report)

**Forged EMSA-PKCS1-v1_5 block with extra DigestAlgorithm element**

```
00 01 FF FF FF FF FF FF FF FF 00
    30 81 F2                          DigestInfo SEQUENCE
       30 81 CD                       DigestAlgorithm SEQUENCE
          06 09 60 86 48 01 65 03 04 02 01   sha256 OID
          05 00                       NULL parameters
          04 81 BD <189 bytes>        extra element (attacker-chosen bytes)
       04 20 <SHA-256(m)>             digest
```

