Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Sicherheitslücke in Squid?!?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
sokar2000
Tux's lil' helper
Tux's lil' helper


Joined: 17 Feb 2005
Posts: 137
Location: Zu Hause

PostPosted: Fri May 20, 2005 11:30 am    Post subject: Sicherheitslücke in Squid?!? Reply with quote

Hallo Zusammen

Ich bin am nachforschen, warum Squid plötzlich einen so extremen Traffic auslöst. (Der Squid-Proxy ist intern wie extern zugreifbar). Dabei bin ich über folgendes gestolpert:

Code:
nbook tmp $ { echo -e "CONNECT 10.10.1.3:25 HTTP/1.0\nUser-Agent:Fake\n"; cat;}|nc 10.10.1.2 80
HTTP/1.0 200 Connection established

220 webcluster.test.local ESMTP Postfix


In der /etc/squid/squid.conf habe ich bereits folgende Regel eingetragen:
acl CONNECT method CONNECT
http_access deny CONNECT all
http_reply_access deny CONNECT all

ohne Erfolg.

Für mich ist das ne riesige Sicherheitslücke. Sehe ich irgend etwas nicht mehr, oder ist das tatsächlich so?

Getestet mit squid-2.5.10_rc3.
Back to top
View user's profile Send private message
flash49
Apprentice
Apprentice


Joined: 12 Feb 2005
Posts: 233

PostPosted: Fri May 20, 2005 12:04 pm    Post subject: Reply with quote

Das squid noch etwas anderes als http und https weiterleitet wundert mich etwas. Funktioniert den folgendes auch noch?
Code:

{ echo -e "CONNECT 10.10.1.3:25 HTTP/1.0\nUser-Agent:Fake\nehlo localhost\nquit\n"; cat;}|nc 10.10.1.2 80

Bei mir erhalte ich damit einen "403 (access denied)" Fehler.

Das sind meine (größtenteil auch die default Einstellungen). Die "Safe_ports" Direktiven sollten eigendlich eine Verbindung zu port 25 verhinderen.
Code:
#Recommended minimum configuration:
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object#
#Recommended minimum configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager
# Only allow purge requests from localhost
http_access allow purge localhost
http_access deny purge
# Deny requests to unknown ports
http_access deny !Safe_ports
# Deny CONNECT to other than SSL ports
http_access deny CONNECT !SSL_ports

Code:
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443 563     # https, snews
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 Safe_ports port 901         # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
#custom
acl localnet src 192.168.0.0/24 192.168.2.0/24 192.168.1.0/24

Back to top
View user's profile Send private message
sokar2000
Tux's lil' helper
Tux's lil' helper


Joined: 17 Feb 2005
Posts: 137
Location: Zu Hause

PostPosted: Fri May 20, 2005 4:45 pm    Post subject: Reply with quote

Ich hab folgendes versucht:

Code:
nbook tmp $ { echo -e "CONNECT 10.10.1.3:25 HTTP/1.0\nUser-Agent:Fake\nquit\n"; cat;}|nc 10.10.1.2 80
HTTP/1.0 200 Connection established

220 webcluster.test.local ESMTP Postfix
helo localhost #von Hand eingetippt
250 webcluster.test.local
mail from:info@webcluster.local #von Hand eingetippt
250 Ok
rcpt to:info@webcluster.local #von Hand eingetippt
250 Ok
data #von Hand eingetippt
354 End data with <CR><LF>.<CR><LF>
So ein Mist! #von Hand eingetippt
. #von Hand eingetippt
250 Ok: queued as 194FD5079B
quit #von Hand eingetippt
221 Bye


flash49 wrote:
Code:
{ echo -e "CONNECT 10.10.1.3:25 HTTP/1.0\nUser-Agent:Fake\nehlo localhost\nquit\n"; cat;}|nc 10.10.1.2 80

Das bewirkt geanu dasselbe wie in meinem ersten Post.

