From: Andreas Weigel Date: Wed, 18 Oct 2023 04:14:31 +0000 (+0000) Subject: Fix validation of certificates with CN=* (#1523) X-Git-Tag: SQUID_6_4~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12b8efc07ff74548d5582c4890f8bdb9057a1bb3;p=thirdparty%2Fsquid.git Fix validation of certificates with CN=* (#1523) The bug was discovered and detailed by Joshua Rogers at https://megamansec.github.io/Squid-Security-Audit/ where it was filed as "Buffer UnderRead in SSL CN Parsing". --- diff --git a/src/anyp/Uri.cc b/src/anyp/Uri.cc index eca2c23573..b0f2ce0307 100644 --- a/src/anyp/Uri.cc +++ b/src/anyp/Uri.cc @@ -174,6 +174,10 @@ urlInitialize(void) assert(0 == matchDomainName("*.foo.com", ".foo.com", mdnHonorWildcards)); assert(0 != matchDomainName("*.foo.com", "foo.com", mdnHonorWildcards)); + assert(0 != matchDomainName("foo.com", "")); + assert(0 != matchDomainName("foo.com", "", mdnHonorWildcards)); + assert(0 != matchDomainName("foo.com", "", mdnRejectSubsubDomains)); + /* more cases? */ } @@ -748,6 +752,8 @@ matchDomainName(const char *h, const char *d, MatchDomainNameFlags flags) return -1; dl = strlen(d); + if (dl == 0) + return 1; /* * Start at the ends of the two strings and work towards the