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.
47 \item Be aware that if you are backing up your database using the default
48 script, if you have a password on your database, it will be passed as
49 a command line option to that script, and any user will be able to see
50 this information. If you want it to be secure, you will need to pass it
51 by an environment variable or a secure file.
55 \subsection*{Backward Compatibility}
56 \index[general]{Backward Compatibility}
57 \addcontentsline{toc}{subsection}{Backward Compatibility}
58 One of the major goals of Bacula is to ensure that you can restore
59 tapes (I'll use the word tape to include disk Volumes) that you wrote years
60 ago. This means that each new version of Bacula should be able to read old
61 format tapes. The first problem you will have is to ensure that the
62 hardware is still working some years down the road, and the second
63 problem will be to ensure that the media will still be good, then
64 your OS must be able to interface to the device, and finally Bacula
65 must be able to recogize old formats. All the problems except the
66 last are ones that we cannot solve, but by careful planning you can.
68 Since the very beginning of Bacula (January 2000) until today (December
69 2005), there have been two major Bacula tape formats. The second format
70 was introduced in version 1.27 in November of 2002, and it has not
71 changed since then. In principle, Bacula can still read the original
72 format, but I haven't tried it lately so who knows ...
74 Though the tape format is fixed, the kinds of data that we can put on the
75 tapes are extensible, and that is how we added new features
76 such as ACLs, Win32 data, encrypted data, ... Obviously, an older
77 version of Bacula would not know how to read these newer data streams,
78 but each newer version of Bacula should know how to read all the
81 If you want to be 100% sure that you can read old tapes, you
84 1. Try reading old tapes from time to time -- e.g. at least once
87 2. Keep statically linked copies of every version of Bacula that you use
88 in production then if for some reason, we botch up old tape compatibility, you
89 can always pull out an old copy of Bacula ...
91 The second point is probably overkill but if you want to be sure, it may
97 subsection*{Configuring and Testing TCP Wrappers}
98 index[general]{Configuring and Testing TCP Wrappers}
99 addcontentsline{toc}{subsection}{Configuring and Testing TCP Wrappers}
101 TCP Wrappers are implemented if you turn them on when configuring ({\bf
102 ./configure \verb:--:with-libwrap}). With this code enabled, you may control who may
103 access your daemons. This control is done by modifying the file: {\bf
104 /etc/hosts.allow}. The program name that {\bf Bacula} uses when applying these
105 access restrictions is the name you specify in the daemon configuration file.
106 You must not use the {\bf twist} option in your {\bf /etc/hosts.allow} or it
107 will terminate the Bacula daemon when a connection is refused.
109 Dan Langille has provided the following information on configuring and
110 testing TCP wrappers with Bacula.
112 If you read hosts\_options(5), you will see an option called twist. This
113 option replaces the current process by an instance of the specified shell
114 command. Typically, something like this is used:
119 : severity auth.info \
120 : twist /bin/echo "You are not welcome to use %d from %h."
124 The libwrap code tries to avoid {\bf twist} if it runs in a resident process,
125 but that test will not protect the first hosts\_access() call. This will
126 result in the process (e.g. bacula-fd, bacula-sd, bacula-dir) being terminated
127 if the first connection to their port results in the twist option being
128 invoked. The potential, and I strees potential, exists for an attacker to
129 prevent the daemons from running. This situation is eliminated if your
130 /etc/hosts.allow file contains an appropriate ruleset. The following example
135 undef-fd : localhost : allow
136 undef-sd : localhost : allow
137 undef-dir : localhost : allow
138 undef-fd : ALL : deny
139 undef-sd : ALL : deny
140 undef-dir : ALL : deny
144 You must adjust the daemon names to those found in the respective daemon
145 configuration files. In these examples, the Director is undef- dir, the
146 Storage Daemon is undef-sd, and the File Daemon is undef-fd. Adjust to suit
147 your situation. The above example rules assume that the SD, FD, and DIR all
148 reside on the same box. If you have a remote FD client, then the following
149 ruleset on the remote client will suffice:
153 undef-fd : director.example.org : allow
154 undef-fd : ALL : deny
158 where director.example.org is the host which will be contacting the client
159 (ie. the box on which the Bacula Director daemon runs). The use of "ALL :
160 deny" ensures that the twist option (if present) is not invoked. To properly
161 test your configuration, start the daemon(s), then attempt to connect from an
162 IP address which should be able to connect. You should see something like
168 Trying 192.168.0.56...
169 Connected to undef.example.org.
170 Escape character is '^]'.
171 Connection closed by foreign host.
176 This is the correct response. If you see this:
181 Trying 192.168.0.56...
182 Connected to undef.example.org.
183 Escape character is '^]'.
184 You are not welcome to use undef-sd from xeon.example.org.
185 Connection closed by foreign host.
190 then twist has been invoked and your configuration is not correct and you need
191 to add the deny statement. It is important to note that your testing must
192 include restarting the daemons after each connection attempt. You can also
193 tcpdchk(8) and tcpdmatch(8) to validate your /etc/hosts.allow rules. Here is a
194 simple test using tcpdmatch:
198 $ tcpdmatch undef-dir xeon.example.org
199 warning: undef-dir: no such process name in /etc/inetd.conf
200 client: hostname xeon.example.org
201 client: address 192.168.0.18
202 server: process undef-dir
203 matched: /etc/hosts.allow line 40
209 If you are running Bacula as a standalone daemon, the warning above can be
210 safely ignored. Here is an example which indicates that your rules are missing
211 a deny statement and the twist option has been invoked.
215 $ tcpdmatch undef-dir 10.0.0.1
216 warning: undef-dir: no such process name in /etc/inetd.conf
217 client: address 10.0.0.1
218 server: process undef-dir
219 matched: /etc/hosts.allow line 91
220 option: severity auth.info
221 option: twist /bin/echo "You are not welcome to use
222 undef-dir from 10.0.0.1."
227 \subsection*{Running as non-root}
228 \index[general]{Running as non-root }
229 \addcontentsline{toc}{subsection}{Running as non-root}
231 Security advice from Dan Langille:
233 It is a good idea to run daemons with the lowest possible privileges. In
234 other words, if you can, don't run applications as root which do not have to
235 be root. The Storage Daemon and the Director Daemon do not need to be root.
236 The File Daemon needs to be root in order to access all files on your system.
237 In order to run as non-root, you need to create a user and a group. Choosing
238 {\tt bacula} as both the user name and the group name sounds like a good idea
241 The FreeBSD port creates this user and group for you (actually, as I write
242 this, the port doesn't do that, but it soon will). Here is what those entries
243 looked like on my FreeBSD laptop:
247 bacula:*:1002:1002::0:0:Bacul Daemon:/var/db/bacula:/sbin/nologin
251 I used vipw to create this entry. I selected a User ID and Group ID of 1002
252 as they were unused on my system.
254 I also created a group in /etc/group:
262 The bacula user (as opposed to the Bacula daemon) will have a home directory
263 of {\tt /var/db/bacula} which is the default location for the Bacula
266 Now that you have both a bacula user and a bacula group, you can secure the
267 bacula home directory by issuing this command:
271 chown -R bacula:bacula /var/db/bacula/
275 This ensures that only the bacula user can access this directory. It also
276 means that if we run the Director and the Storage daemon as bacula, those
277 daemons also have restricted access. This would not be the case if they were
280 It is important to note that the storage daemon actually needs to be in the
281 operator group for normal access to tape drives etc (at least on a FreeBSD
282 system, that's how things are set up by default) Such devices are normally
283 chown root:operator. It is easier and less error prone to make Bacula a
284 member of that group than it is to play around with system permissions.
286 Starting the Bacula daemons
288 To start the bacula daemons on a FreeBSD system, issue the following command:
292 /usr/local/etc/rc.d/bacula.sh start
296 To confirm they are all running:
300 $ ps auwx | grep bacula
301 root\ 63416\ 0.0\ 0.3\ 2040 1172\ ??\ Ss\ 4:09PM 0:00.01
302 /usr/local/sbin/bacula-sd -v -c /usr/local/etc/bacula-sd.conf
303 root\ 63418\ 0.0\ 0.3\ 1856 1036\ ??\ Ss\ 4:09PM 0:00.00
304 /usr/local/sbin/bacula-fd -v -c /usr/local/etc/bacula-fd.conf
305 root\ 63422\ 0.0\ 0.4\ 2360 1440\ ??\ Ss\ 4:09PM 0:00.00
306 /usr/local/sbin/bacula-dir -v -c /usr/local/etc/bacula-dir.conf