]> git.ipfire.org Git - thirdparty/squid.git/commit
Bug 5363: Handle IP-based X.509 SANs better (#1793)
authorTony Walker <walkert.uk@gmail.com>
Sat, 16 Nov 2024 22:10:39 +0000 (22:10 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 16 Nov 2024 22:30:12 +0000 (22:30 +0000)
commit22b2a7a0ae662809948adaea8b4d171b947634b5
tree5b4e87e2f5b8cfb9090e6736825467bf5a8102d3
parentc8ea6a314c097b74a24af7b4037c1b60c5165315
Bug 5363: Handle IP-based X.509 SANs better (#1793)

Most X.509 Subject Alternate Name extensions encountered by Squid are
based on DNS domain names. However, real-world servers (including
publicly available servers that use vanity IP addresses) also use
IP-based SANs. Squid mishandled IP-based SANs in several ways:

* When generating certificates for servers targeted by their IP
  addresses, addAltNameWithSubjectCn() used that target IP as a
  DNS-based SAN, resulting in a frankenstein DNS:[ip] SAN value that
  clients ignored when validating a Squid-generated certificate.

* When validating a received certificate, Squid was ignoring IP-based
  SANs. When Subject CN did not match the requested IP target, Squid
  only looked at DNS-based SANs, incorrectly failing validation.

* When checking certificate-related ACLs like ssl::server_name,
  matchX509CommonNames() ignored IP-based SANs, not matching
  certificates containing ACL-listed IP addresses.

Squid now recognizes and generates IP-based SANs.

Squid now attempts to match IP-based SANs with ACL-listed IP addresses,
but the success of that attempt depends on whether ACL IP parameters are
formatted the same way inet_ntop(3) formats those IP addresses: Matching
is still done using c-string/domain-based ::matchDomainName() (for
ssl::server_name) and string-based regexes (for ssl::server_name_regex).
Similar problems affect dstdomain and dstdomain_regex ACLs. A dedicated
fix is needed to stop treating IPs as domain names in those contexts.

This change introduces partial support for preserving IP-vs-domain
distinction in parsed/internal Squid state rather than converting both
to a string and then assuming that string is a DNS domain name.
21 files changed:
CONTRIBUTORS
src/acl/ServerName.cc
src/anyp/Host.cc [new file with mode: 0644]
src/anyp/Host.h [new file with mode: 0644]
src/anyp/Makefile.am
src/anyp/Uri.cc
src/anyp/Uri.h
src/anyp/forward.h
src/cf.data.pre
src/client_side.cc
src/dns/forward.h
src/ip/Address.cc
src/ip/Address.h
src/security/ErrorDetail.cc
src/security/cert_generators/file/Makefile.am
src/ssl/gadgets.cc
src/ssl/gadgets.h
src/ssl/support.cc
src/ssl/support.h
src/tests/stub_libip.cc
src/tests/stub_libsslsquid.cc