~ubuntu-branches/ubuntu/maverick/samba/maverick-security

« back to all changes in this revision

Viewing changes to docs/htmldocs/Samba3-HOWTO/securing-samba.html

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-01-29 06:16:15 UTC
  • mfrom: (0.27.9 upstream) (0.34.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100129061615-37hs6xqpsdhjq3ld
Tags: 2:3.4.5~dfsg-1ubuntu1
* Merge from debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/smb.conf:
    - Add "(Samba, Ubuntu)" to server string.
    - Comment out the default [homes] share, and add a comment about "valid users = %s"
      to show users how to restrict access to \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are allowed to create
      public shares in additon to authenticated ones.
    - add map to guest = Bad user, maps bad username to gues access.
  + debian/samba-common.conf:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/mksambapasswd.awk:
    - Do not add user with UID less than 1000 to smbpasswd.
  + debian/control: 
    - Make libswbclient0 replace/conflict with hardy's likewise-open.
    - Don't build against ctdb, since its not in main yet.
  + debian/rules:
    - Enable "native" PIE hardening.
    - Add BIND_NOW to maximize benefit of RELRO hardening.
  + Add ufw integration:
    - Created debian/samba.ufw.profile.
    - debian/rules, debian/samba.dirs, debian/samba.files: install
  + Add apoort hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + debian/rules, debian/samba.if-up: allow "NetworkManager" as a recognized address
    family... it's obviously /not/ an address family, but it's what gets
    sent when using NM, so we'll cope for now.  (LP: #462169). Taken from karmic-proposed.
  + debian/control: Recommend keyutils for smbfs (LP: #493565)
  + Dropped patches:
    - debian/patches/security-CVE-2009-3297.patch: No longer needed
    - debian/patches/fix-too-many-open-files.patch: No longer needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter�18.�Securing Samba</title><link rel="stylesheet" href="../samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><link rel="home" href="index.html" title="The Official Samba 3.4.x HOWTO and Reference Guide"><link rel="up" href="optional.html" title="Part�III.�Advanced Configuration"><link rel="prev" href="locking.html" title="Chapter�17.�File and Record Locking"><link rel="next" href="InterdomainTrusts.html" title="Chapter�19.�Interdomain Trust Relationships"></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�18.�Securing Samba</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="locking.html">Prev</a>�</td><th width="60%" align="center">Part�III.�Advanced Configuration</th><td width="20%" align="right">�<a accesskey="n" href="InterdomainTrusts.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="securing-samba"></a>Chapter�18.�Securing Samba</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Andrew</span> <span class="orgname">Samba Team</span> <span class="surname">Tridgell</span></h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><code class="email">&lt;<a class="email" href="mailto:tridge@samba.org">tridge@samba.org</a>&gt;</code></p></div></div></div></div><div><div class="author"><h3 class="author"><span class="firstname">John</span> <span class="othername">H.</span> <span class="orgname">Samba Team</span> <span class="surname">Terpstra</span></h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><code class="email">&lt;<a class="email" href="mailto:jht@samba.org">jht@samba.org</a>&gt;</code></p></div></div></div></div><div><p class="pubdate">May 26, 2003</p></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="securing-samba.html#id2618075">Introduction</a></span></dt><dt><span class="sect1"><a href="securing-samba.html#id2618174">Features and Benefits</a></span></dt><dt><span class="sect1"><a href="securing-samba.html#id2618320">Technical Discussion of Protective Measures and Issues</a></span></dt><dd><dl><dt><span class="sect2"><a href="securing-samba.html#id2618336">Using Host-Based Protection</a></span></dt><dt><span class="sect2"><a href="securing-samba.html#id2618490">User-Based Protection</a></span></dt><dt><span class="sect2"><a href="securing-samba.html#id2618550">Using Interface Protection</a></span></dt><dt><span class="sect2"><a href="securing-samba.html#firewallports">Using a Firewall</a></span></dt><dt><span class="sect2"><a href="securing-samba.html#id2618900">Using IPC$ Share-Based Denials </a></span></dt><dt><span class="sect2"><a href="securing-samba.html#id2619044">NTLMv2 Security</a></span></dt></dl></dd><dt><span class="sect1"><a href="securing-samba.html#id2619099">Upgrading Samba</a></span></dt><dt><span class="sect1"><a href="securing-samba.html#id2619142">Common Errors</a></span></dt><dd><dl><dt><span class="sect2"><a href="securing-samba.html#id2619158">Smbclient Works on Localhost, but the Network Is Dead</a></span></dt><dt><span class="sect2"><a href="securing-samba.html#id2619187">Why Can Users Access Other Users' Home Directories?</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2618075"></a>Introduction</h2></div></div></div><p>
2
 
<a class="indexterm" name="id2618083"></a>
3
 
<a class="indexterm" name="id2618090"></a>
4
 
<a class="indexterm" name="id2618097"></a>
5
 
<a class="indexterm" name="id2618104"></a>
6
 
<a class="indexterm" name="id2618111"></a>
7
 
<a class="indexterm" name="id2618117"></a>
8
 
<a class="indexterm" name="id2618124"></a>
 
1
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter�18.�Securing Samba</title><link rel="stylesheet" href="../samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="The Official Samba 3.4.x HOWTO and Reference Guide"><link rel="up" href="optional.html" title="Part�III.�Advanced Configuration"><link rel="prev" href="locking.html" title="Chapter�17.�File and Record Locking"><link rel="next" href="InterdomainTrusts.html" title="Chapter�19.�Interdomain Trust Relationships"></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�18.�Securing Samba</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="locking.html">Prev</a>�</td><th width="60%" align="center">Part�III.�Advanced Configuration</th><td width="20%" align="right">�<a accesskey="n" href="InterdomainTrusts.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter�18.�Securing Samba"><div class="titlepage"><div><div><h2 class="title"><a name="securing-samba"></a>Chapter�18.�Securing Samba</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Andrew</span> <span class="surname">Tridgell</span></h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><code class="email">&lt;<a class="email" href="mailto:tridge@samba.org">tridge@samba.org</a>&gt;</code></p></div></div></div></div><div><div class="author"><h3 class="author"><span class="firstname">John</span> <span class="othername">H.</span> <span class="surname">Terpstra</span></h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><code class="email">&lt;<a class="email" href="mailto:jht@samba.org">jht@samba.org</a>&gt;</code></p></div></div></div></div><div><p class="pubdate">May 26, 2003</p></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="securing-samba.html#id2624168">Introduction</a></span></dt><dt><span class="sect1"><a href="securing-samba.html#id2624266">Features and Benefits</a></span></dt><dt><span class="sect1"><a href="securing-samba.html#id2624413">Technical Discussion of Protective Measures and Issues</a></span></dt><dd><dl><dt><span class="sect2"><a href="securing-samba.html#id2624429">Using Host-Based Protection</a></span></dt><dt><span class="sect2"><a href="securing-samba.html#id2624583">User-Based Protection</a></span></dt><dt><span class="sect2"><a href="securing-samba.html#id2624642">Using Interface Protection</a></span></dt><dt><span class="sect2"><a href="securing-samba.html#firewallports">Using a Firewall</a></span></dt><dt><span class="sect2"><a href="securing-samba.html#id2624993">Using IPC$ Share-Based Denials </a></span></dt><dt><span class="sect2"><a href="securing-samba.html#id2625141">NTLMv2 Security</a></span></dt></dl></dd><dt><span class="sect1"><a href="securing-samba.html#id2625196">Upgrading Samba</a></span></dt><dt><span class="sect1"><a href="securing-samba.html#id2625240">Common Errors</a></span></dt><dd><dl><dt><span class="sect2"><a href="securing-samba.html#id2625255">Smbclient Works on Localhost, but the Network Is Dead</a></span></dt><dt><span class="sect2"><a href="securing-samba.html#id2625284">Why Can Users Access Other Users' Home Directories?</a></span></dt></dl></dd></dl></div><div class="sect1" title="Introduction"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2624168"></a>Introduction</h2></div></div></div><p>
 
2
<a class="indexterm" name="id2624176"></a>
 
3
<a class="indexterm" name="id2624182"></a>
 
4
<a class="indexterm" name="id2624190"></a>
 
5
<a class="indexterm" name="id2624196"></a>
 
6
<a class="indexterm" name="id2624203"></a>
 
7
<a class="indexterm" name="id2624210"></a>
 
8
<a class="indexterm" name="id2624217"></a>
9
9
The information contained in this chapter applies in general to all Samba installations. Security is
10
10
everyone's concern in the information technology world. A surprising number of Samba servers are being
11
11
installed on machines that have direct internet access, thus security is made more critical than it would have been had the
12
12
server been located behind a firewall and on a private network. Paranoia regarding server security is causing
13
13
some  network administrators to insist on the installation of robust firewalls even on servers that are located
14
14
inside secured networks. This chapter provides information to assist the administrator who understands
15
 
how to create the needed barriers and deterents against &#8220;<span class="quote">the enemy</span>&#8221;, no matter where [s]he may
 
15
how to create the needed barriers and deterents against <span class="quote">&#8220;<span class="quote">the enemy</span>&#8221;</span>, no matter where [s]he may
16
16
come from.
17
17
</p><div class="blockquote"><blockquote class="blockquote"><p>
18
 
A new apprentice reported for duty to the chief engineer of a boiler house. He said, &#8220;<span class="quote">Here I am,
19
 
if you will show me the boiler I'll start working on it.</span>&#8221; Then engineer replied, &#8220;<span class="quote">You're leaning
20
 
on it!</span>&#8221;
 
18
A new apprentice reported for duty to the chief engineer of a boiler house. He said, <span class="quote">&#8220;<span class="quote">Here I am,
 
19
if you will show me the boiler I'll start working on it.</span>&#8221;</span> Then engineer replied, <span class="quote">&#8220;<span class="quote">You're leaning
 
20
on it!</span>&#8221;</span>
21
21
</p></blockquote></div><p>
22
22
Security concerns are just like that. You need to know a little about the subject to appreciate
23
23
how obvious most of it really is. The challenge for most of us is to discover that first morsel
24
24
of knowledge with which we may unlock the secrets of the masters.
25
 
</p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2618174"></a>Features and Benefits</h2></div></div></div><p>
26
 
<a class="indexterm" name="id2618182"></a>
27
 
<a class="indexterm" name="id2618189"></a>
28
 
<a class="indexterm" name="id2618196"></a>
29
 
<a class="indexterm" name="id2618203"></a>
 
25
</p></div><div class="sect1" title="Features and Benefits"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2624266"></a>Features and Benefits</h2></div></div></div><p>
 
26
<a class="indexterm" name="id2624274"></a>
 
27
<a class="indexterm" name="id2624281"></a>
 
28
<a class="indexterm" name="id2624288"></a>
 
29
<a class="indexterm" name="id2624295"></a>
30
30
There are three levels at which security principles must be observed in order to render a site
31
31
at least moderately secure. They are the perimeter firewall, the configuration of the host
32
32
server that is running Samba, and Samba itself.
34
34
Samba permits a most flexible approach to network security. As far as possible Samba implements
35
35
the latest protocols to permit more secure MS Windows file and print operations.
36
36
</p><p>
37
 
<a class="indexterm" name="id2618223"></a>
38
 
<a class="indexterm" name="id2618230"></a>
39
 
<a class="indexterm" name="id2618237"></a>
 
37
<a class="indexterm" name="id2624316"></a>
 
38
<a class="indexterm" name="id2624323"></a>
 
39
<a class="indexterm" name="id2624330"></a>
40
40
Samba can be secured from connections that originate from outside the local network. This can be done using
41
41
<span class="emphasis"><em>host-based protection</em></span>, using Samba's implementation of a technology known as
42
 
&#8220;<span class="quote">tcpwrappers,</span>&#8221; or it may be done be using <span class="emphasis"><em>interface-based exclusion</em></span> so
 
42
<span class="quote">&#8220;<span class="quote">tcpwrappers,</span>&#8221;</span> or it may be done be using <span class="emphasis"><em>interface-based exclusion</em></span> so
43
43
<span class="application">smbd</span> will bind only to specifically permitted interfaces. It is also possible to set specific share- or
44
44
resource-based exclusions, for example, on the <em class="parameter"><code>[IPC$]</code></em> autoshare. The <em class="parameter"><code>[IPC$]</code></em> share is used for browsing purposes as well as to establish TCP/IP connections.
45
45
</p><p>
46
 
<a class="indexterm" name="id2618284"></a>
47
 
<a class="indexterm" name="id2618294"></a>
48
 
<a class="indexterm" name="id2618300"></a>
 
46
<a class="indexterm" name="id2624377"></a>
 
47
<a class="indexterm" name="id2624386"></a>
 
48
<a class="indexterm" name="id2624393"></a>
49
49
Another method by which Samba may be secured is by setting Access Control Entries (ACEs) in an Access 
50
50
Control List (ACL) on the shares themselves. This is discussed in
51
51
<a class="link" href="AccessControls.html" title="Chapter�16.�File, Directory, and Share Access Controls">File, Directory, and Share Access Controls</a>.
52
 
</p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2618320"></a>Technical Discussion of Protective Measures and Issues</h2></div></div></div><p>
 
52
</p></div><div class="sect1" title="Technical Discussion of Protective Measures and Issues"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2624413"></a>Technical Discussion of Protective Measures and Issues</h2></div></div></div><p>
53
53
The key challenge of security is that protective measures suffice at best
54
54
only to close the door on known exploits and breach techniques. Never assume that
55
55
because you have followed these few measures, the Samba server is now an impenetrable
56
56
fortress! Given the history of information systems so far, it is only a matter of time
57
57
before someone will find yet another vulnerability.
58
 
</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2618336"></a>Using Host-Based Protection</h3></div></div></div><p>
59
 
<a class="indexterm" name="id2618344"></a>
60
 
<a class="indexterm" name="id2618351"></a>
61
 
<a class="indexterm" name="id2618357"></a>
 
58
</p><div class="sect2" title="Using Host-Based Protection"><div class="titlepage"><div><div><h3 class="title"><a name="id2624429"></a>Using Host-Based Protection</h3></div></div></div><p>
 
59
<a class="indexterm" name="id2624437"></a>
 
60
<a class="indexterm" name="id2624443"></a>
 
61
<a class="indexterm" name="id2624450"></a>
62
62
        In many installations of Samba, the greatest threat comes from outside
63
63
        your immediate network. By default, Samba accepts connections from
64
64
        any host, which means that if you run an insecure version of Samba on
65
65
        a host that is directly connected to the Internet, you can be
66
66
        especially vulnerable.
67
67
        </p><p>
68
 
<a class="indexterm" name="id2618373"></a>
69
 
<a class="indexterm" name="id2618380"></a>
 
68
<a class="indexterm" name="id2624465"></a>
 
69
<a class="indexterm" name="id2624472"></a>
70
70
        One of the simplest fixes in this case is to use the <a class="link" href="smb.conf.5.html#HOSTSALLOW" target="_top">hosts allow</a> and
71
71
        <a class="link" href="smb.conf.5.html#HOSTSDENY" target="_top">hosts deny</a> options in the Samba <code class="filename">smb.conf</code> configuration file to
72
72
        allow access to your server only from a specific range of hosts. An example might be:
73
 
        </p><table class="simplelist" border="0" summary="Simple list"><tr><td><a class="indexterm" name="id2618426"></a><em class="parameter"><code>hosts allow = 127.0.0.1 192.168.2.0/24 192.168.3.0/24</code></em></td></tr><tr><td><a class="indexterm" name="id2618438"></a><em class="parameter"><code>hosts deny = 0.0.0.0/0</code></em></td></tr></table><p>
 
73
        </p><table border="0" summary="Simple list" class="simplelist"><tr><td><a class="indexterm" name="id2624519"></a><em class="parameter"><code>hosts allow = 127.0.0.1 192.168.2.0/24 192.168.3.0/24</code></em></td></tr><tr><td><a class="indexterm" name="id2624531"></a><em class="parameter"><code>hosts deny = 0.0.0.0/0</code></em></td></tr></table><p>
74
74
        </p><p>
75
 
<a class="indexterm" name="id2618453"></a>
76
 
<a class="indexterm" name="id2618460"></a>
77
 
<a class="indexterm" name="id2618467"></a>
 
75
<a class="indexterm" name="id2624546"></a>
 
76
<a class="indexterm" name="id2624553"></a>
 
77
<a class="indexterm" name="id2624560"></a>
78
78
        The above will allow SMB connections only from <code class="constant">localhost</code> (your own
79
79
        computer) and from the two private networks 192.168.2 and 192.168.3. All other
80
80
        connections will be refused as soon as the client sends its first packet. The refusal
81
81
        will be marked as <code class="literal">not listening on called name</code> error.
82
 
        </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2618490"></a>User-Based Protection</h3></div></div></div><p>
 
82
        </p></div><div class="sect2" title="User-Based Protection"><div class="titlepage"><div><div><h3 class="title"><a name="id2624583"></a>User-Based Protection</h3></div></div></div><p>
83
83
        If you want to restrict access to your server to valid users only, then the following
84
84
        method may be of use. In the <code class="filename">smb.conf</code> <em class="parameter"><code>[global]</code></em> section put:
85
 
        </p><table class="simplelist" border="0" summary="Simple list"><tr><td><a class="indexterm" name="id2618518"></a><em class="parameter"><code>valid users = @smbusers, jacko</code></em></td></tr></table><p>
 
85
        </p><table border="0" summary="Simple list" class="simplelist"><tr><td><a class="indexterm" name="id2624610"></a><em class="parameter"><code>valid users = @smbusers, jacko</code></em></td></tr></table><p>
86
86
        </p><p>
87
 
<a class="indexterm" name="id2618533"></a>
 
87
<a class="indexterm" name="id2624626"></a>
88
88
        This restricts all server access either to the user <span class="emphasis"><em>jacko</em></span>
89
89
        or to members of the system group <span class="emphasis"><em>smbusers</em></span>.
90
 
        </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2618550"></a>Using Interface Protection</h3></div></div></div><p>
91
 
<a class="indexterm" name="id2618558"></a>
92
 
<a class="indexterm" name="id2618565"></a>
93
 
<a class="indexterm" name="id2618572"></a>
 
90
        </p></div><div class="sect2" title="Using Interface Protection"><div class="titlepage"><div><div><h3 class="title"><a name="id2624642"></a>Using Interface Protection</h3></div></div></div><p>
 
91
<a class="indexterm" name="id2624650"></a>
 
92
<a class="indexterm" name="id2624657"></a>
 
93
<a class="indexterm" name="id2624664"></a>
94
94
        By default, Samba accepts connections on any network interface that
95
95
        it finds on your system. That means if you have an ISDN line or a PPP
96
96
        connection to the Internet then Samba will accept connections on those
97
97
        links. This may not be what you want.
98
98
        </p><p>
99
99
        You can change this behavior using options like this:
100
 
        </p><table class="simplelist" border="0" summary="Simple list"><tr><td><a class="indexterm" name="id2618593"></a><em class="parameter"><code>interfaces = eth* lo</code></em></td></tr><tr><td><a class="indexterm" name="id2618604"></a><em class="parameter"><code>bind interfaces only = yes</code></em></td></tr></table><p>
 
100
        </p><table border="0" summary="Simple list" class="simplelist"><tr><td><a class="indexterm" name="id2624685"></a><em class="parameter"><code>interfaces = eth* lo</code></em></td></tr><tr><td><a class="indexterm" name="id2624697"></a><em class="parameter"><code>bind interfaces only = yes</code></em></td></tr></table><p>
101
101
        </p><p>
102
 
<a class="indexterm" name="id2618620"></a>
103
 
<a class="indexterm" name="id2618626"></a>
104
 
<a class="indexterm" name="id2618633"></a>
105
 
<a class="indexterm" name="id2618640"></a>
 
102
<a class="indexterm" name="id2624712"></a>
 
103
<a class="indexterm" name="id2624719"></a>
 
104
<a class="indexterm" name="id2624726"></a>
 
105
<a class="indexterm" name="id2624733"></a>
106
106
        This tells Samba to listen for connections only on interfaces with a name starting with
107
107
        <code class="constant">eth</code> such as <code class="constant">eth0</code> or <code class="constant">eth1</code>, plus on the loopback interface called
108
108
        <code class="constant">lo</code>. The name you will need to use depends on what OS you are using. In the above, I used
109
109
        the common name for Ethernet adapters on Linux.
110
110
        </p><p>
111
 
<a class="indexterm" name="id2618670"></a>
112
 
<a class="indexterm" name="id2618676"></a>
113
 
<a class="indexterm" name="id2618683"></a>
114
 
<a class="indexterm" name="id2618689"></a>
 
111
<a class="indexterm" name="id2624762"></a>
 
112
<a class="indexterm" name="id2624769"></a>
 
113
<a class="indexterm" name="id2624775"></a>
 
114
<a class="indexterm" name="id2624782"></a>
115
115
        If you use the above and someone tries to make an SMB connection to your host over a PPP interface called
116
116
        <code class="constant">ppp0</code>, then [s]he will get a TCP connection refused reply. In that case, no Samba code
117
117
        is run at all, because the operating system has been told not to pass connections from that interface to any
118
118
        Samba process. However, the refusal helps a would-be cracker by confirming that the IP address provides
119
119
        valid active services.
120
120
        </p><p>
121
 
<a class="indexterm" name="id2618710"></a>
122
 
<a class="indexterm" name="id2618717"></a>
123
 
<a class="indexterm" name="id2618724"></a>
124
 
<a class="indexterm" name="id2618731"></a>
125
 
<a class="indexterm" name="id2618738"></a>
 
121
<a class="indexterm" name="id2624803"></a>
 
122
<a class="indexterm" name="id2624810"></a>
 
123
<a class="indexterm" name="id2624817"></a>
 
124
<a class="indexterm" name="id2624824"></a>
 
125
<a class="indexterm" name="id2624831"></a>
126
126
        A better response would be to ignore the connection (from, for example, ppp0) altogether. The
127
127
        advantage of ignoring the connection attempt, as compared with refusing it, is that it foils those who
128
128
        probe an interface with the sole intention of finding valid IP addresses for later use in exploitation
129
129
        or denial of service attacks. This method of dealing with potential malicious activity demands the
130
130
        use of appropriate firewall mechanisms.
131
 
        </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="firewallports"></a>Using a Firewall</h3></div></div></div><p>
132
 
<a class="indexterm" name="id2618767"></a>
133
 
<a class="indexterm" name="id2618774"></a>
134
 
<a class="indexterm" name="id2618780"></a>
 
131
        </p></div><div class="sect2" title="Using a Firewall"><div class="titlepage"><div><div><h3 class="title"><a name="firewallports"></a>Using a Firewall</h3></div></div></div><p>
 
132
<a class="indexterm" name="id2624860"></a>
 
133
<a class="indexterm" name="id2624866"></a>
 
134
<a class="indexterm" name="id2624873"></a>
135
135
        Many people use a firewall to deny access to services they do not want exposed outside their network. This can
136
136
        be a good idea, although I recommend using it in conjunction with the above methods so you are protected even
137
137
        if your firewall is not active for some reason.
138
138
        </p><p>
139
139
        If you are setting up a firewall, you need to know what TCP and UDP ports to allow and block. Samba uses
140
140
        the following:
141
 
<a class="indexterm" name="id2618797"></a>
142
 
<a class="indexterm" name="id2618804"></a>
143
 
<a class="indexterm" name="id2618811"></a>
144
 
<a class="indexterm" name="id2618818"></a>
145
 
<a class="indexterm" name="id2618825"></a>
146
 
        </p><table class="simplelist" border="0" summary="Simple list"><tr><td>Port 135/TCP - used by smbd</td></tr><tr><td>Port 137/UDP - used by nmbd</td></tr><tr><td>Port 138/UDP - used by nmbd</td></tr><tr><td>Port 139/TCP - used by smbd</td></tr><tr><td>Port 445/TCP - used by smbd</td></tr></table><p>
147
 
<a class="indexterm" name="id2618859"></a>
 
141
<a class="indexterm" name="id2624890"></a>
 
142
<a class="indexterm" name="id2624897"></a>
 
143
<a class="indexterm" name="id2624904"></a>
 
144
<a class="indexterm" name="id2624911"></a>
 
145
<a class="indexterm" name="id2624918"></a>
 
146
        </p><table border="0" summary="Simple list" class="simplelist"><tr><td>Port 135/TCP - used by smbd</td></tr><tr><td>Port 137/UDP - used by nmbd</td></tr><tr><td>Port 138/UDP - used by nmbd</td></tr><tr><td>Port 139/TCP - used by smbd</td></tr><tr><td>Port 445/TCP - used by smbd</td></tr></table><p>
 
147
<a class="indexterm" name="id2624952"></a>
148
148
        The last one is important because many older firewall setups may not be aware of it, given that this port
149
149
        was only added to the protocol in recent years.
150
150
        </p><p>
151
 
<a class="indexterm" name="id2618872"></a>
152
 
<a class="indexterm" name="id2618879"></a>
153
 
<a class="indexterm" name="id2618886"></a>
 
151
<a class="indexterm" name="id2624965"></a>
 
152
<a class="indexterm" name="id2624972"></a>
 
153
<a class="indexterm" name="id2624979"></a>
154
154
        When configuring a firewall, the high order ports (1024-65535) are often used for outgoing connections and
155
155
        therefore should be permitted through the firewall. It is prudent to block incoming packets on the high order
156
156
        ports except for established connections.
157
 
        </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2618900"></a>Using IPC$ Share-Based Denials </h3></div></div></div><p>
158
 
<a class="indexterm" name="id2618908"></a>
159
 
<a class="indexterm" name="id2618915"></a>
160
 
<a class="indexterm" name="id2618922"></a>
 
157
        </p></div><div class="sect2" title="Using IPC$ Share-Based Denials"><div class="titlepage"><div><div><h3 class="title"><a name="id2624993"></a>Using IPC$ Share-Based Denials </h3></div></div></div><p>
 
158
<a class="indexterm" name="id2625001"></a>
 
159
<a class="indexterm" name="id2625008"></a>
 
160
<a class="indexterm" name="id2625014"></a>
161
161
        If the above methods are not suitable, then you could also place a more specific deny on the IPC$ share that
162
162
        is used in the recently discovered security hole. This allows you to offer access to other shares while
163
163
        denying access to IPC$ from potentially untrustworthy hosts.
164
164
        </p><p>
165
165
        To do this you could use:
166
 
        </p><table class="simplelist" border="0" summary="Simple list"><tr><td> </td></tr><tr><td><em class="parameter"><code>[IPC$]</code></em></td></tr><tr><td><a class="indexterm" name="id2618952"></a><em class="parameter"><code>hosts allow = 192.168.115.0/24 127.0.0.1</code></em></td></tr><tr><td><a class="indexterm" name="id2618964"></a><em class="parameter"><code>hosts deny = 0.0.0.0/0</code></em></td></tr></table><p>
 
166
        </p><table border="0" summary="Simple list" class="simplelist"><tr><td> </td></tr><tr><td><em class="parameter"><code>[IPC$]</code></em></td></tr><tr><td><a class="indexterm" name="id2625049"></a><em class="parameter"><code>hosts allow = 192.168.115.0/24 127.0.0.1</code></em></td></tr><tr><td><a class="indexterm" name="id2625061"></a><em class="parameter"><code>hosts deny = 0.0.0.0/0</code></em></td></tr></table><p>
167
167
        </p><p>
168
 
<a class="indexterm" name="id2618979"></a>
169
 
<a class="indexterm" name="id2618986"></a>
170
 
<a class="indexterm" name="id2618993"></a>
 
168
<a class="indexterm" name="id2625076"></a>
 
169
<a class="indexterm" name="id2625083"></a>
 
170
<a class="indexterm" name="id2625090"></a>
171
171
        This instructs Samba that IPC$ connections are not allowed from anywhere except the two listed network
172
172
        addresses (localhost and the 192.168.115 subnet). Connections to other shares are still allowed. Because the
173
173
        IPC$ share is the only share that is always accessible anonymously, this provides some level of protection
174
174
        against attackers who do not know a valid username/password for your host.
175
175
        </p><p>
176
 
<a class="indexterm" name="id2619010"></a>
177
 
<a class="indexterm" name="id2619017"></a>
178
 
<a class="indexterm" name="id2619024"></a>
 
176
<a class="indexterm" name="id2625107"></a>
 
177
<a class="indexterm" name="id2625114"></a>
 
178
<a class="indexterm" name="id2625121"></a>
179
179
        If you use this method, then clients will be given an <code class="literal">`access denied'</code> reply when they try
180
180
        to access the IPC$ share. Those clients will not be able to browse shares and may also be unable to access
181
181
        some other resources.  This is not recommended unless for some reason you cannot use one of the other methods
182
182
        just discussed.
183
 
        </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2619044"></a>NTLMv2 Security</h3></div></div></div><p>
184
 
<a class="indexterm" name="id2619052"></a>
 
183
        </p></div><div class="sect2" title="NTLMv2 Security"><div class="titlepage"><div><div><h3 class="title"><a name="id2625141"></a>NTLMv2 Security</h3></div></div></div><p>
 
184
<a class="indexterm" name="id2625149"></a>
185
185
        To configure NTLMv2 authentication, the following registry keys are worth knowing about:
186
186
        </p><p>
187
187
                </p><pre class="screen">
201
201
        The value 0x00080000 means permit only NTLMv2 session security. If either NtlmMinClientSec or
202
202
        NtlmMinServerSec is set to 0x00080000, the connection will fail if NTLMv2
203
203
        session security is negotiated.
204
 
        </p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2619099"></a>Upgrading Samba</h2></div></div></div><p>
205
 
<a class="indexterm" name="id2619107"></a>
206
 
<a class="indexterm" name="id2619113"></a>
207
 
<a class="indexterm" name="id2619120"></a>
 
204
        </p></div></div><div class="sect1" title="Upgrading Samba"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2625196"></a>Upgrading Samba</h2></div></div></div><p>
 
205
<a class="indexterm" name="id2625204"></a>
 
206
<a class="indexterm" name="id2625211"></a>
 
207
<a class="indexterm" name="id2625218"></a>
208
208
Please check regularly on <a class="ulink" href="http://www.samba.org/" target="_top">http://www.samba.org/</a> for
209
209
updates and important announcements. Occasionally security releases are made, and it is highly recommended to
210
210
upgrade Samba promptly when a security vulnerability is discovered. Check with your OS vendor for OS-specific
211
211
upgrades.
212
 
</p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2619142"></a>Common Errors</h2></div></div></div><p>
 
212
</p></div><div class="sect1" title="Common Errors"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2625240"></a>Common Errors</h2></div></div></div><p>
213
213
If all Samba and host platform configurations were really as intuitive as one might like them to be, this
214
214
chapter would not be necessary. Security issues are often vexing for a support person to resolve, not because
215
215
of the complexity of the problem, but because most administrators who post what turns out to be a security
216
216
problem request are totally convinced that the problem is with Samba.
217
 
</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2619158"></a>Smbclient Works on Localhost, but the Network Is Dead</h3></div></div></div><p>
 
217
</p><div class="sect2" title="Smbclient Works on Localhost, but the Network Is Dead"><div class="titlepage"><div><div><h3 class="title"><a name="id2625255"></a>Smbclient Works on Localhost, but the Network Is Dead</h3></div></div></div><p>
218
218
        This is a common problem. Linux vendors tend to install a default firewall.
219
219
        With the default firewall in place, only traffic on the loopback adapter (IP address 127.0.0.1)
220
220
        is allowed through the firewall.
222
222
        The solution is either to remove the firewall (stop it) or modify the firewall script to
223
223
        allow SMB networking traffic through. See <a class="link" href="securing-samba.html#firewallports" title="Using a Firewall">the Using a 
224
224
        Firewall</a> section.
225
 
        </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2619187"></a>Why Can Users Access Other Users' Home Directories?</h3></div></div></div><p>
226
 
        &#8220;<span class="quote">
227
 
<a class="indexterm" name="id2619197"></a>
228
 
<a class="indexterm" name="id2619204"></a>
 
225
        </p></div><div class="sect2" title="Why Can Users Access Other Users' Home Directories?"><div class="titlepage"><div><div><h3 class="title"><a name="id2625284"></a>Why Can Users Access Other Users' Home Directories?</h3></div></div></div><p>
 
226
        <span class="quote">&#8220;<span class="quote">
 
227
<a class="indexterm" name="id2625295"></a>
 
228
<a class="indexterm" name="id2625302"></a>
229
229
        We are unable to keep individual users from mapping to any other user's home directory once they have
230
230
        supplied a valid password! They only need to enter their own password. I have not found any method to
231
231
        configure Samba so that users may map only their own home directory.
232
 
        </span>&#8221;
233
 
        </p><p>&#8220;<span class="quote">
 
232
        </span>&#8221;</span>
 
233
        </p><p><span class="quote">&#8220;<span class="quote">
234
234
        User xyzzy can map his home directory. Once mapped, user xyzzy can also map anyone else's home directory.
235
 
        </span>&#8221;</p><p>
236
 
<a class="indexterm" name="id2619226"></a>
237
 
<a class="indexterm" name="id2619233"></a>
 
235
        </span>&#8221;</span></p><p>
 
236
<a class="indexterm" name="id2625324"></a>
 
237
<a class="indexterm" name="id2625331"></a>
238
238
        This is not a security flaw, it is by design. Samba allows users to have exactly the same access to the UNIX
239
239
        file system as when they were logged on to the UNIX box, except that it only allows such views onto the file
240
240
        system as are allowed by the defined shares.
241
241
        </p><p>
242
 
<a class="indexterm" name="id2619248"></a>
243
 
<a class="indexterm" name="id2619255"></a>
 
242
<a class="indexterm" name="id2625345"></a>
 
243
<a class="indexterm" name="id2625352"></a>
244
244
        If your UNIX home directories are set up so that one user can happily <code class="literal">cd</code>
245
245
        into another user's directory and execute <code class="literal">ls</code>, the UNIX security solution is to change file
246
246
        permissions on the user's home directories so that the <code class="literal">cd</code> and <code class="literal">ls</code> are denied.
247
247
        </p><p>
248
 
<a class="indexterm" name="id2619293"></a>
249
 
<a class="indexterm" name="id2619300"></a>
 
248
<a class="indexterm" name="id2625390"></a>
 
249
<a class="indexterm" name="id2625397"></a>
250
250
        Samba tries very hard not to second guess the UNIX administrator's security policies and
251
251
        trusts the UNIX admin to set the policies and permissions he or she desires.
252
252
        </p><p>
255
255
        </p><p>
256
256
        The <a class="link" href="smb.conf.5.html#ONLYUSER" target="_top">only user</a> works in conjunction with the <a class="link" href="smb.conf.5.html#USERS" target="_top">users = list</a>,
257
257
        so to get the behavior you require, add the line:
258
 
        </p><table class="simplelist" border="0" summary="Simple list"><tr><td><a class="indexterm" name="id2619366"></a><em class="parameter"><code>users = %S</code></em></td></tr></table><p>
 
258
        </p><table border="0" summary="Simple list" class="simplelist"><tr><td><a class="indexterm" name="id2625463"></a><em class="parameter"><code>users = %S</code></em></td></tr></table><p>
259
259
        This is equivalent to adding
260
 
        </p><table class="simplelist" border="0" summary="Simple list"><tr><td><a class="indexterm" name="id2619383"></a><em class="parameter"><code>valid users = %S</code></em></td></tr></table><p>
 
260
        </p><table border="0" summary="Simple list" class="simplelist"><tr><td><a class="indexterm" name="id2625480"></a><em class="parameter"><code>valid users = %S</code></em></td></tr></table><p>
261
261
        to the definition of the <em class="parameter"><code>[homes]</code></em> share, as recommended in
262
262
        the <code class="filename">smb.conf</code> man page.
263
263
        </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="locking.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="InterdomainTrusts.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter�17.�File and Record Locking�</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">�Chapter�19.�Interdomain Trust Relationships</td></tr></table></div></body></html>