]> git.ipfire.org Git - thirdparty/squid.git/commit
Reject more CONNECT requests with malformed targets (#1253)
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 28 Jun 2023 09:28:59 +0000 (09:28 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 28 Jun 2023 09:29:06 +0000 (09:29 +0000)
commit963ff14337f7bea953658d99870a0dbd2e74a206
tree564f2adf2171d4cc0db65aececa764ba8f11036a
parent6ec49cda026b3597edcf56a6463048523c5d2d9b
Reject more CONNECT requests with malformed targets (#1253)

Squid silently ignored many syntax violations, interpreting a malformed
target as a valid host:port address of some origin server and
establishing a CONNECT tunnel with that origin server. While being
"tolerant" probably did not compromise the Squid instance itself, some
known attacks abuse the _difference_ in treatment of malformed requests.
Rejecting malformed requests and closing the connection prevents many
such attacks.

Among other syntax violations, this change rejects bracketed pure IPv4
addresses and bracketed domain names in CONNECT targets. Bracketed IPv6
addresses that include an IPv4address suffix are still accepted (e.g.,
look for ABNF containing ls32 in RFC 3986, Section 3.2.2).

CONNECT target hosts are no longer covered by uri_whitespace: CONNECT
targets containing whitespace are now rejected with in ERR_INVALID_URL
regardless of uri_whitespace and check_hostnames settings. With the
exception of whitespaces in host names when uri_whitespace is set to
"strip" (default), the uri_whitespace directive was already ignored for
all request targets. For example, whitespaces in the port component were
always handled without checking uri_whitespace. In CONNECT context,
stripping whitespace is not only risky but probably is not needed in
practice because user typos should not lead to spaces in CONNECT
targets, and even if they do, virtually all legitimate use cases ought
to fail during certificate validation and similar post-CONNECT checks.
src/anyp/Uri.cc
src/anyp/Uri.h