| 1 |
\chapter{\bacula{} Security Issues} |
| 2 |
\label{blb:SecurityChapter} |
| 3 |
\index[general]{\bacula{} Security Issues} |
| 4 |
\index[general]{Security} |
| 5 |
\index[general]{Issues!\bacula{} Security} |
| 6 |
|
| 7 |
\begin{bitemize} |
| 8 |
\item Security means being able to restore your files, so read the |
| 9 |
\bilink{Critical Items Chapter}{blb:Critical} of this manual. |
| 10 |
\item The Clients (\btool{bacula-fd}) must run as root to be able to access all |
| 11 |
the system files. |
| 12 |
\item It is not necessary to run the Director as \texttt{root}. |
| 13 |
\item It is not necessary to run the Storage daemon as \texttt{root}, but you must |
| 14 |
ensure that it can open the tape drives, which are often restricted to \texttt{root} |
| 15 |
access by default. In addition, if you do not run the Storage daemon as \texttt{root}, |
| 16 |
it will not be able to automatically set your tape drive parameters on most |
| 17 |
\acs{OS}es since these functions, unfortunately require root access. |
| 18 |
\item You should restrict access to the \bacula{} configuration files, so that |
| 19 |
the passwords are not world-readable. The \textbf{\bacula{}} daemons are password |
| 20 |
protected using CRAM-MD5 (i.e. the password is not sent across the network). |
| 21 |
This will ensure that not everyone can access the daemons. It is a reasonably |
| 22 |
good protection, but can be cracked by experts. |
| 23 |
\item If you are using the recommended ports 9101, 9102, and 9103, you will |
| 24 |
probably want to protect these ports from external access using a firewall |
| 25 |
and/or using tcp wrappers (\bfilename{etc/hosts.allow}). |
| 26 |
\item By default, all data that is sent across the network is unencrypted. |
| 27 |
However, \bacula{} does support \ac{TLS} and can encrypt transmitted data. Please read the |
| 28 |
\bilink{\acs{TLS} (\acs{SSL}) Communications Encryption}{blb:CommEncryption} |
| 29 |
section of this manual. |
| 30 |
\item You should ensure that the \bacula{} working directories are readable and |
| 31 |
writable only by the \bacula{} daemons. |
| 32 |
\item If you are using \mysql{} it is not necessary for it to run with |
| 33 |
\textbf{root} permission. |
| 34 |
\item The default \bacula{} \btool{grant-mysql-permissions} script grants all |
| 35 |
permissions to use the \mysql{} database without a password. If you want |
| 36 |
security, please tighten this up! |
| 37 |
\item Don't forget that \bacula{} is a network program, so anyone anywhere on |
| 38 |
the network with the console program and the Director's password can access |
| 39 |
\bacula{} and the backed up data. |
| 40 |
\item You can restrict what IP addresses \bacula{} will bind to by using the |
| 41 |
appropriate \textbf{DirAddress}, \textbf{FDAddress}, or \textbf{SDAddress} records in |
| 42 |
the respective daemon configuration files. |
| 43 |
\item Be aware that if you are backing up your database using the default |
| 44 |
script, if you have a password on your database, it will be passed as |
| 45 |
a command line option to that script, and any user will be able to see |
| 46 |
this information. If you want it to be secure, you will need to pass it |
| 47 |
by an environment variable or a secure file. |
| 48 |
|
| 49 |
See also \bilink{Backing Up Your \bacula{} Database --- Security Considerations}{blb:BackingUp\bacula{}SecurityConsiderations} |
| 50 |
for more information. |
| 51 |
\end{bitemize} |
| 52 |
|
| 53 |
|
| 54 |
\section{Backward Compatibility} |
| 55 |
\index[general]{Backward Compatibility} |
| 56 |
One of the major goals of \bacula{} is to ensure that you can restore |
| 57 |
tapes (I'll use the word tape to include disk Volumes) that you wrote years |
| 58 |
ago. This means that each new version of \bacula{} should be able to read old |
| 59 |
format tapes. The first problem you will have is to ensure that the |
| 60 |
hardware is still working some years down the road, and the second |
| 61 |
problem will be to ensure that the media will still be good, then |
| 62 |
your \acs{OS} must be able to interface to the device, and finally \bacula{} |
| 63 |
must be able to recognize old formats. All the problems except the |
| 64 |
last are ones that we cannot solve, but by careful planning you can. |
| 65 |
|
| 66 |
Since the very beginning of \bacula{} (January 2000) until today (December |
| 67 |
2005), there have been two major \bacula{} tape formats. The second format |
| 68 |
was introduced in version 1.27 in November of 2002, and it has not |
| 69 |
changed since then. In principle, \bacula{} can still read the original |
| 70 |
format, but I haven't tried it lately so who knows \ldots{} |
| 71 |
|
| 72 |
Though the tape format is fixed, the kinds of data that we can put on the |
| 73 |
tapes are extensible, and that is how we added new features |
| 74 |
such as \acsp{ACL}, Win32 data, encrypted data, \ldots{} Obviously, an older |
| 75 |
version of \bacula{} would not know how to read these newer data streams, |
| 76 |
but each newer version of \bacula{} should know how to read all the |
| 77 |
older streams. |
| 78 |
|
| 79 |
If you want to be 100\% sure that you can read old tapes, you should: |
| 80 |
\begin{benumerate} |
| 81 |
\item Try reading old tapes from time to time -- e.g. at least once a year. |
| 82 |
\item Keep statically linked copies of every version of \bacula{} that you use in |
| 83 |
production then if for some reason, we botch up old tape compatibility, you |
| 84 |
can always pull out an old copy of \bacula{} \ldots{} |
| 85 |
\end{benumerate} |
| 86 |
The second point is probably overkill but if you want to be sure, it may |
| 87 |
save you someday. |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
\label{blb:wrappers} |
| 92 |
\section{Configuring and Testing TCP Wrappers} |
| 93 |
\index[general]{Configuring and Testing TCP Wrappers} |
| 94 |
\index[general]{TCP Wrappers} |
| 95 |
\index[general]{Wrappers!TCP} |
| 96 |
\index[general]{libwrappers} |
| 97 |
|
| 98 |
TCP Wrappers are implemented if you turn them on when configuring |
| 99 |
(\btool{./configure {-}{-}with-tcp-wrappers}). |
| 100 |
With this code enabled, you may control who may access your |
| 101 |
daemons. This control is done by modifying the file: \bfilename{/etc/hosts.allow}. |
| 102 |
The program name that \textbf{\bacula{}} uses when |
| 103 |
applying these access restrictions is the name you specify in the |
| 104 |
daemon configuration file (see below for examples). |
| 105 |
You must not use the \textbf{twist} option in your \bfilename{/etc/hosts.allow} |
| 106 |
or it will terminate the \bacula{} daemon when a connection is refused. |
| 107 |
|
| 108 |
The exact name of the package you need loaded to build with TCP wrappers |
| 109 |
depends on the system. For example, on SuSE, the TCP wrappers libraries needed to link \bacula{} are |
| 110 |
contained in the tcpd-devel package. On Red Hat, the package is named |
| 111 |
\texttt{tcp\_wrappers}. |
| 112 |
|
| 113 |
Dan Langille has provided the following information on configuring and |
| 114 |
testing TCP wrappers with \bacula{}. |
| 115 |
|
| 116 |
If you read \texttt{hosts\_options}(5), you will see an option called twist. This |
| 117 |
option replaces the current process by an instance of the specified shell |
| 118 |
command. Typically, something like this is used: |
| 119 |
|
| 120 |
\begin{bVerbatim} |
| 121 |
ALL : ALL \ |
| 122 |
: severity auth.info \ |
| 123 |
: twist /bin/echo "You are not welcome to use %d from %h." |
| 124 |
\end{bVerbatim} |
| 125 |
|
| 126 |
The libwrap code tries to avoid \textbf{twist} if it runs in a resident process, |
| 127 |
but that test will not protect the first \texttt{hosts\_access()} call. This will |
| 128 |
result in the process (e.g. \btool{bacula-fd}, \btool{bacula-sd}, \btool{bacula-dir}) being terminated |
| 129 |
if the first connection to their port results in the twist option being |
| 130 |
invoked. The potential, and I stress potential, exists for an attacker to |
| 131 |
prevent the daemons from running. This situation is eliminated if your |
| 132 |
\bfilename{/etc/hosts.allow} file contains an appropriate rule set. The following example |
| 133 |
is sufficient: |
| 134 |
|
| 135 |
\begin{bVerbatim} |
| 136 |
undef-fd : localhost : allow |
| 137 |
undef-sd : localhost : allow |
| 138 |
undef-dir : localhost : allow |
| 139 |
undef-fd : ALL : deny |
| 140 |
undef-sd : ALL : deny |
| 141 |
undef-dir : ALL : deny |
| 142 |
\end{bVerbatim} |
| 143 |
|
| 144 |
You must adjust the names to be the same as the Name directives found |
| 145 |
in each of the daemon configuration files. They are, in general, not the |
| 146 |
same as the binary daemon names. It is not possible to use the |
| 147 |
daemon names because multiple daemons may be running on the same machine |
| 148 |
but with different configurations. |
| 149 |
|
| 150 |
In these examples, the Director is \texttt{undef-dir}, the |
| 151 |
Storage Daemon is \texttt{undef-sd}, and the File Daemon is \texttt{undef-fd}. Adjust to suit |
| 152 |
your situation. The above example rules assume that the SD, FD, and DIR all |
| 153 |
reside on the same box. If you have a remote FD client, then the following |
| 154 |
rule set on the remote client will suffice: |
| 155 |
|
| 156 |
\begin{bVerbatim} |
| 157 |
undef-fd : director.example.org : allow |
| 158 |
undef-fd : ALL : deny |
| 159 |
\end{bVerbatim} |
| 160 |
|
| 161 |
where \url{director.example.org} is the host which will be contacting the client |
| 162 |
(ie. the box on which the \bacula{} Director daemon runs). The use of |
| 163 |
``ALL : deny'' ensures that the twist option (if present) is not invoked. To properly |
| 164 |
test your configuration, start the daemon(s), then attempt to connect from an |
| 165 |
IP address which should be able to connect. You should see something like |
| 166 |
this: |
| 167 |
|
| 168 |
\begin{bVerbatim} |
| 169 |
$ telnet undef 9103 |
| 170 |
Trying 192.168.0.56... |
| 171 |
Connected to undef.example.org. |
| 172 |
Escape character is '^]'. |
| 173 |
Connection closed by foreign host. |
| 174 |
$ |
| 175 |
\end{bVerbatim} |
| 176 |
|
| 177 |
This is the correct response. If you see this: |
| 178 |
|
| 179 |
\begin{bVerbatim} |
| 180 |
$ telnet undef 9103 |
| 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. |
| 186 |
$ |
| 187 |
\end{bVerbatim} |
| 188 |
|
| 189 |
then twist has been invoked and your configuration is not correct and you need |
| 190 |
to add the deny statement. It is important to note that your testing must |
| 191 |
include restarting the daemons after each connection attempt. You can also use |
| 192 |
\texttt{btool}(8) and \btool{tcpdmatch}(8) to validate your \bfilename{/etc/hosts.allow} rules. Here is a |
| 193 |
simple test using \btool{tcpdmatch}: |
| 194 |
|
| 195 |
\begin{bVerbatim} |
| 196 |
$ tcpdmatch undef-dir xeon.example.org |
| 197 |
warning: undef-dir: no such process name in /etc/inetd.conf |
| 198 |
client: hostname xeon.example.org |
| 199 |
client: address 192.168.0.18 |
| 200 |
server: process undef-dir |
| 201 |
matched: /etc/hosts.allow line 40 |
| 202 |
option: allow |
| 203 |
access: granted |
| 204 |
\end{bVerbatim} |
| 205 |
|
| 206 |
If you are running \bacula{} as a standalone daemon, the warning above can be |
| 207 |
safely ignored. Here is an example which indicates that your rules are missing |
| 208 |
a deny statement and the twist option has been invoked. |
| 209 |
|
| 210 |
\begin{bVerbatim} |
| 211 |
$ tcpdmatch undef-dir 10.0.0.1 |
| 212 |
warning: undef-dir: no such process name in /etc/inetd.conf |
| 213 |
client: address 10.0.0.1 |
| 214 |
server: process undef-dir |
| 215 |
matched: /etc/hosts.allow line 91 |
| 216 |
option: severity auth.info |
| 217 |
option: twist /bin/echo "You are not welcome to use |
| 218 |
undef-dir from 10.0.0.1." |
| 219 |
access: delegated |
| 220 |
\end{bVerbatim} |
| 221 |
|
| 222 |
\section{Running as non-root} |
| 223 |
\index[general]{Running as non-root} |
| 224 |
|
| 225 |
Security advice from Dan Langille: |
| 226 |
% TODO: don't use specific name |
| 227 |
|
| 228 |
% TODO: don't be too specific on operating system |
| 229 |
|
| 230 |
% TODO: maybe remove personalization? |
| 231 |
|
| 232 |
It is a good idea to run daemons with the lowest possible privileges. In |
| 233 |
other words, if you can, don't run applications as root which do not have to |
| 234 |
be root. The Storage Daemon and the Director Daemon do not need to be root. |
| 235 |
The File Daemon needs to be root in order to access all files on your system. |
| 236 |
In order to run as non-root, you need to create a user and a group. Choosing |
| 237 |
\texttt{bacula} as both the user name and the group name sounds like a good idea |
| 238 |
to me. |
| 239 |
|
| 240 |
The FreeBSD port creates this user and group for you. |
| 241 |
Here is what those entries looked like on my FreeBSD laptop: |
| 242 |
|
| 243 |
\begin{bVerbatim} |
| 244 |
bacula:*:1002:1002::0:0:\bacula{} Daemon:/var/db/bacula:/sbin/nologin |
| 245 |
\end{bVerbatim} |
| 246 |
|
| 247 |
I used \btool{vipw} to create this entry. I selected a User ID and Group ID of 1002 |
| 248 |
as they were unused on my system. |
| 249 |
|
| 250 |
I also created a group in \bfilename{/etc/group}: |
| 251 |
\begin{bVerbatim} |
| 252 |
bacula:*:1002: |
| 253 |
\end{bVerbatim} |
| 254 |
|
| 255 |
The \texttt{bacula} user (as opposed to the \bacula{} daemon) will have a home directory |
| 256 |
of \bdirectoryname{/var/db/bacula} which is the default location for the \bacula{} |
| 257 |
database. |
| 258 |
|
| 259 |
Now that you have both a bacula user and a bacula group, you can secure the |
| 260 |
bacula home directory by issuing this command: |
| 261 |
|
| 262 |
\begin{bVerbatim} |
| 263 |
chown -R bacula:bacula /var/db/bacula/ |
| 264 |
\end{bVerbatim} |
| 265 |
|
| 266 |
This ensures that only the bacula user can access this directory. It also |
| 267 |
means that if we run the Director and the Storage daemon as bacula, those |
| 268 |
daemons also have restricted access. This would not be the case if they were |
| 269 |
running as root. |
| 270 |
|
| 271 |
It is important to note that the storage daemon actually needs to be in the |
| 272 |
operator group for normal access to tape drives etc (at least on a FreeBSD |
| 273 |
system, that's how things are set up by default) Such devices are normally |
| 274 |
\btool{chown root:operator}. It is easier and less error prone to make \bacula{} a |
| 275 |
member of that group than it is to play around with system permissions. |
| 276 |
|
| 277 |
Starting the \bacula{} daemons |
| 278 |
|
| 279 |
To start the \bacula{} daemons on a FreeBSD system, issue the following command: |
| 280 |
|
| 281 |
\begin{bVerbatim} |
| 282 |
/usr/local/etc/rc.d/bacula-dir start |
| 283 |
/usr/local/etc/rc.d/bacula-sd start |
| 284 |
/usr/local/etc/rc.d/bacula-fd start |
| 285 |
\end{bVerbatim} |
| 286 |
|
| 287 |
To confirm they are all running: |
| 288 |
|
| 289 |
\begin{bVerbatim} |
| 290 |
$ ps auwx | grep bacula |
| 291 |
root 63418 0.0 0.3 1856 1036 ?? Ss 4:09PM 0:00.00 |
| 292 |
/usr/local/sbin/bacula-fd -v -c /usr/local/etc/bacula-fd.conf |
| 293 |
bacula 63416 0.0 0.3 2040 1172 ?? Ss 4:09PM 0:00.01 |
| 294 |
/usr/local/sbin/bacula-sd -v -c /usr/local/etc/bacula-sd.conf |
| 295 |
bacula 63422 0.0 0.4 2360 1440 ?? Ss 4:09PM 0:00.00 |
| 296 |
/usr/local/sbin/bacula-dir -v -c /usr/local/etc/bacula-dir.conf |
| 297 |
\end{bVerbatim} |