openssl+ech: workaround for insecure handshakes

OpenSSL 4.0.0-dev supports ECH with one flaw. If peer verification
is not enabled, it will report SSL_ECH_STATUS_BAD_NAME on the ECH
status.

Provide a workaround in libcurl that checks the inner name used in
ECH was the peer's hostname, both verify peer and host are disabled
and then accept the BAD_NAME without failing the connect.

Fixes #20655
Reported-by: Dexter Gerig
Closes #20821
This commit is contained in:
Stefan Eissing 2026-03-05 13:56:49 +01:00 committed by Daniel Stenberg
parent b803dc9f20
commit 3c007d6351
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -4348,9 +4348,18 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf,
case SSL_ECH_STATUS_BAD_CALL:
status = "bad call (unexpected)";
break;
case SSL_ECH_STATUS_BAD_NAME:
status = "bad name (unexpected)";
case SSL_ECH_STATUS_BAD_NAME: {
struct ssl_primary_config *conn_config =
Curl_ssl_cf_get_primary_config(cf);
if(!conn_config->verifypeer && !conn_config->verifyhost &&
inner && !strcmp(inner, connssl->peer.hostname)) {
status = "bad name (tolerated without peer verification)";
rv = SSL_ECH_STATUS_SUCCESS;
}
else
status = "bad name (unexpected)";
break;
}
default:
status = "unexpected status";
infof(data, "ECH: unexpected status %d", rv);