Debian Codegraph @

manuals/en/main/verify.tex

raw
1 % TODO: this chapter name is confusing ... maybe rename to
2 % TODO: "File Integrity Checking with Bacula"?
3 \chapter{Using \bacula{} to Improve Computer Security}
4 \label{blb:VerifyChapter}
5 \index[general]{Security!Using \bacula{} to Improve Computer }
6 \index[general]{Using \bacula{} to Improve Computer Security }
7
8 % TODO: only those two digest algorithms?
9 % TODO: can it use multiple at a time? (record and use both SHA1 and MD5?)
10 Since \bacula{} maintains a catalog of files, their attributes, and either SHA1
11 or MD5 signatures, it can be an ideal tool for improving computer security.
12 This is done by making a snapshot of your system files with a \textbf{Verify} Job
13 and then checking the current state of your system against the snapshot, on a
14 regular basis (e.g. nightly).
15
16 The first step is to set up a \textbf{Verify} Job and to run it with:
17
18 \begin{bVerbatim}
19 Level = InitCatalog
20 \end{bVerbatim}
21
22
23 The \textbf{InitCatalog} level tells \textbf{\bacula{}} simply to get the information on
24 the specified files and to put it into the catalog. That is your database is
25 initialized and no comparison is done. The \textbf{InitCatalog} is normally run
26 one time manually.
27
28 Thereafter, you will run a Verify Job on a daily (or whatever) basis with:
29
30 \begin{bVerbatim}
31 Level = Catalog
32 \end{bVerbatim}
33
34
35 The \textbf{Level = Catalog} level tells \bacula{} to compare the current state of
36 the files on the Client to the last \textbf{InitCatalog} that is stored in the
37 catalog and to report any differences. See the example below for the format of
38 the output.
39
40 You decide what files you want to form your ``snapshot'' by specifying them in
41 a \textbf{FileSet} resource, and normally, they will be system files that do not
42 change, or that only certain features change.
43
44 Then you decide what attributes of each file you want compared by specifying
45 comparison options on the \textbf{Include} statements that you use in the
46 \textbf{FileSet} resource of your \textbf{Catalog} Jobs.
47
48 \section{The Details}
49 \index[general]{Details }
50
51 In the discussion that follows, we will make reference to the Verify
52 Configuration Example that is included below in the
53 \textbf{A Verify Configuration Example} section. You might want to look it over now to get an
54 idea of what it does.
55
56 The main elements consist of adding a schedule, which will normally be run
57 daily, or perhaps more often. This is provided by the \textbf{VerifyCycle}
58 Schedule, which runs at 5:05 in the morning every day.
59
60 Then you must define a Job, much as is done below. We recommend that the Job
61 name contain the name of your machine as well as the word \textbf{Verify} or
62 \textbf{Check}. In our example, we named it \textbf{MatouVerify}. This will permit you to
63 easily identify your job when running it from the Console.
64
65 You will notice that most records of the Job are quite standard, but that the
66 \textbf{FileSet} resource contains \textbf{verify=pins1} option in addition to the
67 standard \textbf{signature=SHA1} option. If you don't want SHA1 signature
68 comparison, and we cannot imagine why not, you can drop the
69 \textbf{signature=SHA1} and none will be computed nor stored in the catalog. Or
70 alternatively, you can use \textbf{verify=pins5} and \textbf{signature=MD5}, which
71 will use the MD5 hash algorithm. The MD5 hash computes faster than SHA1, but
72 is cryptographically less secure.
73
74 The \textbf{verify=pins1} is ignored during the \textbf{InitCatalog} Job, but is
75 used during the subsequent \textbf{Catalog} Jobs to specify what attributes of
76 the files should be compared to those found in the catalog. \textbf{pins1} is a
77 reasonable set to begin with, but you may want to look at the details of these
78 and other options. They can be found in the
79 \bilink{FileSet Resource}{blb:FileSetResource} section of this manual.
80 Briefly, however, the \textbf{p} of the \textbf{pins1} tells Verify to compare the
81 permissions bits, the \textbf{i} is to compare inodes, the \textbf{n} causes
82 comparison of the number of links, the \textbf{s} compares the file size, and the
83 \textbf{1} compares the SHA1 checksums (this requires the \textbf{signature=SHA1}
84 option to have been set also).
85
86 You must also specify the \textbf{Client} and the \textbf{Catalog} resources for
87 your Verify job, but you probably already have them created for your client
88 and do not need to recreate them, they are included in the example below for
89 completeness.
90
91 As mentioned above, you will need to have a \textbf{FileSet} resource for the
92 Verify job, which will have the additional \textbf{verify=pins1} option. You will
93 want to take some care in defining the list of files to be included in your
94 \textbf{FileSet}. Basically, you will want to include all system (or other) files
95 that should not change on your system. If you select files, such as log files
96 or mail files, which are constantly changing, your automatic Verify job will
97 be constantly finding differences. The objective in forming the FileSet is to
98 choose all unchanging important system files. Then if any of those files has
99 changed, you will be notified, and you can determine if it changed because you
100 loaded a new package, or because someone has broken into your computer and
101 modified your files. The example below shows a list of files that I use on my
102 Red Hat 7.3 system. Since I didn't spend a lot of time working on it, it
103 probably is missing a few important files (if you find one, please send it to
104 me). On the other hand, as long as I don't load any new packages, none of
105 these files change during normal operation of the system.
106
107 \section{Running the Verify}
108 \index[general]{Running the Verify }
109 \index[general]{Verify!Running the }
110
111 The first thing you will want to do is to run an \textbf{InitCatalog} level
112 Verify Job. This will initialize the catalog to contain the file information
113 that will later be used as a basis for comparisons with the actual file
114 system, thus allowing you to detect any changes (and possible intrusions into
115 your system).
116
117 The easiest way to run the \textbf{InitCatalog} is manually with the console
118 program by simply entering \bcommandname{run}. You will be presented with a list of
119 Jobs that can be run, and you will choose the one that corresponds to your
120 Verify Job, \textbf{MatouVerify} in this example.
121
122 \begin{bVerbatim}
123 The defined Job resources are:
124 1: MatouVerify
125 2: kernsrestore
126 3: Filetest
127 4: kernsave
128 Select Job resource (1-4): 1
129 \end{bVerbatim}
130
131
132 Next, the console program will show you the basic parameters of the Job and
133 ask you:
134
135 \begin{bVerbatim}
136 Run Verify job
137 JobName: MatouVerify
138 FileSet: Verify Set
139 Level: Catalog
140 Client: MatouVerify
141 Storage: DLTDrive
142 Verify Job:
143 Verify List: /tmp/regress/working/MatouVerify.bsr
144 OK to run? (yes/mod/no): mod
145 \end{bVerbatim}
146
147
148 Here, you want to respond \textbf{mod} to modify the parameters because the Level
149 is by default set to \textbf{Catalog} and we want to run an \textbf{InitCatalog}
150 Job. After responding \textbf{mod}, the console will ask:
151
152
153 \begin{bVerbatim}
154 Parameters to modify:
155 1: Level
156 2: Storage
157 3: Job
158 4: FileSet
159 5: Client
160 6: When
161 7: Priority
162 8: Pool
163 9: Verify Job
164 Select parameter to modify (1-5): 1
165 \end{bVerbatim}
166
167
168 you should select number 2 to modify the \textbf{Level}, and it will display:
169
170
171 \begin{bVerbatim}
172 Levels:
173 1: Initialize Catalog
174 2: Verify Catalog
175 3: Verify Volume to Catalog
176 4: Verify Disk to Catalog
177 5: Verify Volume Data
178 Select level (1-4): 1
179 \end{bVerbatim}
180
181
182 Choose item 1, and you will see the final display:
183
184
185 \begin{bVerbatim}
186 Run Verify job
187 JobName: MatouVerify
188 FileSet: Verify Set
189 Level: Initcatalog
190 Client: MatouVerify
191 Storage: DLTDrive
192 Verify Job:
193 Verify List: /tmp/regress/working/MatouVerify.bsr
194 OK to run? (yes/mod/no): yes
195 \end{bVerbatim}
196
197
198 at which point you respond \textbf{yes}, and the Job will begin.
199
200 Thereafter the Job will automatically start according to the schedule you
201 have defined. If you wish to immediately verify it, you can simply run a
202 Verify \textbf{Catalog} which will be the default. No differences should be
203 found.
204
205 To use a previous job, you can add \texttt{jobid=xxx} option in \bcommandname{run} command
206 line. It will run the Verify job against the specified job.
207
208 \begin{bVerbatim}
209 *run jobid=1 job=MatouVerify
210 Run Verify job
211 JobName: MatouVerify
212 Level: Catalog
213 Client: 127.0.0.1-fd
214 FileSet: Full Set
215 Pool: Default (From Job resource)
216 Storage: File (From Job resource)
217 Verify Job: MatouVerify.2010-09-08_15.33.33_03
218 Verify List: /tmp/regress/working/MatouVerify.bsr
219 When: 2010-09-08 15:35:32
220 Priority: 10
221 OK to run? (yes/mod/no):
222 \end{bVerbatim}
223
224 \section{What To Do When Differences Are Found}
225 \index[general]{What To Do When Differences Are Found }
226 \index[general]{Found!What To Do When Differences Are }
227
228 If you have setup your messages correctly, you should be notified if there are
229 any differences and exactly what they are. For example, below is the email
230 received after doing an update of OpenSSH:
231
232
233 \begin{bVerbatim}
234 HeadMan: Start Verify JobId 83 Job=RufusVerify.2002-06-25.21:41:05
235 HeadMan: Verifying against Init JobId 70 run 2002-06-21 18:58:51
236 HeadMan: File: /etc/pam.d/sshd
237 HeadMan: st_ino differ. Cat: 4674b File: 46765
238 HeadMan: File: /etc/rc.d/init.d/sshd
239 HeadMan: st_ino differ. Cat: 56230 File: 56231
240 HeadMan: File: /etc/ssh/ssh_config
241 HeadMan: st_ino differ. Cat: 81317 File: 8131b
242 HeadMan: st_size differ. Cat: 1202 File: 1297
243 HeadMan: SHA1 differs.
244 HeadMan: File: /etc/ssh/sshd_config
245 HeadMan: st_ino differ. Cat: 81398 File: 81325
246 HeadMan: st_size differ. Cat: 1182 File: 1579
247 HeadMan: SHA1 differs.
248 HeadMan: File: /etc/ssh/ssh_config.rpmnew
249 HeadMan: st_ino differ. Cat: 812dd File: 812b3
250 HeadMan: st_size differ. Cat: 1167 File: 1114
251 HeadMan: SHA1 differs.
252 HeadMan: File: /etc/ssh/sshd_config.rpmnew
253 HeadMan: st_ino differ. Cat: 81397 File: 812dd
254 HeadMan: st_size differ. Cat: 2528 File: 2407
255 HeadMan: SHA1 differs.
256 HeadMan: File: /etc/ssh/moduli
257 HeadMan: st_ino differ. Cat: 812b3 File: 812ab
258 HeadMan: File: /usr/bin/scp
259 HeadMan: st_ino differ. Cat: 5e07e File: 5e343
260 HeadMan: st_size differ. Cat: 26728 File: 26952
261 HeadMan: SHA1 differs.
262 HeadMan: File: /usr/bin/ssh-keygen
263 HeadMan: st_ino differ. Cat: 5df1d File: 5e07e
264 HeadMan: st_size differ. Cat: 80488 File: 84648
265 HeadMan: SHA1 differs.
266 HeadMan: File: /usr/bin/sftp
267 HeadMan: st_ino differ. Cat: 5e2e8 File: 5df1d
268 HeadMan: st_size differ. Cat: 46952 File: 46984
269 HeadMan: SHA1 differs.
270 HeadMan: File: /usr/bin/slogin
271 HeadMan: st_ino differ. Cat: 5e359 File: 5e2e8
272 HeadMan: File: /usr/bin/ssh
273 HeadMan: st_mode differ. Cat: 89ed File: 81ed
274 HeadMan: st_ino differ. Cat: 5e35a File: 5e359
275 HeadMan: st_size differ. Cat: 219932 File: 234440
276 HeadMan: SHA1 differs.
277 HeadMan: File: /usr/bin/ssh-add
278 HeadMan: st_ino differ. Cat: 5e35b File: 5e35a
279 HeadMan: st_size differ. Cat: 76328 File: 81448
280 HeadMan: SHA1 differs.
281 HeadMan: File: /usr/bin/ssh-agent
282 HeadMan: st_ino differ. Cat: 5e35c File: 5e35b
283 HeadMan: st_size differ. Cat: 43208 File: 47368
284 HeadMan: SHA1 differs.
285 HeadMan: File: /usr/bin/ssh-keyscan
286 HeadMan: st_ino differ. Cat: 5e35d File: 5e96a
287 HeadMan: st_size differ. Cat: 139272 File: 151560
288 HeadMan: SHA1 differs.
289 HeadMan: 25-Jun-2002 21:41
290 JobId: 83
291 Job: RufusVerify.2002-06-25.21:41:05
292 FileSet: Verify Set
293 Verify Level: Catalog
294 Client: RufusVerify
295 Start time: 25-Jun-2002 21:41
296 End time: 25-Jun-2002 21:41
297 Files Examined: 4,258
298 Termination: Verify Differences
299 \end{bVerbatim}
300
301
302 At this point, it was obvious that these files were modified during
303 installation of the \acsp{RPM}. If you want to be super safe, you should run a
304 \textbf{Verify Level=Catalog} immediately before installing new software to verify
305 that there are no differences, then run a \textbf{Verify Level=InitCatalog}
306 immediately after the installation.
307
308 To keep the above email from being sent every night when the Verify Job runs,
309 we simply re-run the Verify Job setting the level to \textbf{InitCatalog} (as we
310 did above in the very beginning). This will re-establish the current state of
311 the system as your new basis for future comparisons. Take care that you don't
312 do an \textbf{InitCatalog} after someone has placed a Trojan horse on your
313 system!
314
315 If you have included in your \textbf{FileSet} a file that is changed by the
316 normal operation of your system, you will get false matches, and you will need
317 to modify the \textbf{FileSet} to exclude that file (or not to Include it), and
318 then re-run the \textbf{InitCatalog}.
319
320 The FileSet that is shown below is what I use on my Red Hat 7.3 system. With a
321 bit more thought, you can probably add quite a number of additional files that
322 should be monitored.
323
324 \section{A Verify Configuration Example}
325 \index[general]{Verify Configuration Example }
326 \index[general]{Example!Verify Configuration }
327
328
329 \begin{bVerbatim}
330 Schedule {
331 Name = "VerifyCycle"
332 Run = Level=Catalog sun-sat at 5:05
333 }
334 Job {
335 Name = "MatouVerify"
336 Type = Verify
337 Level = Catalog # default level
338 Client = MatouVerify
339 FileSet = "Verify Set"
340 Messages = Standard
341 Storage = DLTDrive
342 Pool = Default
343 Schedule = "VerifyCycle"
344 }
345 #
346 # The list of files in this FileSet should be carefully
347 # chosen. This is a good starting point.
348 #
349 FileSet {
350 Name = "Verify Set"
351 Include {
352 Options {
353 verify=pins1
354 signature=SHA1
355 }
356 File = /boot
357 File = /bin
358 File = /sbin
359 File = /usr/bin
360 File = /lib
361 File = /root/.ssh
362 File = /home/kern/.ssh
363 File = /var/named
364 File = /etc/sysconfig
365 File = /etc/ssh
366 File = /etc/security
367 File = /etc/exports
368 File = /etc/rc.d/init.d
369 File = /etc/sendmail.cf
370 File = /etc/sysctl.conf
371 File = /etc/services
372 File = /etc/xinetd.d
373 File = /etc/hosts.allow
374 File = /etc/hosts.deny
375 File = /etc/hosts
376 File = /etc/modules.conf
377 File = /etc/named.conf
378 File = /etc/pam.d
379 File = /etc/resolv.conf
380 }
381 Exclude = { }
382 }
383 Client {
384 Name = MatouVerify
385 Address = lmatou
386 Catalog = Bacula
387 Password = ""
388 File Retention = 80d # 80 days
389 Job Retention = 1y # one year
390 AutoPrune = yes # Prune expired Jobs/Files
391 }
392 Catalog {
393 Name = Bacula
394 dbname = verify; user = bacula; password = ""
395 }
396 \end{bVerbatim}