Meine squid.conf sieht so aus:
Code:
http_port 80
https_port 443 cert=/etc/squid/server.crt key=/etc/squid/server.key
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
log_fqdn on
dns_timeout 30 seconds
dns_nameservers 10.10.1.11
hosts_file /etc/hosts
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
refresh_pattern ^ftp:      1440   20%   10080
refresh_pattern ^gopher:   1440   0%   1440
refresh_pattern .      0   20%   4320
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443 563   # https, snews
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 Safe_ports port 901      # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
acl cluster dst 10.10.1.11
http_access allow all
http_access deny !cluster
http_reply_access deny !cluster
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT all
http_reply_access deny CONNECT all
http_access allow localhost
http_access deny all
http_reply_access allow all
icp_access allow all
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
dns_testnames 10.10.1.11
coredump_dir /var/cache/squid
ignore_unknown_nameservers on
balance_on_multiple_ip off


Ist hierbei irgenwas faul?
Back to top
View user's profile Send private message
flash49
Apprentice
Apprentice


Joined: 12 Feb 2005
Posts: 233

PostPosted: Fri May 20, 2005 6:40 pm    Post subject: Reply with quote

sokar2000 wrote:
Ich hab folgendes versucht:

Code:
nbook tmp $ { echo -e "CONNECT 10.10.1.3:25 HTTP/1.0\nUser-Agent:Fake\nquit\n"; cat;}|nc 10.10.1.2 80
HTTP/1.0 200 Connection established

220 webcluster.test.local ESMTP Postfix
helo localhost #von Hand eingetippt
250 webcluster.test.local
mail from:info@webcluster.local #von Hand eingetippt
250 Ok
rcpt to:info@webcluster.local #von Hand eingetippt
250 Ok
data #von Hand eingetippt
354 End data with <CR><LF>.<CR><LF>
So ein Mist! #von Hand eingetippt
. #von Hand eingetippt
250 Ok: queued as 194FD5079B
quit #von Hand eingetippt
221 Bye


Das zeigt eindeutig, dass man über squid auch smtp laufen lassen kann. Das squid grundsätzlich damit zurecht kommt war mir neu, aber man lernt ja immer wieder dazu.

Quote:

Meine squid.conf sieht so aus:
Code:

...
acl purge method PURGE
acl CONNECT method CONNECT
acl cluster dst 10.10.1.11
http_access allow all <<<<<<----------------hier liegt das Problem!
http_access deny !cluster
http_reply_access deny !cluster
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT all
http_reply_access deny CONNECT all
http_access allow localhost
http_access deny all
http_reply_access allow all
...


Ist hierbei irgenwas faul?

Ja, sogar ein ziemlich böser Fehler:
Code:

http_access allow all

Das erlaubt schon am Anfang jedem kompletten http Zugriff. Die ganzen späteren "http_access" Kommandos werden nicht mehr beachtet! Besonders problematisch ist, dass jetzt auch jeder "CONNECT" zu jedem Port benutzen kann. Das scheint der Grund

Code:
acl cluster dst 10.10.1.11
http_access deny !cluster
http_reply_access deny !cluster

Wenn dein squid-proxy von mehr als einem Rechner benutzt werden soll, dann sind diese 3 Zeilen nicht das, was du willst. Diese lassen nur die ip 10.10.1.11 squid benutzen alle anderen werden geblockt (wäre da nicht die "http_access allow all" direktive vorher). "http_reply_access deny !cluster" verhindert sogar, das irgend eine Antwort von einem Webserver ankommt. In dieser Kombination sind die unteren beiden Direktiven auf jeden Fall Blödsinn!

Richtig würde deine squid.conf folgendermaßen aussehen (Vorher noch die Kommentare lesen):
Code:
http_port 80
https_port 443 cert=/etc/squid/server.crt key=/etc/squid/server.key
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
log_fqdn on
dns_timeout 30 seconds
dns_nameservers 10.10.1.11
hosts_file /etc/hosts
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
refresh_pattern ^ftp:      1440   20%   10080
refresh_pattern ^gopher:   1440   0%   1440
refresh_pattern .      0   20%   4320
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443 563   # https, snews
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 Safe_ports port 901      # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
acl cluster dst 10.10.1.11

http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
#Die nächsten 2 Anweisungen stellen sicher, dass niemand mehr Blödsinn mit Hilfe von "CONNECT" Anweisungen machen kann und wirklich nur http/https funktioniert
http_access deny CONNECT all
http_reply_access deny CONNECT all

