4 \section*{Bacula Security Issues}
5 \label{_ChapterStart14}
6 \index[general]{Bacula Security Issues }
7 \index[general]{Issues!Bacula Security }
8 \addcontentsline{toc}{section}{Bacula Security Issues}
11 \item Security means being able to restore your files, so read the
12 \ilink{Critical Items Chapter}{Critical} of this manual.
13 \item The Clients ({\bf bacula-fd}) must run as root to be able to access all
15 \item It is not necessary to run the Director as root.
16 \item It is not necessary to run the Storage daemon as root, but you must
17 ensure that it can open the tape drives, which are often restricted to root
18 access by default. In addition, if you do not run the Storage daemon as root,
19 it will not be able to automatically set your tape drive parameters on most
20 OSes since these functions, unfortunately require root access.
21 \item You should restrict access to the Bacula configuration files, so that
22 the passwords are not world-readable. The {\bf Bacula} daemons are password
23 protected using CRAM-MD5 (i.e. the password is not sent across the network).
24 This will ensure that not everyone can access the daemons. It is a reasonably
25 good protection, but can be cracked by experts.
26 \item If you are using the recommended ports 9101, 9102, and 9103, you will
27 probably want to protect these ports from external access using a firewall
28 and/or using tcp wrappers ({\bf etc/hosts.allow}).
29 \item Currently all data that is sent across the network is unencrypted. As a
30 consequence, unless you use {\bf ssh} or {\bf stunnel} for port forwarding,
31 it is not recommended to do a backup across an insecure network (e.g. the
32 Internet). In a future version, we plan to have {\bf ssl} encryption
34 \item You should ensure that the Bacula working directories are readable and
35 writable only by the Bacula daemons.
36 \item If you are using {\bf MySQL} it is not necessary for it to run with
37 {\bf root} permission.
38 \item The default Bacula {\bf grant-mysql-permissions} script grants all
39 permissions to use the MySQL database without a password. If you want
40 security, please tighten this up!
41 \item Don't forget that Bacula is a network program, so anyone anywhere on
42 the network with the console program and the Director's password can access
43 Bacula and the backed up data.
44 \item You can restrict what IP addresses Bacula will bind to by using the
45 appropriate {\bf DirAddress}, {\bf FDAddress}, or {\bf SDAddress} records in
46 the respective daemon configuration files.
50 \subsection*{Backward Compatibility}
51 \index[general]{Backward Compatibility}
52 \addcontentsline{toc}{subsection}{Backward Compatibility}
53 One of the major goals of Bacula is to ensure that you can restore
54 tapes (I'll use the word tape to include disk Volumes) that you wrote years
55 ago. This means that each new version of Bacula should be able to read old
56 format tapes. The first problem you will have is to ensure that the
57 hardware is still working some years down the road, and the second
58 problem will be to ensure that the media will still be good, then
59 your OS must be able to interface to the device, and finally Bacula
60 must be able to recogize old formats. All the problems except the
61 last are ones that we cannot solve, but by careful planning you can.
63 Since the very beginning of Bacula (January 2000) until today (December
64 2005), there have been two major Bacula tape formats. The second format
65 was introduced in version 1.27 in November of 2002, and it has not
66 changed since then. In principle, Bacula can still read the original
67 format, but I haven't tried it lately so who knows ...
69 Though the tape format is fixed, the kinds of data that we can put on the
70 tapes are extensible, and that is how we added new features
71 such as ACLs, Win32 data, encrypted data, ... Obviously, an older
72 version of Bacula would not know how to read these newer data streams,
73 but each newer version of Bacula should know how to read all the
76 If you want to be 100% sure that you can read old tapes, you
79 1. Try reading old tapes from time to time -- e.g. at least once
82 2. Keep statically linked copies of every version of Bacula that you use
83 in production then if for some reason, we botch up old tape compatibility, you
84 can always pull out an old copy of Bacula ...
86 The second point is probably overkill but if you want to be sure, it may
92 subsection*{Configuring and Testing TCP Wrappers}
93 index[general]{Configuring and Testing TCP Wrappers}
94 addcontentsline{toc}{subsection}{Configuring and Testing TCP Wrappers}
96 TCP Wrappers are implemented if you turn them on when configuring ({\bf
97 ./configure \verb:--:with-libwrap}). With this code enabled, you may control who may
98 access your daemons. This control is done by modifying the file: {\bf
99 /etc/hosts.allow}. The program name that {\bf Bacula} uses when applying these
100 access restrictions is the name you specify in the daemon configuration file.
101 You must not use the {\bf twist} option in your {\bf /etc/hosts.allow} or it
102 will terminate the Bacula daemon when a connection is refused.
104 Dan Langille has provided the following information on configuring and
105 testing TCP wrappers with Bacula.
107 If you read hosts\_options(5), you will see an option called twist. This
108 option replaces the current process by an instance of the specified shell
109 command. Typically, something like this is used:
114 : severity auth.info \
115 : twist /bin/echo "You are not welcome to use %d from %h."
119 The libwrap code tries to avoid {\bf twist} if it runs in a resident process,
120 but that test will not protect the first hosts\_access() call. This will
121 result in the process (e.g. bacula-fd, bacula-sd, bacula-dir) being terminated
122 if the first connection to their port results in the twist option being
123 invoked. The potential, and I strees potential, exists for an attacker to
124 prevent the daemons from running. This situation is eliminated if your
125 /etc/hosts.allow file contains an appropriate ruleset. The following example
130 undef-fd : localhost : allow
131 undef-sd : localhost : allow
132 undef-dir : localhost : allow
133 undef-fd : ALL : deny
134 undef-sd : ALL : deny
135 undef-dir : ALL : deny
139 You must adjust the daemon names to those found in the respective daemon
140 configuration files. In these examples, the Director is undef- dir, the
141 Storage Daemon is undef-sd, and the File Daemon is undef-fd. Adjust to suit
142 your situation. The above example rules assume that the SD, FD, and DIR all
143 reside on the same box. If you have a remote FD client, then the following
144 ruleset on the remote client will suffice:
148 undef-fd : director.example.org : allow
149 undef-fd : ALL : deny
153 where director.example.org is the host which will be contacting the client
154 (ie. the box on which the Bacula Director daemon runs). The use of "ALL :
155 deny" ensures that the twist option (if present) is not invoked. To properly
156 test your configuration, start the daemon(s), then attempt to connect from an
157 IP address which should be able to connect. You should see something like
163 Trying 192.168.0.56...
164 Connected to undef.example.org.
165 Escape character is '^]'.
166 Connection closed by foreign host.
171 This is the correct response. If you see this:
176 Trying 192.168.0.56...
177 Connected to undef.example.org.
178 Escape character is '^]'.
179 You are not welcome to use undef-sd from xeon.example.org.
180 Connection closed by foreign host.
185 then twist has been invoked and your configuration is not correct and you need
186 to add the deny statement. It is important to note that your testing must
187 include restarting the daemons after each connection attempt. You can also
188 tcpdchk(8) and tcpdmatch(8) to validate your /etc/hosts.allow rules. Here is a
189 simple test using tcpdmatch:
193 $ tcpdmatch undef-dir xeon.example.org
194 warning: undef-dir: no such process name in /etc/inetd.conf
195 client: hostname xeon.example.org
196 client: address 192.168.0.18
197 server: process undef-dir
198 matched: /etc/hosts.allow line 40
204 If you are running Bacula as a standalone daemon, the warning above can be
205 safely ignored. Here is an example which indicates that your rules are missing
206 a deny statement and the twist option has been invoked.
210 $ tcpdmatch undef-dir 10.0.0.1
211 warning: undef-dir: no such process name in /etc/inetd.conf
212 client: address 10.0.0.1
213 server: process undef-dir
214 matched: /etc/hosts.allow line 91
215 option: severity auth.info
216 option: twist /bin/echo "You are not welcome to use
217 undef-dir from 10.0.0.1."
222 \subsection*{Running as non-root}
223 \index[general]{Running as non-root }
224 \addcontentsline{toc}{subsection}{Running as non-root}
226 Security advice from Dan Langille:
228 It is a good idea to run daemons with the lowest possible privileges. In
229 other words, if you can, don't run applications as root which do not have to
230 be root. The Storage Daemon and the Director Daemon do not need to be root.
231 The File Daemon needs to be root in order to access all files on your system.
232 In order to run as non-root, you need to create a user and a group. Choosing
233 {\tt bacula} as both the user name and the group name sounds like a good idea
236 The FreeBSD port creates this user and group for you (actually, as I write
237 this, the port doesn't do that, but it soon will). Here is what those entries
238 looked like on my FreeBSD laptop:
242 bacula:*:1002:1002::0:0:Bacul Daemon:/var/db/bacula:/sbin/nologin
246 I used vipw to create this entry. I selected a User ID and Group ID of 1002
247 as they were unused on my system.
249 I also created a group in /etc/group:
257 The bacula user (as opposed to the Bacula daemon) will have a home directory
258 of {\tt /var/db/bacula} which is the default location for the Bacula
261 Now that you have both a bacula user and a bacula group, you can secure the
262 bacula home directory by issuing this command:
266 chown -R bacula:bacula /var/db/bacula/
270 This ensures that only the bacula user can access this directory. It also
271 means that if we run the Director and the Storage daemon as bacula, those
272 daemons also have restricted access. This would not be the case if they were
275 It is important to note that the storage daemon actually needs to be in the
276 operator group for normal access to tape drives etc (at least on a FreeBSD
277 system, that's how things are set up by default) Such devices are normally
278 chown root:operator. It is easier and less error prone to make Bacula a
279 member of that group than it is to play around with system permissions.
281 Starting the Bacula daemons
283 To start the bacula daemons on a FreeBSD system, issue the following command:
287 /usr/local/etc/rc.d/bacula.sh start
291 To confirm they are all running:
295 $ ps auwx | grep bacula
296 root\ 63416\ 0.0\ 0.3\ 2040 1172\ ??\ Ss\ 4:09PM 0:00.01
297 /usr/local/sbin/bacula-sd -v -c /usr/local/etc/bacula-sd.conf
298 root\ 63418\ 0.0\ 0.3\ 1856 1036\ ??\ Ss\ 4:09PM 0:00.00
299 /usr/local/sbin/bacula-fd -v -c /usr/local/etc/bacula-fd.conf
300 root\ 63422\ 0.0\ 0.4\ 2360 1440\ ??\ Ss\ 4:09PM 0:00.00
301 /usr/local/sbin/bacula-dir -v -c /usr/local/etc/bacula-dir.conf