/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY TIMESTAMP "2019-08-04">
<!ENTITY % common SYSTEM "common.ent">
%common;
]>

<refentry xmlns:xi="http://www.w3.org/2001/XInclude">
   <refentryinfo>
    <title>Mandos Manual</title>
    <!-- NWalsh’s docbook scripts use this to generate the footer: -->
    <productname>Mandos</productname>
    <productnumber>&version;</productnumber>
    <date>&TIMESTAMP;</date>
    <authorgroup>
      <author>
	<firstname>Björn</firstname>
	<surname>Påhlsson</surname>
	<address>
	  <email>belorn@recompile.se</email>
	</address>
      </author>
      <author>
	<firstname>Teddy</firstname>
	<surname>Hogeborn</surname>
	<address>
	  <email>teddy@recompile.se</email>
	</address>
      </author>
    </authorgroup>
    <copyright>
      <year>2011</year>
      <year>2012</year>
      <year>2013</year>
      <year>2014</year>
      <year>2015</year>
      <year>2016</year>
      <year>2017</year>
      <year>2018</year>
      <year>2019</year>
      <holder>Teddy Hogeborn</holder>
      <holder>Björn Påhlsson</holder>
    </copyright>
    <xi:include href="legalnotice.xml"/>
  </refentryinfo>
  
  <refmeta>
    <refentrytitle>intro</refentrytitle>
    <manvolnum>8mandos</manvolnum>
  </refmeta>
  
  <refnamediv>
    <refname>intro</refname>
    <refpurpose>
      Introduction to the Mandos system
    </refpurpose>
  </refnamediv>
  
  <refsect1 id="description">
    <title>DESCRIPTION</title>
    <para>
      This is the the Mandos system, which allows computers to have
      encrypted root file systems and at the same time be capable of
      remote and/or unattended reboots.
    </para>
    <para>
      The computers run a small client program in the initial RAM disk
      environment which will communicate with a server over a network.
      All network communication is encrypted using TLS.  The clients
      are identified by the server using a TLS public key; each client
      has one unique to it.  The server sends the clients an encrypted
      password.  The encrypted password is decrypted by the clients
      using a separate OpenPGP key, and the password is then used to
      unlock the root file system, whereupon the computers can
      continue booting normally.
    </para>
  </refsect1>
  
  <refsect1 id="introduction">
    <title>INTRODUCTION</title>
    <para>
      <!-- This paragraph is a combination and paraphrase of two
           quotes from the 1995 movie “The Usual Suspects”. -->
      You know how it is.  You’ve heard of it happening.  The Man
      comes and takes away your servers, your friends’ servers, the
      servers of everybody in the same hosting facility. The servers
      of their neighbors, and their neighbors’ friends.  The servers
      of people who owe them money.  And like
      <emphasis>that</emphasis>, they’re gone.  And you doubt you’ll
      ever see them again.
    </para>
    <para>
      That is why your servers have encrypted root file systems.
      However, there’s a downside.  There’s no going around it:
      rebooting is a pain.  Dragging out that rarely-used keyboard and
      screen and unraveling cables behind your servers to plug them in
      to type in that password is messy, especially if you have many
      servers.  There are some people who do clever things like using
      serial line consoles and daisy-chain it to the next server, and
      keep all the servers connected in a ring with serial cables,
      which will work, if your servers are physically close enough.
      There are also other out-of-band management solutions, but with
      <emphasis>all</emphasis> these, you still have to be on hand and
      manually type in the password at boot time.  Otherwise the
      server just sits there, waiting for a password.
    </para>
    <para>
      Wouldn’t it be great if you could have the security of encrypted
      root file systems and still have servers that could boot up
      automatically if there was a short power outage while you were
      asleep?  That you could reboot at will, without having someone
      run over to the server to type in the password?
    </para>
    <para>
      Well, with Mandos, you (almost) can!  The gain in convenience
      will only be offset by a small loss in security.  The setup is
      as follows:
    </para>
    <para>
      The server will still have its encrypted root file system.  The
      password to this file system will be stored on another computer
      (henceforth known as the Mandos server) on the same local
      network.  The password will <emphasis>not</emphasis> be stored
      in plaintext, but encrypted with OpenPGP.  To decrypt this
      password, a key is needed.  This key (the Mandos client key)
      will not be stored there, but back on the original server
      (henceforth known as the Mandos client) in the initial RAM disk
      image.  Oh, and all network Mandos client/server communications
      will be encrypted, using TLS (SSL).
    </para>
    <para>
      So, at boot time, the Mandos client will ask for its encrypted
      data over the network, decrypt the data to get the password, use
      the password to decrypt the root file system, and the client can
      then continue booting.
    </para>
    <para>
      Now, of course the initial RAM disk image is not on the
      encrypted root file system, so anyone who had physical access
      could take the Mandos client computer offline and read the disk
      with their own tools to get the authentication keys used by a
      client.  <emphasis>But</emphasis>, by then the Mandos server
      should notice that the original server has been offline for too
      long, and will no longer give out the encrypted key.  The timing
      here is the only real weak point, and the method, frequency and
      timeout of the server’s checking can be adjusted to any desired
      level of paranoia.
    </para>
    <para>
      (The encrypted keys on the Mandos server is on its normal file
      system, so those are safe, provided the root file system of
      <emphasis>that</emphasis> server is encrypted.)
    </para>
  </refsect1>
  
  <refsect1 id="faq">
    <title>FREQUENTLY ASKED QUESTIONS</title>
    <para>
      Couldn’t the security be defeated by…
    </para>
    <refsect2 id="quick">
      <title>Grabbing the Mandos client key from the
      initrd <emphasis>really quickly</emphasis>?</title>
    <para>
      This, as mentioned above, is the only real weak point.  But if
      you set the timing values tight enough, this will be really
      difficult to do.  An attacker would have to physically
      disassemble the client computer, extract the key from the
      initial RAM disk image, and then connect to a <emphasis>still
      online</emphasis> Mandos server to get the encrypted key, and do
      all this <emphasis>before</emphasis> the Mandos server timeout
      kicks in and the Mandos server refuses to give out the key to
      anyone.
    </para>
    <para>
      Now, as the typical procedure seems to be to barge in and turn
      off and grab <emphasis>all</emphasis> computers, to maybe look
      at them months later, this is not likely.  If someone does that,
      the whole system <emphasis>will</emphasis> lock itself up
      completely, since Mandos servers are no longer running.
    </para>
    <para>
      For sophisticated attackers who <emphasis>could</emphasis> do
      the clever thing, <emphasis>and</emphasis> had physical access
      to the server for enough time, it would be simpler to get a key
      for an encrypted file system by using hardware memory scanners
      and reading it right off the memory bus.
    </para>
    </refsect2>
    
    <refsect2 id="replay">
      <title>Replay attacks?</title>
      <para>
	Nope, the network stuff is all done over TLS, which provides
	protection against that.
      </para>
    </refsect2>
    
    <refsect2 id="mitm">
      <title>Man-in-the-middle?</title>
      <para>
	No.  The server only gives out the passwords to clients which
	have <emphasis>in the TLS handshake</emphasis> proven that
	they do indeed hold the private key corresponding to that
	client.
      </para>
    </refsect2>
    
    <refsect2 id="sniff">
      <title>How about sniffing the network traffic and decrypting it
      later by physically grabbing the Mandos client and using its
      key?</title>
      <para>
	We only use <acronym>PFS</acronym> (Perfect Forward Security)
	key exchange algorithms in TLS, which protects against this.
      </para>
    </refsect2>
    
    <refsect2 id="physgrab">
      <title>Physically grabbing the Mandos server computer?</title>
      <para>
	You could protect <emphasis>that</emphasis> computer the
	old-fashioned way, with a must-type-in-the-password-at-boot
	method.  Or you could have two computers be the Mandos server
	for each other.
      </para>
      <para>
	Multiple Mandos servers can coexist on a network without any
	trouble.  They do not clash, and clients will try all
	available servers.  This means that if just one reboots then
	the other can bring it back up, but if both reboot at the same
	time they will stay down until someone types in the password
	on one of them.
      </para>
    </refsect2>
    
    <refsect2 id="fakecheck">
      <title>Faking checker results?</title>
      <para>
	If the Mandos client does not have an SSH server, the default
	is for the Mandos server to use
	<quote><literal>fping</literal></quote>, the replies to which
	could be faked to eliminate the timeout.  But this could
	easily be changed to any shell command, with any security
	measures you like.  If the Mandos client
	<emphasis>has</emphasis> an SSH server, the default
	configuration (as generated by
	<command>mandos-keygen</command> with the
	<option>--password</option> option) is for the Mandos server
	to use an <command>ssh-keyscan</command> command with strict
	keychecking, which can not be faked.  Alternatively, IPsec
	could be used for the ping packets, making them secure.
      </para>
    </refsect2>
  </refsect1>
  
  <refsect1 id="security">
    <title>SECURITY</title>
    <para>
      So, in summary:  The only weakness in the Mandos system is from
      people who have:
    </para>
    <orderedlist>
      <listitem>
	<para>
	  The power to come in and physically take your servers,
	  <emphasis>and</emphasis>
	</para>
      </listitem>
      <listitem>
	<para>
	  The cunning and patience to do it carefully, one at a time,
	  and <emphasis>quickly</emphasis>, faking Mandos
	  client/server responses for each one before the timeout.
	</para>
      </listitem>
    </orderedlist>
    <para>
      While there are some who may be threatened by people who have
      <emphasis>both</emphasis> these attributes, they do not,
      probably, constitute the majority.
    </para>
    <para>
      If you <emphasis>do</emphasis> face such opponents, you must
      figure that they could just as well open your servers and read
      the file system keys right off the memory by running wires to
      the memory bus.
    </para>
    <para>
      What Mandos is designed to protect against is
      <emphasis>not</emphasis> such determined, focused, and competent
      attacks, but against the early morning knock on your door and
      the sudden absence of all the servers in your server room.
      Which it does nicely.
    </para>
  </refsect1>
  
  <refsect1 id="plugins">
    <title>PLUGINS</title>
    <para>
      In the early designs, the
      <citerefentry><refentrytitle>mandos-client</refentrytitle
      ><manvolnum>8mandos</manvolnum></citerefentry> program (which
      retrieves a password from the Mandos server) also prompted for a
      password on the terminal, in case a Mandos server could not be
      found.  Other ways of retrieving a password could easily be
      envisoned, but this multiplicity of purpose was seen to be too
      complex to be a viable way to continue.  Instead, the original
      program was separated into <citerefentry><refentrytitle
      >mandos-client</refentrytitle><manvolnum>8mandos</manvolnum
      ></citerefentry> and <citerefentry><refentrytitle
      >password-prompt</refentrytitle><manvolnum>8mandos</manvolnum
      ></citerefentry>, and a <citerefentry><refentrytitle
      >plugin-runner</refentrytitle><manvolnum>8mandos</manvolnum
      ></citerefentry> exist to run them both in parallel, allowing
      the first successful plugin to provide the password.  This
      opened up for any number of additional plugins to run, all
      competing to be the first to find a password and provide it to
      the plugin runner.
    </para>
    <para>
      Four additional plugins are provided:
    </para>
    <variablelist>
      <varlistentry>
	<term>
	  <citerefentry><refentrytitle>plymouth</refentrytitle>
	  <manvolnum>8mandos</manvolnum></citerefentry>
	</term>
	<listitem>
	  <para>
	    This prompts for a password when using <citerefentry>
	    <refentrytitle>plymouth</refentrytitle><manvolnum
	    >8</manvolnum></citerefentry>.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  <citerefentry><refentrytitle>usplash</refentrytitle>
	  <manvolnum>8mandos</manvolnum></citerefentry>
	</term>
	<listitem>
	  <para>
	    This prompts for a password when using <citerefentry>
	    <refentrytitle>usplash</refentrytitle><manvolnum
	    >8</manvolnum></citerefentry>.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  <citerefentry><refentrytitle>splashy</refentrytitle>
	  <manvolnum>8mandos</manvolnum></citerefentry>
	</term>
	<listitem>
	  <para>
	    This prompts for a password when using <citerefentry>
	    <refentrytitle>splashy</refentrytitle><manvolnum
	    >8</manvolnum></citerefentry>.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  <citerefentry><refentrytitle>askpass-fifo</refentrytitle>
	  <manvolnum>8mandos</manvolnum></citerefentry>
	</term>
	<listitem>
	  <para>
	    To provide compatibility with the "askpass" program from
	    cryptsetup, this plugin listens to the same FIFO as
	    askpass would do.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
    <para>
      More plugins can easily be written and added by the system
      administrator; see the section called "WRITING PLUGINS" in
      <citerefentry><refentrytitle>plugin-runner</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry> to learn the
      plugin requirements.
    </para>
  </refsect1>

  <refsect1 id="systemd">
    <title>SYSTEMD</title>
    <para>
      More advanced startup systems like <citerefentry><refentrytitle
      >systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
      already have their own plugin-like mechanisms for allowing
      multiple agents to independently retrieve a password and deliver
      it to the subsystem requesting a password to unlock the root
      file system.  On these systems, it would make no sense to run
      <citerefentry><refentrytitle>plugin-runner</refentrytitle
      ><manvolnum>8mandos</manvolnum></citerefentry>, the plugins of
      which would largely duplicate the work of (and conflict with)
      the existing systems prompting for passwords.
    </para>
    <para>
      As for <citerefentry><refentrytitle>systemd</refentrytitle
      ><manvolnum>1</manvolnum></citerefentry> in particular, it has
      its own <ulink
      url="https://www.freedesktop.org/wiki/Software/systemd/PasswordAgents/"
      >Password Agents</ulink> system.  Mandos uses this via its
      <citerefentry><refentrytitle>password-agent</refentrytitle
      ><manvolnum>8mandos</manvolnum></citerefentry> program, which
      is run instead of <citerefentry><refentrytitle
      >plugin-runner</refentrytitle><manvolnum>8mandos</manvolnum
      ></citerefentry> when <citerefentry><refentrytitle
      >systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
      is used during system startup.
    </para>
  </refsect1>
  <refsect1 id="bugs">
    <title>BUGS</title>
    <xi:include href="bugs.xml"/>
  </refsect1>
  
  <refsect1 id="see_also">
    <title>SEE ALSO</title>
    <para>
      <citerefentry><refentrytitle>mandos</refentrytitle>
      <manvolnum>8</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>mandos.conf</refentrytitle>
      <manvolnum>5</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>mandos-clients.conf</refentrytitle>
      <manvolnum>5</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>mandos-ctl</refentrytitle>
      <manvolnum>8</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>mandos-monitor</refentrytitle>
      <manvolnum>8</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>plugin-runner</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>password-agent</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>mandos-client</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>password-prompt</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>plymouth</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>usplash</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>splashy</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>askpass-fifo</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>mandos-keygen</refentrytitle>
      <manvolnum>8</manvolnum></citerefentry>
    </para>
    <variablelist>
      <varlistentry>
	<term>
	  <ulink url="https://www.recompile.se/mandos">Mandos</ulink>
	</term>
	<listitem>
	  <para>
	    The Mandos home page.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
</refentry>
<!-- Local Variables: -->
<!-- time-stamp-start: "<!ENTITY TIMESTAMP [\"']" -->
<!-- time-stamp-end: "[\"']>" -->
<!-- time-stamp-format: "%:y-%02m-%02d" -->
<!-- End: -->