# Forge: RSA PKCS#1 v1.5 signature forgery via non-canonical DigestInfo encoding

node-forge's RSA PKCS#1 v1.5 verify accepted non-canonical BER DigestInfo encodings, letting attackers forge signatures for e=3 keys without the private key.

- Payout: Research
- Severity: high
- Program: node-forge
- Found by: orenyomtov
- Disclosed: 2026-11-10
- CVE: CVE-2026-119192
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-6qrw-m8cv-hcxf
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-6qrw-m8cv-hcxf
- Tags: area:oss domain:oss impact:integrity kind:research platform:ghsa sev:high tech:nodejs technique:parser-differential technique:source-review vuln:crypto

**Target:** RSA PKCS#1 v1.5 signature verification (publicKey.verify, X.509/PKCS#7)
**Root cause:** Verification parsed the recovered DigestInfo with the lenient BER parser asn1.fromDer() and validated structure with asn1.validate() without requiring canonical DER, leaving attacker-controlled slack bytes inside an accepted DigestInfo.
**Steps:**
1. Recover the EMSA-PKCS1-v1_5 block `00 01 FF..FF 00 || DigestInfo` for a target digest.
2. Craft a non-canonical DigestInfo, e.g. NULL parameters with content `30 33 30 0F <OID> 05 02 BE EF 04 20 <H>` or non-minimal length `30 81 31 30 0D <OID> 05 00 04 20 <H>`.
3. Use the slack bytes to construct a forged signature for an e=3 key (BERserk-style).
4. Call `publicKey.verify(digest, signature)`; pre-1.4.1 it returns true.
**How found:** Noticed verification used the lenient BER parser and structural validator rather than re-encoding the expected DigestInfo per RFC 8017 8.2.2, then tested non-canonical shapes (NULL params with content, non-minimal/indefinite lengths, padded OID subidentifiers) against verify().
**Exploitation:** For RSA keys with low public exponent e=3, attacker-controlled bytes in the non-canonical DigestInfo give room to construct a forged signature that verifies without the private key; affects publicKey.verify and X.509/PKCS#7 verification built on it.
**Insight:** When auditing signature verification, check whether the recovered DigestInfo is compared byte-for-byte against a re-encoded expected value or merely parsed structurally; lenient BER parsers accept slack bytes that enable Bleichenbacher/BERserk forgery on e=3 keys.

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

**Non-canonical DigestInfo encodings accepted by verifier**

```
NULL parameters with content:  30 33 30 0F <OID> 05 02 BE EF 04 20 <H>
    non-minimal DigestInfo length: 30 81 31 30 0D <OID> 05 00 04 20 <H>
    (canonical form:               30 31 30 0D <OID> 05 00 04 20 <H>)
```

