# CVE-2024-2466: TLS certificate check bypass with mbedTLS (reward request)

libcurl built with mbedTLS skipped mbedtls_ssl_set_hostname when connecting to an IP address, bypassing TLS certificate hostname verification entirely.

- Payout: $2,580
- Severity: medium
- Program: Internet Bug Bounty
- Found by (vendor credit): Frank Yueh
- Found by: frankyueh
- Disclosed: 2024-03-29
- CVE: CVE-2024-2466
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/2435482
- Library page: https://bugbountylibrary.com/r/h1%3A2435482
- Tags: area:oss domain:oss impact:integrity kind:bounty platform:hackerone sev:medium tech:curl technique:incomplete-fix technique:regression technique:source-review vuln:auth-bypass vuln:misconfiguration

**Target:** libcurl TLS backend (lib/vtls/mbedtls.c) and curl CLI
**Root cause:** mbedtls_ssl_set_hostname() sets both SNI and the CN/SAN verification name, but curl only called it when peer.sni was non-NULL; for IP-address peers sni is NULL, so the call was skipped and mbedTLS performed no hostname check.
**Steps:**
1. Build curl 8.6.0 against mbedTLS 2.28.7 (`./configure --with-mbedtls=/usr/local`)
2. Resolve a host: `host -t A www.example.org` -> 93.184.216.34
3. Connect by IP: `curl https://93.184.216.34`
4. Observe HTTP 404 response instead of `curl: (60) SSL: no alternative certificate subject name matches target host name`
5. Confirm `connssl->peer.sni` is NULL for CURL_SSL_PEER_IPV4/IPV6 in Curl_ssl_peer_init, so mbedtls_ssl_set_hostname is never invoked
**How found:** Author traced the mbedtls_ssl_set_hostname call site in mbed_connect_step1, noticed it was gated on connssl->peer.sni, then read Curl_ssl_peer_init and saw sni is only populated for CURL_SSL_PEER_DNS. Compared against the CVE-2016-3739 fix commit (which called set_hostname unconditionally) and the later 'keep peer name information together' commit that reintroduced the sni-only guard.
**Exploitation:** Attacker with a valid certificate for any domain (or MITM position) can serve TLS to a client that connects via IP address; since no hostname check occurs, the handshake succeeds and the client trusts the attacker's endpoint, enabling spoofing/impersonation of the intended IP-based service.
**Insight:** When a TLS API conflates SNI with certificate-name verification, gating the call on 'is this a DNS name' silently disables verification for IP peers; grep for conditional calls to hostname-setting APIs and check the regression history of prior CVEs in the same file.

