1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
10 TITLE="SAMBA Project Documentation"
11 HREF="samba-howto-collection.html"><LINK
13 TITLE="Advanced Configuration"
14 HREF="optional.html"><LINK
16 TITLE="Stackable VFS modules"
19 TITLE="Unicode/Charsets"
20 HREF="unicode.html"></HEAD
31 SUMMARY="Header navigation table"
40 >SAMBA Project Documentation</TH
77 >Chapter 21. Securing Samba</H1
84 >21.1. Introduction</A
87 >This note was attached to the Samba 2.2.8 release notes as it contained an
88 important security fix. The information contained here applies to Samba
89 installations in general.</P
97 >21.2. Using host based protection</A
100 >In many installations of Samba the greatest threat comes for outside
101 your immediate network. By default Samba will accept connections from
102 any host, which means that if you run an insecure version of Samba on
103 a host that is directly connected to the Internet you can be
104 especially vulnerable.</P
106 >One of the simplest fixes in this case is to use the 'hosts allow' and
107 'hosts deny' options in the Samba smb.conf configuration file to only
108 allow access to your server from a specific range of hosts. An example
112 CLASS="PROGRAMLISTING"
113 > hosts allow = 127.0.0.1 192.168.2.0/24 192.168.3.0/24
114 hosts deny = 0.0.0.0/0</PRE
117 >The above will only allow SMB connections from 'localhost' (your own
118 computer) and from the two private networks 192.168.2 and
119 192.168.3. All other connections will be refused connections as soon
120 as the client sends its first packet. The refusal will be marked as a
121 'not listening on called name' error.</P
129 >21.3. Using interface protection</A
132 >By default Samba will accept connections on any network interface that
133 it finds on your system. That means if you have a ISDN line or a PPP
134 connection to the Internet then Samba will accept connections on those
135 links. This may not be what you want.</P
137 >You can change this behaviour using options like the following:</P
140 CLASS="PROGRAMLISTING"
141 > interfaces = eth* lo
142 bind interfaces only = yes</PRE
147 >This tells Samba to only listen for connections on interfaces with a
148 name starting with 'eth' such as eth0, eth1, plus on the loopback
149 interface called 'lo'. The name you will need to use depends on what
150 OS you are using, in the above I used the common name for Ethernet
151 adapters on Linux.</P
153 >If you use the above and someone tries to make a SMB connection to
154 your host over a PPP interface called 'ppp0' then they will get a TCP
155 connection refused reply. In that case no Samba code is run at all as
156 the operating system has been told not to pass connections from that
157 interface to any process.</P
165 >21.4. Using a firewall</A
168 >Many people use a firewall to deny access to services that they don't
169 want exposed outside their network. This can be a very good idea,
170 although I would recommend using it in conjunction with the above
171 methods so that you are protected even if your firewall is not active
174 >If you are setting up a firewall then you need to know what TCP and
175 UDP ports to allow and block. Samba uses the following:</P
178 CLASS="PROGRAMLISTING"
179 >UDP/137 - used by nmbd
180 UDP/138 - used by nmbd
181 TCP/139 - used by smbd
182 TCP/445 - used by smbd</PRE
185 >The last one is important as many older firewall setups may not be
186 aware of it, given that this port was only added to the protocol in
195 >21.5. Using a IPC$ share deny</A
198 >If the above methods are not suitable, then you could also place a
199 more specific deny on the IPC$ share that is used in the recently
200 discovered security hole. This allows you to offer access to other
201 shares while denying access to IPC$ from potentially untrustworthy
204 >To do that you could use:</P
207 CLASS="PROGRAMLISTING"
209 hosts allow = 192.168.115.0/24 127.0.0.1
210 hosts deny = 0.0.0.0/0</PRE
213 >this would tell Samba that IPC$ connections are not allowed from
214 anywhere but the two listed places (localhost and a local
215 subnet). Connections to other shares would still be allowed. As the
216 IPC$ share is the only share that is always accessible anonymously
217 this provides some level of protection against attackers that do not
218 know a username/password for your host.</P
220 >If you use this method then clients will be given a 'access denied'
221 reply when they try to access the IPC$ share. That means that those
222 clients will not be able to browse shares, and may also be unable to
223 access some other resources. </P
225 >This is not recommended unless you cannot use one of the other
226 methods listed above for some reason.</P
234 >21.6. Upgrading Samba</A
237 >Please check regularly on http://www.samba.org/ for updates and
238 important announcements. Occasionally security releases are made and
239 it is highly recommended to upgrade Samba when a security vulnerability
248 SUMMARY="Footer navigation table"
268 HREF="samba-howto-collection.html"
287 >Stackable VFS modules</TD
301 >Unicode/Charsets</TD