Lucene search

K
hackeroneKurohiroH1:1950627
HistoryApr 17, 2023 - 4:54 p.m.

curl: CVE-2023-28321: IDN wildcard match

2023-04-1716:54:15
kurohiro
hackerone.com
102
cve-2023-28321
rfc-6125
hostname validation

0.002 Low

EPSS

Percentile

56.6%

Summary:

curl /libcurl uses wildcards for validation during TLS communication, even if the hostname is an IDN.
Even if wildcards are present in the CN/SAN of the certificate, they must not be used to match if the hostname is an IDN.
This is described in [RFC-6125, section 6.4.3.][RFC]
[RFC]: https://datatracker.ietf.org/doc/html/rfc6125#section-6.4.3
You probably know that.
However, there was a problem with the implementation.
lib/vtls/hostcheck.c in the function โ€˜hostmatchโ€™ on lines 100-106.

  /* We require at least 2 dots in the pattern to avoid too wide wildcard
     match. */
  pattern_label_end = memchr(pattern, '.', patternlen);
  if(!pattern_label_end ||
     (memrchr(pattern, '.', patternlen) == pattern_label_end) ||
     strncasecompare(pattern, "xn--", 4))
    return pmatch(hostname, hostlen, pattern, patternlen);

I think strncasecompare(pattern, "xn--", 4)) is strncasecompare(hostname, "xn--", 4)).
pattern is a value that contains wildcards because it is CN/SAN.
In other words, it will not match โ€œxnโ€“โ€ because it will be a string containing wildcards.

Steps To Reproduce:

  1. Create a wildcard certificate.As an example, attach a certificate and private key with CN value of x*.example.local. {F2298301} {F2298300}
  2. openssl s_server -accept 443 -cert server.crt -key server.key -www
  3. Modify hosts so that the name resolution result of `xnโ€“l8j.example.localโ€˜ is the IP of your machine in order to perform the test in the local environment.
  4. curl https://%E3%81%82.example.local --cacert server.crt

When the above is executed, the communication succeeds even though it should result in a validation error.

Impact

Improper Validation of Certificate with Host Mismatch.