And finally IDMAP in 3_0
[Samba/bb.git] / docs / htmldocs / securing-samba.html
blobae6408ea7b0dc5f242cbf6aef8a41b50b33d7faa
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 24. Securing Samba</title><link rel="stylesheet" href="samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.59.1"><link rel="home" href="index.html" title="SAMBA Project Documentation"><link rel="up" href="optional.html" title="Part III. Advanced Configuration"><link rel="previous" href="integrate-ms-networks.html" title="Chapter 23. Integrating MS Windows networks with Samba"><link rel="next" href="unicode.html" title="Chapter 25. Unicode/Charsets"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 24. Securing Samba</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="integrate-ms-networks.html">Prev</a> </td><th width="60%" align="center">Part III. Advanced Configuration</th><td width="20%" align="right"> <a accesskey="n" href="unicode.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="securing-samba"></a>Chapter 24. Securing Samba</h2></div><div><div class="author"><h3 class="author">Andrew Tridgell</h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt>&lt;<a href="mailto:tridge@samba.org">tridge@samba.org</a>&gt;</tt></p></div></div></div></div><div><div class="author"><h3 class="author">John H. Terpstra</h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt>&lt;<a href="mailto:jht@samba.org">jht@samba.org</a>&gt;</tt></p></div></div></div></div><div><p class="pubdate">17 March 2003</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="securing-samba.html#id2900501">Introduction</a></dt><dt><a href="securing-samba.html#id2900517">Using host based protection</a></dt><dt><a href="securing-samba.html#id2900967">Using interface protection</a></dt><dt><a href="securing-samba.html#id2901018">Using a firewall</a></dt><dt><a href="securing-samba.html#id2901061">Using a IPC$ share deny</a></dt><dt><a href="securing-samba.html#id2900617">NTLMv2 Security</a></dt><dt><a href="securing-samba.html#id2900653">Upgrading Samba</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2900501"></a>Introduction</h2></div></div><p>
3 This note was attached to the Samba 2.2.8 release notes as it contained an
4 important security fix. The information contained here applies to Samba
5 installations in general.
6 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2900517"></a>Using host based protection</h2></div></div><p>
7 In many installations of Samba the greatest threat comes for outside
8 your immediate network. By default Samba will accept connections from
9 any host, which means that if you run an insecure version of Samba on
10 a host that is directly connected to the Internet you can be
11 especially vulnerable.
12 </p><p>
13 One of the simplest fixes in this case is to use the <b>hosts allow</b> and
14 <b>hosts deny</b> options in the Samba <tt>smb.conf</tt> configuration file to only
15 allow access to your server from a specific range of hosts. An example
16 might be:
17 </p><pre class="programlisting">
18 hosts allow = 127.0.0.1 192.168.2.0/24 192.168.3.0/24
19 hosts deny = 0.0.0.0/0
20 </pre><p>
21 The above will only allow SMB connections from 'localhost' (your own
22 computer) and from the two private networks 192.168.2 and
23 192.168.3. All other connections will be refused as soon
24 as the client sends its first packet. The refusal will be marked as a
25 'not listening on called name' error.
26 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2900967"></a>Using interface protection</h2></div></div><p>
27 By default Samba will accept connections on any network interface that
28 it finds on your system. That means if you have a ISDN line or a PPP
29 connection to the Internet then Samba will accept connections on those
30 links. This may not be what you want.
31 </p><p>
32 You can change this behaviour using options like the following:
33 </p><pre class="programlisting">
34 interfaces = eth* lo
35 bind interfaces only = yes
36 </pre><p>
37 This tells Samba to only listen for connections on interfaces with a
38 name starting with 'eth' such as eth0, eth1, plus on the loopback
39 interface called 'lo'. The name you will need to use depends on what
40 OS you are using, in the above I used the common name for Ethernet
41 adapters on Linux.
42 </p><p>
43 If you use the above and someone tries to make a SMB connection to
44 your host over a PPP interface called 'ppp0' then they will get a TCP
45 connection refused reply. In that case no Samba code is run at all as
46 the operating system has been told not to pass connections from that
47 interface to any samba process.
48 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2901018"></a>Using a firewall</h2></div></div><p>
49 Many people use a firewall to deny access to services that they don't
50 want exposed outside their network. This can be a very good idea,
51 although I would recommend using it in conjunction with the above
52 methods so that you are protected even if your firewall is not active
53 for some reason.
54 </p><p>
55 If you are setting up a firewall then you need to know what TCP and
56 UDP ports to allow and block. Samba uses the following:
57 </p><pre class="programlisting">
58 UDP/137 - used by nmbd
59 UDP/138 - used by nmbd
60 TCP/139 - used by smbd
61 TCP/445 - used by smbd
62 </pre><p>
63 The last one is important as many older firewall setups may not be
64 aware of it, given that this port was only added to the protocol in
65 recent years.
66 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2901061"></a>Using a IPC$ share deny</h2></div></div><p>
67 If the above methods are not suitable, then you could also place a
68 more specific deny on the IPC$ share that is used in the recently
69 discovered security hole. This allows you to offer access to other
70 shares while denying access to IPC$ from potentially untrustworthy
71 hosts.
72 </p><p>
73 To do that you could use:
74 </p><pre class="programlisting">
75 [ipc$]
76 hosts allow = 192.168.115.0/24 127.0.0.1
77 hosts deny = 0.0.0.0/0
78 </pre><p>
79 this would tell Samba that IPC$ connections are not allowed from
80 anywhere but the two listed places (localhost and a local
81 subnet). Connections to other shares would still be allowed. As the
82 IPC$ share is the only share that is always accessible anonymously
83 this provides some level of protection against attackers that do not
84 know a username/password for your host.
85 </p><p>
86 If you use this method then clients will be given a 'access denied'
87 reply when they try to access the IPC$ share. That means that those
88 clients will not be able to browse shares, and may also be unable to
89 access some other resources.
90 </p><p>
91 This is not recommended unless you cannot use one of the other
92 methods listed above for some reason.
93 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2900617"></a>NTLMv2 Security</h2></div></div><p>
94 To configure NTLMv2 authentication the following registry keys are worth knowing about:
95 </p><p>
96 </p><pre class="programlisting">
97 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
98 &quot;lmcompatibilitylevel&quot;=dword:00000003
100 0x3 - Send NTLMv2 response only. Clients will use NTLMv2 authentication,
101 use NTLMv2 session security if the server supports it. Domain
102 controllers accept LM, NTLM and NTLMv2 authentication.
104 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0]
105 &quot;NtlmMinClientSec&quot;=dword:00080000
107 0x80000 - NTLMv2 session security. If either NtlmMinClientSec or
108 NtlmMinServerSec is set to 0x80000, the connection will fail if NTLMv2
109 session security is not negotiated.
110 </pre><p>
111 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2900653"></a>Upgrading Samba</h2></div></div><p>
112 Please check regularly on <a href="http://www.samba.org/" target="_top">http://www.samba.org/</a> for updates and
113 important announcements. Occasionally security releases are made and
114 it is highly recommended to upgrade Samba when a security vulnerability
115 is discovered.
116 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="integrate-ms-networks.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="optional.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="unicode.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 23. Integrating MS Windows networks with Samba </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 25. Unicode/Charsets</td></tr></table></div></body></html>