[squid-users] Strange Squid SSL Interception Behavior
Alex Rousskov
rousskov at measurement-factory.com
Mon Aug 24 22:41:05 UTC 2020
On 8/24/20 6:21 PM, Mathew Brown wrote:
> acl whitelist ssl::server_name .httpbin.org
> acl whitelist_http ssl::server_name .httpbin.org
> ssl_bump peek step1
> ssl_bump splice all
> http_access allow whitelist
> http_access allow whitelist_http
> http_access deny all
The rules above only allow CONNECT requests to .httpbin.org domains.
During step1, when Squid intercepts a TLS connection to an IP address of
an .httpbin.org domain, Squid http_access rules are applied to a (fake)
CONNECT request to the destination IP address. There are no domain names
at that TCP-level bumping stage. Thus, you place your Squid at the mercy
of reverse DSN lookups.
In my environment, reverse DNS does not work for httpbin.org the way you
may expect:
> $ host 54.236.246.173
> 173.246.236.54.in-addr.arpa domain name pointer ec2-54-236-246-173.compute-1.amazonaws.com.
The above AWS domain name does not match your whitelist ACLs, of course,
and, hence, the fake CONNECT request is denied. Denied requests are
bumped to deliver the error message. Bumped requests require
--no-check-certificate or other means of trusting Squid's CA certificate.
If you cannot explicitly allow CONNECT requests to httpbin.org IP
addresses (e.g., because they change too often), then consider allowing
CONNECT to safe ports at any address at step1. If you only intercept
connections to httpbin.org IPs, then you can probably relax your step1
http_access rules to allow all CONNECTs (to safe addresses).
There are many similar questions about allowing CONNECT to IP addresses
on this mailing list. You may be able to find more detailed advice or
instructions by searching for those mailing list threads.
HTH,
Alex.
> $ wget https://httpbin.org
> --2020-08-24 17:48:34-- https://httpbin.org/
> Resolving httpbin.org (httpbin.org)... 54.236.246.173, 3.220.112.94
> Connecting to httpbin.org (httpbin.org)|54.236.246.173|:443... connected.
> ERROR: cannot verify httpbin.org's certificate, issued by ‘O=Internet
> Widgits Pty Ltd,ST=Some-State,C=AU’:
> Self-signed certificate encountered.
> To connect to httpbin.org insecurely, use `--no-check-certificate'.
>
> $ wget https://httpbin.org --no-check-certificate
> --2020-08-24 17:48:40-- https://httpbin.org/
> Resolving httpbin.org (httpbin.org)... 3.220.112.94, 54.236.246.173
> Connecting to httpbin.org (httpbin.org)|3.220.112.94|:443... connected.
> WARNING: cannot verify httpbin.org's certificate, issued by ‘O=Internet
> Widgits Pty Ltd,ST=Some-State,C=AU’:
> Self-signed certificate encountered.
> HTTP request sent, awaiting response... 403 Forbidden
> 2020-08-24 17:48:40 ERROR 403: Forbidden.
>
> looking at access.log shows:
>
> 1598305800.974 2 192.168.123.214 TCP_DENIED/200 0 CONNECT
> 54.236.246.173:443 - HIER_NONE/- -
>
> for the first request (without the --no-check-certificate) and the
> following for the 2nd request (with the --no-check-certificate):
>
> 1598305812.292 3 192.168.123.214 TCP_DENIED/200 0 CONNECT
> 54.236.246.173:443 - HIER_NONE/- -
> 1598305812.300 2 192.168.123.214 NONE/403 3795 GET
> https://httpbin.org/ - HIER_NONE/- text/html
>
> looking at cache.log shows:
>
> # cat /var/log/squid/cache.log | grep -i "28" | grep -i httpbin
> 2020/08/24 17:50:00.972 kid1| 28,7| ServerName.cc(32)
> aclHostDomainCompare: Match:54.236.246.173 <> .httpbin.org
> 2020/08/24 17:50:00.972 kid1| 28,7| ServerName.cc(32)
> aclHostDomainCompare: Match:54.236.246.173 <> .httpbin.org
> 2020/08/24 17:50:12.290 kid1| 28,7| ServerName.cc(32)
> aclHostDomainCompare: Match:54.236.246.173 <> .httpbin.org
> 2020/08/24 17:50:12.290 kid1| 28,7| ServerName.cc(32)
> aclHostDomainCompare: Match:54.236.246.173 <> .httpbin.org
>
> so it never matches on the httpbin.org
>
> now, if I add the following line to my configuration:
>
> http_access allow localnet
>
> right before the:
>
> http_access deny all
>
> line it works and I see the following in access.log:
>
> 1598305979.004 4 192.168.123.214 NONE/200 0 CONNECT
> 54.236.246.173:443 - HIER_NONE/- -
> 1598305980.016 1012 192.168.123.214 TCP_TUNNEL/200 15370 CONNECT
> httpbin.org:443 - ORIGINAL_DST/54.236.246.173 -
>
> and I see the following in cache.log:
>
> # cat /var/log/squid/cache.log | grep -i "28" | grep -i httpbin
> 2020/08/24 17:52:59.000 kid1| 28,7| ServerName.cc(32)
> aclHostDomainCompare: Match:54.236.246.173 <> .httpbin.org
> 2020/08/24 17:52:59.000 kid1| 28,7| ServerName.cc(32)
> aclHostDomainCompare: Match:54.236.246.173 <> .httpbin.org
> 2020/08/24 17:52:59.005 kid1| 28,3| RegexData.cc(43) match: checking
> 'httpbin.org:443'
> 2020/08/24 17:52:59.005 kid1| 28,3| ServerName.cc(42) match: checking
> 'httpbin.org'
> 2020/08/24 17:52:59.005 kid1| 28,7| ServerName.cc(32)
> aclHostDomainCompare: Match:httpbin.org <> .httpbin.org
> 2020/08/24 17:52:59.005 kid1| 28,3| ServerName.cc(47) match:
> 'httpbin.org' found
>
> What's puzzling is why adding the 'allow localnet' line changes the ACL
> logic for .httpbin.org and why the original configuration does not work.
> Any ideas? Thanks
>
> PS. I reproduced the exact same scenario on Ubuntu 20.04 with Squid 4.12
>
>
>
> _______________________________________________
> squid-users mailing list
> squid-users at lists.squid-cache.org
> http://lists.squid-cache.org/listinfo/squid-users
>
More information about the squid-users
mailing list