0

I have read many tutorial and official documentation, but the suggested method is not working for me.

I have set up a squid proxy(Squid Cache: Version 4.10, ubuntu 18.04.4 LTS) in my organization, and it works well for my use case. I have come across two issues but will focus one at a time.

Users can reach out to the Internet using a proxy, but from the logs, I see that Internal LAN IPs are accessed via web proxy. I want to restrict the users to use the Internet, not internal LAN IPs. On web proxies I have set the rule, neither of it works.

acl restricted_destination_subnetworks dst 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 acl restricted_destination_IP dst 10.50.21.135

http_access deny restricted_destination_IP http_access deny restricted_destination_subnetworks

Testing - From server, 10.50.40.18, I run below command, I get 200 OK, and I can see the log at web proxy as 200/TCP_MISS.

curl -s -o /dev/null -I -w "%{http_code} \n" -k http://10.50.21.135:8585 200

Ideally, my curl request should be blocked, but in this scenario its not.

Can anyone correct me if I have done something wrong?

Full config

acl allowed_subnetworks src "/etc/squid/allowed_subnetworks_list.txt"

acl restricted_destination_subnetworks dst 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16  
acl restricted_destination_IP dst 10.50.21.135

acl step1 at_step SslBump1
ssl_bump peek step1
ssl_bump splice all
acl localnet src 0.0.0.1-0.255.255.255  # RFC 1122 "this" network (LAN)
acl localnet src 10.0.0.0/8     # RFC 1918 local private network (LAN)
acl localnet src 100.64.0.0/10      # RFC 6598 shared address space (CGN)
acl localnet src 169.254.0.0/16     # RFC 3927 link-local (directly plugged) machines
acl localnet src 172.16.0.0/12      # RFC 1918 local private network (LAN)
acl localnet src 192.168.0.0/16     # RFC 1918 local private network (LAN)
acl localnet src fc00::/7           # RFC 4193 local private network range
acl localnet src fe80::/10          # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443     # https
acl Safe_ports port 70      # gopher
acl Safe_ports port 210     # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280     # http-mgmt
acl Safe_ports port 488     # gss-http
acl Safe_ports port 591     # filemaker
acl Safe_ports port 777     # multiling http
acl CONNECT method CONNECT
    http_access allow allowed_subnetworks
    http_access deny restricted_destination_IP
    http_access deny restricted_destination_subnetworks 
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
 http_access allow localhost
  http_access deny all
http_port 3128 ssl-bump
cache_dir ufs /var/spool/squid 3000 16 256
coredump_dir /var/spool/squid
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern ^gopher:    1440    0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
refresh_pattern .       0   20% 4320

Thanks

Bhalu
  • 3
  • 1
  • 3
  • Hard to say without knowing the contents of /etc/squid/allowed_subnetworks_list.txt. – Gerard H. Pille Jul 21 '20 at 15:13
  • @GerardH.Pille - The contents of /etc/squid/allowed_subnetworks_list.txt is 10.31.193.0/24 The users on subnet 10.31.193.0/24 are able to access the internet via proxy as expected. The issue is for blocked destination subnet or IP address. I am unable to restrict users from accessing the destination. – Bhalu Jul 21 '20 at 17:43
  • Did you restart squid after the config changes? Test the config with "squid -k parse " ? Does squid mind that there are spaces before http_access ? – Gerard H. Pille Jul 21 '20 at 18:31
  • @GerardH.Pille - Thanks for helping me out here. Yes, I did restart squid and "squid -k parse" doesn't complain. Just that, even though I have deny rule for destination subnet, user requests go through and reach IPs from destination subnet. – Bhalu Jul 22 '20 at 01:15
  • It shouldn't matter, but don't "acl restricted_destination_subnetworks dst 10.0.0.0/8" and "acl restricted_destination_IP dst 10.50.21.135" overlap? – Gerard H. Pille Jul 22 '20 at 11:25
  • The requests that go through, they are not coming from "10.31.193.0/24". I suppose? From what IP address do they come? Are you sure they pass via Squid? – Gerard H. Pille Jul 22 '20 at 11:29
  • What is the IP address of the Squid server? Can you add the route table from server 10.50.40.18 ? – Gerard H. Pille Jul 22 '20 at 11:35
  • There is a security problem with your config, see https://wiki.squid-cache.org/SquidFaq/SecurityPitfalls. "http_access deny !Safe_ports" and "http_access deny CONNECT !SSL_ports" should be the first lines!! – Gerard H. Pille Jul 22 '20 at 11:44
  • @GerardH.Pille - requests that go through, they are indeed coming from "10.31.193.0/24". I have no issue here. "acl restricted_destination_subnetworks dst 10.0.0.0/8" and "acl restricted_destination_IP dst 10.50.21.135" do overlap, but for sake of clarity and to "display different methods I have tried to solve the issue" I have used both lines. removing "acl restricted_destination_IP dst 10.50.21.135" doesn't resolve the issue. I surfed many sites, but none help me. I an not sure what wrong I am doing and how can I block destination IP. – Bhalu Jul 23 '20 at 01:35
  • First, order your http_access lines as specified in https://wiki.squid-cache.org/SquidFaq/SecurityPitfalls. Can you please answer my other questions? – Gerard H. Pille Jul 23 '20 at 09:53
  • "curl -s -o /dev/null -I -w "%{http_code} \n" -k http://10.50.21.135:8585 200" what is the meaning of the "200" at the end? Curl thinks this is an IP address. – Gerard H. Pille Jul 23 '20 at 10:26

1 Answers1

0

The order of your http_access lines is wrong. SecurityPitfalls

http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
http_access allow allowed_subnetworks
http_access deny restricted_destination_IP
http_access deny restricted_destination_subnetworks 

#
# INSERT YOUR OWN RULE(S) BEFORE THESE TO ALLOW ACCESS FROM YOUR CLIENTS
#
http_access allow localhost
http_access deny all
Gerard H. Pille
  • 2,569
  • 1
  • 13
  • 11
  • Thank you for suggesting the ordering. I did reorder the configs and restart the service. It doesn't help. I test by "curl -s -o /dev/null -I -w "%{http_code} \n" -k http://10.50.21.135:8585" . The return status code is 200 which is NOT expected. – Bhalu Jul 24 '20 at 05:09
  • How does curl know it has to use the proxy? – Gerard H. Pille Jul 24 '20 at 16:04
  • 1) I have exported the http_proxy variables in the test machine. 2) I see the proxy server name in curl output 3) I see the logs on the proxy server of the test machine for curl request. – Bhalu Jul 24 '20 at 16:30
  • Can you test without "allowed_subnetworks"? – Gerard H. Pille Jul 24 '20 at 17:02