<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi Amos,</p>
<p>Thanks for your continued support.<br>
</p>
<p>1.<br>
</p>
<p>
<blockquote type="cite">Do you mean the VPN exit point has that
10/8 IP address? or that the traffic from the client is altered
to be going to that IP before it reaches Squid?
<br>
<br>
The latter is broken because it destroys the original dst-IP
values on the TCP connection. Which Squid needs to setup the
server connection.
</blockquote>
<br>
Let me put it as an example:</p>
<p>From the normal internet: mail.amosprivateserver.org >
publicly accessible IP.</p>
<p>From my place: mail.amosprivateserver.org > 10.x.x.x
(corporate network, accessible only from within the place).</p>
<p>Anyways no worries about this! I decided to make an exception in
the redirect rule, so that if the outgoing traffic matches the IP
10.x.x.x then the firewall will not redirect the traffic to squid
and instead establish a connection directly.</p>
<p>This is not ideal, but it works.</p>
<p><br>
</p>
<p>2.<br>
</p>
<p>
<blockquote type="cite">If for any reason those firewall rules
change in unexpected ways or don't block something you expect to
be blocked this may leave a security hole open. It does not seem
to be necessary really, so best to close.
</blockquote>
</p>
<p>But if I put the lines you told me: <br>
</p>
<p># http_access allow SSL_ports (commented out as you advised)<br>
http_access deny !localnet <br>
</p>
<p>Then I can't get any https work per my whitelist (google for
example complains of HSTS..etc) There must be another thing messed
up in my config then?</p>
<p><br>
</p>
<p>3.</p>
<p>
<blockquote type="cite">The point I was trying to emphasize is
that your Squid is accepting *anything* in those port 443
connections.
</blockquote>
<blockquote type="cite"><br>
HSTS requires a header "Strict-Transport-Security" to be
delivered from servers before it takes effect. You can erase
that header from replies going through Squid with the
reply_header_access directive. Current Squid should be doing it
automatically.
<br>
There may be issues with HSTS if the header is received before
the device connects to your network, or if it arrives over an
uncontrolled CONNECT tunnel. But there is not much to be done
about those cases.
</blockquote>
I'm not sure I follow (please bare with me!), see I'm simply
trying to prevent abuse by only allowing connections to whats in
whitelist, is my approach in my current config doing that? If
there's a better way please tell me. This is going over a
satellite connection with extremely poor latency and bandwidth, so
Squid's job is to stop the connections from reaching out, and only
allowing whats in whitelist.<br>
</p>
<p><br>
</p>
<p>4.<br>
</p>
<p>
<blockquote type="cite">That means the server that HTTPS
connection is attempting to reach is not on your whitelist. It
is therefore one of the things you wanted to be blocked
according to your stated policy.
<br>
<br>
- as I mentioned earlier, if that causes any issues your
whitelist is incomplete.
</blockquote>
But it is, eg whitelist.txt has .google.com, shouldn't google.com
be accessible then (without complaining about HSTS, since I'm
splicing?). Note if I reverse the commented out lines, as below,
then it works:</p>
<p>http_access allow SSL_ports<br>
# http_access deny !localnet (now it works).</p>
<p><br>
</p>
<p>As I mentioned no worries about the forgery error as I'm simply
adding an exception for that to circumvent squid, now I simply
need to polish up my squid.conf to only allow whats in whitelist
(while not consuming any unnecessary bandwidth).</p>
<p><br>
</p>
<p>Latest version below:</p>
<p>### begin squid.conf</p>
<p>acl localnet src 10.0.0.0/8
<br>
acl localnet src 172.16.0.0/12
<br>
acl localnet src 192.168.0.0/16
<br>
<br>
acl SSL_ports port 443
<br>
<br>
acl Safe_ports port 80
<br>
acl Safe_ports port 443
<br>
acl CONNECT method CONNECT
<br>
acl http_whitelist dstdomain "/etc/squid/whitelist.txt"
<br>
acl https_whitelist ssl::server_name "/etc/squid/whitelist.txt"
<br>
acl ips_whitelist dst "/etc/squid/ips.txt"
<br>
<br>
<br>
http_access deny !Safe_ports
<br>
http_access deny CONNECT !SSL_ports
<br>
http_access allow SSL_ports
<br>
# http_access deny !localnet
<br>
http_access allow http_whitelist
<br>
http_access allow ips_whitelist
<br>
http_access deny all
<br>
<br>
http_port 3128 ssl-bump \
<br>
cert=/etc/squid/myCA.pem \
<br>
generate-host-certificates=off dynamic_cert_mem_cache_size=4MB
<br>
<br>
https_port 3130 intercept ssl-bump \
<br>
cert=/etc/squid/myCA.pem \
<br>
generate-host-certificates=off dynamic_cert_mem_cache_size=4MB
<br>
<br>
acl step1 at_step SslBump1
<br>
acl step2 at_step SslBump2
<br>
acl step3 at_step SslBump3
<br>
<br>
ssl_bump peek step1 all
<br>
ssl_bump splice https_whitelist
<br>
ssl_bump splice ips_whitelist
<br>
ssl_bump terminate all
<br>
<br>
<br>
refresh_pattern ^ftp: 1440 20% 10080
<br>
refresh_pattern ^gopher: 1440 0% 1440
<br>
refresh_pattern -i (<i class="moz-txt-slash"><span
class="moz-txt-tag">/</span>cgi-bin<span class="moz-txt-tag">/</span></i>|\?)
0 0% 0
<br>
refresh_pattern . 0 20% 4320
<br>
<br>
store_miss deny all
<br>
cache_log /tmp/squid/squid.log
<br>
access_log /tmp/squid/access.log
<br>
logfile_rotate 0
<br>
<br>
logfile_daemon /usr/bin/logger
<br>
http_port 3129 intercept
<br>
coredump_dir /tmp/squid
<br>
visible_hostname LEDE.lan
<br>
pinger_enable off
<br>
mime_table /tmp/squid/mime.conf
<br>
sslcrtd_program /usr/lib/squid/ssl_crtd -s /tmp/squid/ssldb -M 4MB
<br>
<br>
## end config <br>
</p>
<pre class="moz-signature" cols="72">Regards,
A. Benz</pre>
<div class="moz-cite-prefix">On 11/10/17 03:30, Amos Jeffries wrote:<br>
</div>
<blockquote type="cite"
cite="mid:7a55ca37-23d0-a0f3-6397-2a772f91745f@treenet.co.nz">On
09/11/17 11:34, A. Benz wrote:
<br>
<blockquote type="cite">Hi Amos,
<br>
<br>
Many thanks for your detailed reply.
<br>
<br>
I have modified the config following your comments, before you
see the new config (attached below), pls let me know your
thoughts on the following:
<br>
<br>
1.
<br>
<br>
> The workarounds and gotcha's listed at
<br>
>
<a class="moz-txt-link-rfc2396E" href="https://wiki.squid-cache.org/KnowledgeBase/HostHeaderForgery"><https://wiki.squid-cache.org/KnowledgeBase/HostHeaderForgery></a>
are the
<br>
> best you can hope for there. The most successful all-round
solution is
<br>
> to increase EDNS0 capabilities.
<br>
<br>
My particular case is a single server only, a corporate email
server. This server is publicly accessible from internet (and
has a valid signed SSL cert), now, on the remote location,
there's a VPN setup that redirects access to the mail server to
a private IP, eg 10.x.x.x (and this differs depending on
loadbalance decision).
<br>
</blockquote>
<br>
Do you mean the VPN exit point has that 10/8 IP address? or that
the traffic from the client is altered to be going to that IP
before it reaches Squid?
<br>
<br>
The latter is broken because it destroys the original dst-IP
values on the TCP connection. Which Squid needs to setup the
server connection.
<br>
<br>
<br>
<blockquote type="cite">
<br>
Without squid, I can connect to webmail, but with squid I get
the forgery error. Does the EDNS0 fix this? See its almost
working exactly as I need now, except for access to this single
domain.. so if there's a workaround (even if it requires a
recompile) to ignore this single domain do let me know.
<br>
<br>
</blockquote>
<br>
EDNS0 fixes problems with services that load balance by rotating
the IP addresses delivered in response to A/AAAA queries, possibly
omitting some records if the final few don't fit. That results in
Squid getting different IPs occasionally than the one the client
is using. EDNS0 extends the available DNS response packet size to
fit all the records so Squid can see them all even when a large
set is rotating.
<br>
<br>
There are a few major hosting providers that have that behaviour
in their DNS. If you have not hit it yet you are very lucky.
<br>
<br>
<br>
<blockquote type="cite">
<br>
2.
<br>
<br>
> NAT of the dst-IP:port *MUST NOT* happen on any device
between the
<br>
> client machine and the proxy machine. Squid needs access
directly to the
<br>
> kernel NAT records of the device doing that NAT operation.
So it can
<br>
> only happen on the Squid device.
<br>
> You must *route* the packets unchanged to the Squid
device (possibly
<br>
> over a tunnel if necessary).
<br>
<br>
It happens on the same device (LEDE/OpenWrt router where squid
is running), so the router is configured to intercept http (80)
and https (443) traffic and redirect it to squid's ports:
<br>
80 ---> 3129
<br>
443 --> 3130
<br>
<br>
<br>
3.
<br>
<br>
> Rather than allowing unlimited access to anyone on the
Internet to use
<br>
> your limited bandwidth outbound connection for access to
port 443 you
<br>
> should be using the localnet ACL that restricts use of the
proxy to
<br>
> people on your LAN - those 14 clients you mentioned
sharing the line.
<br>
>
<br>
> [NP: It is not possible in this setup to determine what
remote users are
<br>
> abusing your proxy. All traffic logs from your firewall
etc will show
<br>
> Squid as the client, not the remote [ab]user. Squid
access.log records
<br>
> you are sending to /dev/null is the *only* record of such
activities.]
<br>
>
<br>
>
<br>
<br>
I think I didn't word my earlier email properly, apologies for
not being clear. No one from the internet has access to squid,
the listening ports are not open to public, only accessible from
LAN.
<br>
</blockquote>
<br>
If for any reason those firewall rules change in unexpected ways
or don't block something you expect to be blocked this may leave a
security hole open. It does not seem to be necessary really, so
best to close.
<br>
<br>
<br>
<blockquote type="cite">
<br>
With abuse I meant the 14 users.. you know nowadays with
mobiles/tablets and all the apps and syncing, I only allow ports
443 and 80 (and those are intercepted and forwarded to squid).
All other ports are blocked.
<br>
The bandwidth available is extremely scarce and hence why I'm
setting this up.
<br>
</blockquote>
<br>
The point I was trying to emphasize is that your Squid is
accepting *anything* in those port 443 connections.
<br>
<br>
<br>
<blockquote type="cite">
<br>
4.
<br>
<br>
> To make your whitelists have any effect replace the above
"allow
<br>
> ssl_ports" line with a "deny !localnet" line.
<br>
<br>
When I do this, it doesn't work anymore. I get "Your connection
is not secure" from firefox, and since google has HSTS, I can't
"ignore and proceed". The squid access log shows (not
.google.com is in whitelist.txt):
<br>
</blockquote>
<br>
HSTS requires a header "Strict-Transport-Security" to be delivered
from servers before it takes effect. You can erase that header
from replies going through Squid with the reply_header_access
directive. Current Squid should be doing it automatically.
<br>
There may be issues with HSTS if the header is received before the
device connects to your network, or if it arrives over an
uncontrolled CONNECT tunnel. But there is not much to be done
about those cases.
<br>
<br>
<br>
<blockquote type="cite">
<br>
1510180110.096 0 192.168.1.178 TCP_DENIED/200 0 CONNECT
108.177.14.103:443 - HIER_NONE/- -
<br>
<br>
Once I switch back to "allow SSL_ports" I can connect (squid
splices' the connection, no complaints from firefox).
<br>
<br>
</blockquote>
<br>
That means the server that HTTPS connection is attempting to reach
is not on your whitelist. It is therefore one of the things you
wanted to be blocked according to your stated policy.
<br>
<br>
- as I mentioned earlier, if that causes any issues your
whitelist is incomplete.
<br>
<br>
<br>
<blockquote type="cite">
<br>
5.
<br>
<br>
I followed your comments about the config changes: changed acls
to match original config in upper case. Swapped the port
numbers, but about having my ssl-bump match on 3129, pls check
my new one see if I did it right.
<br>
<br>
<br>
## begin squid.conf
<br>
<br>
<br>
acl localnet src 10.0.0.0/8
<br>
acl localnet src 172.16.0.0/12
<br>
acl localnet src 192.168.0.0/16
<br>
<br>
acl SSL_ports port 443
<br>
<br>
acl Safe_ports port 80
<br>
acl Safe_ports port 443
<br>
acl CONNECT method CONNECT
<br>
acl http_whitelist dstdomain "/etc/squid/whitelist.txt"
<br>
acl https_whitelist ssl::server_name "/etc/squid/whitelist.txt"
<br>
acl ips_whitelist dst "/etc/squid/ips.txt"
<br>
<br>
<br>
http_access deny !Safe_ports
<br>
http_access deny CONNECT !SSL_ports
<br>
http_access allow SSL_ports
<br>
# http_access deny !localnet
<br>
http_access allow http_whitelist
<br>
http_access allow ips_whitelist
<br>
http_access deny all
<br>
<br>
http_port 3128 ssl-bump \
<br>
cert=/etc/squid/myCA.pem \
<br>
generate-host-certificates=off
dynamic_cert_mem_cache_size=4MB
<br>
<br>
https_port 3130 intercept ssl-bump \
<br>
cert=/etc/squid/myCA.pem \
<br>
generate-host-certificates=off
dynamic_cert_mem_cache_size=4MB
<br>
<br>
acl step1 at_step SslBump1
<br>
acl step2 at_step SslBump2
<br>
acl step3 at_step SslBump3
<br>
<br>
ssl_bump peek step1 all
<br>
ssl_bump splice https_whitelist
<br>
ssl_bump splice ips_whitelist
<br>
ssl_bump terminate all
<br>
<br>
<br>
refresh_pattern ^ftp: 1440 20% 10080
<br>
refresh_pattern ^gopher: 1440 0% 1440
<br>
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
<br>
refresh_pattern . 0 20% 4320
<br>
<br>
store_miss deny all
<br>
cache_log /tmp/squid/squid.log
<br>
access_log /tmp/squid/access.log
<br>
logfile_rotate 0
<br>
<br>
logfile_daemon /usr/bin/logger
<br>
http_port 3129 intercept
<br>
coredump_dir /tmp/squid
<br>
visible_hostname LEDE.lan
<br>
pinger_enable off
<br>
mime_table /tmp/squid/mime.conf
<br>
sslcrtd_program /usr/lib/squid/ssl_crtd -s /tmp/squid/ssldb -M
4MB
<br>
<br>
## end config
<br>
<br>
Many thanks!
<br>
<br>
<br>
Regards,
<br>
A. Benz
<br>
<br>
On 11/08/17 12:23, Amos Jeffries wrote:
<br>
<blockquote type="cite">On 08/11/17 12:18, A. Benz wrote:
<br>
<blockquote type="cite">Hi all,
<br>
<br>
<br>
## Intro
<br>
<br>
I read many blogs and emails on this list related to what
I'm trying to do, but most go into bumping or do things that
are not as simple as I'm trying to achieve.
<br>
<br>
I have an extremely slow line, with very high latency in a
remote location. About 14 people are sharing this line.
Nowadays with all the mobile apps trying to sync and such,
the line stalls to unusable all the time.
<br>
<br>
I tried doing filters with firewall or dns level, but those
are not effective. In the end I figured squid might be my
best option.
<br>
<br>
## End intro
<br>
<br>
<br>
I have squid 3.5.27 running under LEDE (OpenWrt fork), ie
its cross-compiled for a MIPS based SoC (mediatek mt7621). I
mention this because you will see some options in the config
file that won't make sense otherwise.
<br>
<br>
</blockquote>
<br>
NP: That should not be making much difference to the
squid.conf settings. The worst limitations such devices impose
are things that should be solved by OS settings outside of
squid.conf. eg the cache.log going to a pipe for remote
logging instead of a filename, and system-level FD limits.
<br>
<br>
<br>
<blockquote type="cite">It works great, here's what I'm trying
to achieve: Allow access only to a pre-defined list of
websites (whitelist). http is straightforward, but if the
connection is https all I need to know is domain, if its
allowed, let it pass, otherwise terminate.
<br>
<br>
this setup is working as intended with the config attached
below, however the issue I'm facing is that some servers are
"loadbalanced", this would give me the forgery error, eg:
<br>
<br>
"SECURITY ALERT: Host header forgery detected on...."
<br>
<br>
</blockquote>
<br>
The workarounds and gotcha's listed at
<a class="moz-txt-link-rfc2396E" href="https://wiki.squid-cache.org/KnowledgeBase/HostHeaderForgery"><https://wiki.squid-cache.org/KnowledgeBase/HostHeaderForgery></a>
are the best you can hope for there. The most successful
all-round solution is to increase EDNS0 capabilities.
<br>
<br>
<br>
<blockquote type="cite">Here's a specific example, there's a
corporate domain for webmail access, and some loadbalance
config makes use of different IPs, I think this is what
triggers the error. My question is, can I just ignore this
error somehow and allow the connection? From what I gather
this connection is cut by squid before it reaches the
client..
<br>
</blockquote>
<br>
Squid default behaviour is to allow the connection only to the
same IP:port the client was connecting to. If that is not
working your network configuration is screwed up. Specifically
your routing or NAT.
<br>
<br>
NAT of the dst-IP:port *MUST NOT* happen on any device between
the client machine and the proxy machine. Squid needs access
directly to the kernel NAT records of the device doing that
NAT operation. So it can only happen on the Squid device.
<br>
You must *route* the packets unchanged to the Squid device
(possibly over a tunnel if necessary).
<br>
<br>
<br>
<blockquote type="cite">
<br>
Also if there's anything else obviously wrong with my setup
please let me know.
<br>
<br>
Many thanks.
<br>
<br>
<br>
Here's my config:
<br>
<br>
<br>
### squid.conf begin
<br>
<br>
acl localnet src 10.0.0.0/8
<br>
acl localnet src 172.16.0.0/12
<br>
acl localnet src 192.168.0.0/16
<br>
<br>
acl ssl_ports port 443
<br>
<br>
acl safe_ports port 80
<br>
acl safe_ports port 443
<br>
acl connect method connect
<br>
</blockquote>
<br>
NP: the default above ACL names are case-sensitive and some of
them involve built-in default values which you are preventing
having any effect by using custom lower-case ACL names.
<br>
<br>
<br>
<blockquote type="cite">acl http_whitelist dstdomain
"/etc/squid/whitelist.txt"
<br>
acl https_whitelist ssl::server_name
"/etc/squid/whitelist.txt"
<br>
acl ips_whitelist dst "/etc/squid/ips.txt"
<br>
<br>
http_port 3128 intercept
<br>
http_port 3129
<br>
</blockquote>
<br>
Port 3128 is registered for forward-proxy traffic. Ideally you
would have those lines reversed like so:
<br>
<br>
http_port 3128
<br>
http_port 3129 intercept
<br>
<br>
... with the corresponding NAT change for the intercept port.
<br>
<br>
Also, to have your SSL-Bump whitelists applied to
forward-proxy CONNECT traffic you should have ssl-bump
settings on that 3128 forward-proxy port matching those on the
port 3130 line.
<br>
<br>
<br>
<blockquote type="cite">
<br>
http_access deny !safe_ports
<br>
http_access deny connect !ssl_ports
<br>
</blockquote>
<br>
<blockquote type="cite">http_access allow ssl_ports
<br>
</blockquote>
<br>
Rather than allowing unlimited access to anyone on the
Internet to use your limited bandwidth outbound connection for
access to port 443 you should be using the localnet ACL that
restricts use of the proxy to people on your LAN - those 14
clients you mentioned sharing the line.
<br>
<br>
[NP: It is not possible in this setup to determine what remote
users are abusing your proxy. All traffic logs from your
firewall etc will show Squid as the client, not the remote
[ab]user. Squid access.log records you are sending to
/dev/null is the *only* record of such activities.]
<br>
<br>
<br>
To make your whitelists have any effect replace the above
"allow ssl_ports" line with a "deny !localnet" line.
<br>
<br>
If that change causes issues then your whitelists are
incorrect / incomplete. You then need the (currently
discarded) access.log and/or cache.log data to solve the issue
properly.
<br>
<br>
<br>
<blockquote type="cite">http_access allow http_whitelist
<br>
http_access allow ips_whitelist
<br>
http_access deny all
<br>
<br>
https_port 3130 intercept ssl-bump \
<br>
cert=/etc/squid/myCA.pem \
<br>
generate-host-certificates=off
dynamic_cert_mem_cache_size=4MB
<br>
<br>
acl step1 at_step SslBump1
<br>
acl step2 at_step SslBump2
<br>
acl step3 at_step SslBump3
<br>
<br>
ssl_bump peek step1 all
<br>
ssl_bump splice https_whitelist
<br>
ssl_bump splice ips_whitelist
<br>
ssl_bump terminate all
<br>
<br>
</blockquote>
<br>
That seems fine. The problem is not part of this _config_. If
you are having any SSL-Bump issues please try a build of the
latest Squid-4. It may be related to bugs in Squid-3 SSL-Bump
or modern TLS things Squid-3 cannot cope with - there is a
growing list of those.
<br>
<br>
<blockquote type="cite">
<br>
cache deny all
<br>
</blockquote>
<br>
In the latest Squid-3 use "store_miss deny all" instead of the
above.
<br>
<br>
<blockquote type="cite">access_log none
<br>
</blockquote>
<br>
The above is fine if you are certain of the squid.conf working
100% properly. But since you are debugging issues you may need
those transaction details.
<br>
<br>
NP: access.log can be logged to syslog or a TCP pipe by Squid.
To deliver the log content externally for normal audit
purposes instead of using space on the device.
<br>
<br>
<blockquote type="cite">cache_log /dev/null
<br>
</blockquote>
<br>
You *need* the information logged here. By default only the
most operationally critical errors are recorded.
<br>
<br>
NP: the cache.log can usually be a Unix-pipe delivering data
to a remote server if the local machine is constrained.
<br>
<br>
<blockquote type="cite">cache_store_log stdio:/dev/null
<br>
</blockquote>
<br>
Above line is *actively* harmful. The Squid-3 default is not
to waste cycles logging *unless* you enter something like the
above in squid.conf. The above makes Squid allocate device
resources to logging that data to /dev/null.
<br>
<br>
<blockquote type="cite">logfile_rotate 0
<br>
<br>
logfile_daemon /dev/null
<br>
</blockquote>
<br>
/dev/null is not a valid application filename.
<br>
<br>
Build your Squid with --disable-logfile-daemon.
<br>
<br>
<blockquote type="cite">coredump_dir /tmp/squid
<br>
visible_hostname main_Firewall
<br>
</blockquote>
<br>
The *visible* hostname is the domain delivered to clients and
denied parties in the URLs to fetch error message data and FTP
icons from Squid. It needs to be a valid FQDN.
<br>
<br>
Amos
<br>
_______________________________________________
<br>
squid-users mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:squid-users@lists.squid-cache.org">squid-users@lists.squid-cache.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.squid-cache.org/listinfo/squid-users">http://lists.squid-cache.org/listinfo/squid-users</a>
<br>
</blockquote>
_______________________________________________
<br>
squid-users mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:squid-users@lists.squid-cache.org">squid-users@lists.squid-cache.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.squid-cache.org/listinfo/squid-users">http://lists.squid-cache.org/listinfo/squid-users</a>
<br>
</blockquote>
_______________________________________________
<br>
squid-users mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:squid-users@lists.squid-cache.org">squid-users@lists.squid-cache.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.squid-cache.org/listinfo/squid-users">http://lists.squid-cache.org/listinfo/squid-users</a>
<br>
</blockquote>
<br>
</body>
</html>