http_access allow localhost
#falls nur "cluster" squid benutzen soll dann die nächsten 2 auskommentieren:
#http_access deny !cluster
#http_reply_access deny !cluster

#Diese Zeile würde _jedem_ Zugriff auf squid geben
#http_access allow all

#Sicher ist sicher: alles was man nicht erlaubt hat wird abgelehnt
http_access deny all
http_reply_access allow all
icp_access allow all
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
dns_testnames 10.10.1.11
coredump_dir /var/cache/squid
ignore_unknown_nameservers on
balance_on_multiple_ip off


PS.: Das benutze ich hier, um Zugriff nur aus dem lokalen Netz zu ermöglichen:
Code:

#custom
acl localnet src 192.168.0.0/24 192.168.2.0/24 192.168.1.0/24
...
http_access allow localnet
http_access deny all
http_reply_access allow all
icp_access allow all
...
Back to top
View user's profile Send private message
sokar2000
Tux's lil' helper
Tux's lil' helper


Joined: 17 Feb 2005
Posts: 137
Location: Zu Hause

PostPosted: Fri May 20, 2005 8:10 pm    Post subject: Reply with quote

Mein Gott! Diese besch*****e kleine Zeile hat mich nun fast drei Tage gekostet. Und wieder mal bewarheitet sich der alte Spruch in unserer Frima: Der grösste Fehler liegt meist am kleinsten Häkchen.

myself wrote:
Code:
acl cluster dst 10.10.1.11
http_access deny !cluster
http_reply_access deny !cluster


Ich möchte, dass jedermann auf der Welt den Proxie benutzen kann (bzw. muss). Allerdings will ich, dass Squid ausschliesslich auf die interne IP 10.10.1.11 zugreifen kann. Jede andere IP soll für ihn gesperrt sein, dass mir nicht irgend einer den Proxy als offener Proxy benutzt. Mir gehts darum, dass der Zugriff vom Internet auf unseren Webcluster beschleunigt wird.

Bei dieser gewünschten Aufgabe, da sind die oberen drei in meinen Augen richtig. Oder unterliege ich hier auch einem Irrtum?

Vielen vielen Dank für Deine bisherige Hilfe, flash49. Du hast mir das Wochenende gerettet!
Back to top
View user's profile Send private message
flash49
Apprentice
Apprentice


Joined: 12 Feb 2005
Posts: 233

PostPosted: Fri May 20, 2005 9:32 pm    Post subject: Reply with quote

Quote:
Ich möchte, dass jedermann auf der Welt den Proxie benutzen kann (bzw. muss). Allerdings will ich, dass Squid ausschliesslich auf die interne IP 10.10.1.11 zugreifen kann. Jede andere IP soll für ihn gesperrt sein, dass mir nicht irgend einer den Proxy als offener Proxy benutzt. Mir gehts darum, dass der Zugriff vom Internet auf unseren Webcluster beschleunigt wird.

Bei dieser gewünschten Aufgabe, da sind die oberen drei in meinen Augen richtig. Oder unterliege ich hier auch einem Irrtum?

Bei der aktuellen Einstellung kann nur die ip 10.10.1.11 auf den Proxy zugreifen und nur Antworten (also Webeseiten) von sich selbst empfangen.
Die richtige Einstellung wäre:
Quote:

http_reply_access deny !cluster
http_access allow all

Allerdings macht das alleine squid noch nicht zum "revese Proxy". Das ist, was du suchst:
google suche: squid reverse proxy
Dieser Artikel scheint gut zu sein:
http://www.tecchannel.de/betriebssysteme/1535/
Back to top
View user's profile Send private message
sokar2000
Tux's lil' helper
Tux's lil' helper


Joined: 17 Feb 2005
Posts: 137
Location: Zu Hause

PostPosted: Fri May 20, 2005 10:24 pm    Post subject: Reply with quote

Es funktioniert. Ich werde den Squid mal über Nacht ans Netz hängen und mit ethereal den Traffic loggen. Mal sehen, ob der Server jetzt sicherer ist.

Vielen Dank @flash49!!!!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum