# Invalid handling of X509_verify_cert() internal errors in libssl (CVE-2021-4044)

OpenSSL 3.0 libssl mishandles negative X509_verify_cert() internal errors, returning unexpected SSL_ERROR_WANT_RETRY_VERIFY to clients, causing crashes or loops.

- Payout: $1,200
- Severity: medium
- Program: Internet Bug Bounty
- Found by (vendor credit): Tobias Nießen
- Found by: tniessen
- Disclosed: 2022-01-20
- CVE: CVE-2021-4044
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1455411
- Library page: https://bugbountylibrary.com/r/h1%3A1455411
- Tags: area:oss domain:oss impact:dos kind:bounty platform:hackerone sev:medium tech:linux technique:chained technique:source-review vuln:crypto

**Target:** OpenSSL 3.0.0 libssl client-side certificate verification (SSL_connect/SSL_do_handshake)
**Root cause:** libssl treats a negative (internal error) return from X509_verify_cert() as a retryable condition, surfacing SSL_ERROR_WANT_RETRY_VERIFY even though the app never set a cert verify callback; a second 3.0 bug makes X509_verify_cert() return internal error for valid chains lacking SAN under CA name constraints.
**Steps:**
1. Use OpenSSL 3.0.0 as a TLS client.
2. Server presents a chain where a cert lacks the Subject Alternative Name extension and the CA enforces name constraints, triggering X509_verify_cert() internal error.
3. Client calls SSL_connect()/SSL_do_handshake(); it does not indicate success.
4. SSL_get_error() returns SSL_ERROR_WANT_RETRY_VERIFY, unexpected since no SSL_CTX_set_cert_verify_callback() was set.
5. Application mishandles the unexpected code, e.g. crash or infinite retry loop.
**How found:** Reporter analyzed libssl's handling of X509_verify_cert() return values and combined it with a separate OpenSSL 3.0 chain-verification bug producing internal errors on valid chains.
**Exploitation:** Attacker controls a server and supplies a crafted certificate chain (no SAN, CA with name constraints) to an OpenSSL 3.0.0 client; the client's handshake handling misbehaves in an application-dependent way (crash, loop).
**Insight:** Audit how libraries map internal error codes to public API return values; unexpected error codes leaking to callers that never opted into a feature (here SSL_CTX_set_cert_verify_callback) can break application state machines.

