# OpenID4VP: X.509 chain validation accepts a forged certificate that reuses a trusted anchor's Subject DN without verifying its signature

OpenID4VP's ChainBuilder accepted a forged self-signed cert as trusted because it matched the anchor's Subject DN string without verifying signatures, enabling forged credential acceptance.

- Payout: Research
- Severity: high
- Program: OpenID4VP
- Found by: devdotbo
- Disclosed: 2026-11-19
- CVE: CVE-2026-75522
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-4c2f-96cf-f5fc
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-4c2f-96cf-f5fc
- Tags: area:oss domain:oss impact:integrity kind:research platform:ghsa sev:high tech:nodejs technique:incomplete-fix technique:source-review vuln:auth-bypass vuln:crypto

**Target:** X.509 chain validation in TrustEvaluator / ChainBuilder (npm @openeudi/openid4vp)
**Root cause:** ChainBuilder.tryBuild() terminated chain building on Subject DN string equality with a trust anchor instead of cryptographic closure, returning the chain without calling verifySignature against the anchor's public key. TrustEvaluator additionally fell back to anchors[0] when serialNumber matching failed.
**Steps:**
1. Mint a self-signed certificate whose Subject DN string equals a trusted anchor's Subject DN: `selfSigned({ subject: trustedAnchor.subject })`
2. Call `new ChainBuilder().build(impostor, [trustedAnchor])`
3. The `while (current.subject !== anchor.subject)` guard exits immediately on DN equality, skipping `verifySignature(current, anchor)`
4. Chain is returned as valid; TrustEvaluator.evaluate() returns success and attributes the forged leaf to the real anchor's metadata via the anchors[0] fallback
5. Sign a forged credential with the impostor's private key and present it to a relying party
**How found:** Code review of the private RFC 5280 validator: noticed the `while (current.subject !== anchor.subject)` loop guard provides a second exit path that bypasses the signature-verified closure branch (`if (!issuer) verifySignature(current, anchor)`), and that per-cert checks operate only on the attacker-controlled cert.
**Exploitation:** Attacker mints a self-signed cert copying a trusted anchor's Subject DN, signs a forged mdoc/SD-JWT VC credential with its private key, and presents it via OpenID4VP. The relying party's TrustEvaluator.evaluate() returns a trusted result, so the forged credential is accepted as issued by a genuine authority, enabling impersonation of a trusted issuer in eIDAS/EUDI deployments.
**Escalation:** Secondary fallback in TrustEvaluator (anchors[0] when serialNumber match fails) attributes the forged leaf to a real anchor's trustedAuthorityIds/provenance, strengthening the false trust signal.
**Insight:** In chain builders, any loop-exit condition other than cryptographic closure is a bypass: audit every `while`/`break` that terminates on identity fields (DN, serial, issuer string) rather than a verified signature, and check for silent fallbacks like anchors[0] that mask mismatches.

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

**Self-signed cert reusing anchor Subject DN**

```
// Attacker mints a self-signed cert reusing a trusted anchor's Subject DN.
const impostor = selfSigned({ subject: trustedAnchor.subject /* string */ });
// Vulnerable: resolves to a valid chain [impostor] with no signature check.
await new ChainBuilder().build(impostor, [trustedAnchor]);
```

