Clarify that scripts are called synchronously.
[tinc] / doc / SECURITY2
1 This is the security documentation for tinc, a Virtual Private Network daemon.
2
3    Copyright 2001-2006 Guus Sliepen <guus@tinc-vpn.org>,
4              2001-2006 Wessel Dankers <wsl@tinc-vpn.org>
5
6    Permission is granted to make and distribute verbatim copies of
7    this documentation provided the copyright notice and this
8    permission notice are preserved on all copies.
9
10    Permission is granted to copy and distribute modified versions of
11    this documentation under the conditions for verbatim copying,
12    provided that the entire resulting derived work is distributed
13    under the terms of a permission notice identical to this one.
14
15 Proposed new authentication scheme
16 ----------------------------------
17
18 A new scheme for authentication in tinc has been devised, which offers some
19 improvements over the protocol used in 1.0pre2 and 1.0pre3. Explanation is
20 below.
21
22 daemon  message
23 --------------------------------------------------------------------------
24 client  <attempts connection>
25
26 server  <accepts connection>
27
28 client  ID client 12
29               |   +---> version
30               +-------> name of tinc daemon
31
32 server  ID server 12
33               |   +---> version
34               +-------> name of tinc daemon
35
36 client  META_KEY 5f0823a93e35b69e...7086ec7866ce582b
37                  \_________________________________/
38                                  +-> RSAKEYLEN bits totally random string S1,
39                                      encrypted with server's public RSA key
40
41 server  META_KEY 6ab9c1640388f8f0...45d1a07f8a672630
42                  \_________________________________/
43                                  +-> RSAKEYLEN bits totally random string S2,
44                                      encrypted with client's public RSA key
45
46 From now on:
47  - the client will symmetrically encrypt outgoing traffic using S1
48  - the server will symmetrically encrypt outgoing traffic using S2
49
50 client  CHALLENGE da02add1817c1920989ba6ae2a49cecbda0
51                   \_________________________________/
52                                  +-> CHALLEN bits totally random string H1
53
54 server  CHALLENGE 57fb4b2ccd70d6bb35a64c142f47e61d57f
55                   \_________________________________/
56                                  +-> CHALLEN bits totally random string H2
57
58 client  CHAL_REPLY 816a86
59                       +-> 160 bits SHA1 of H2
60
61 server  CHAL_REPLY 928ffe
62                       +-> 160 bits SHA1 of H1
63
64 After the correct challenge replies are recieved, both ends have proved
65 their identity. Further information is exchanged.
66
67 client  ACK 655 123 0
68              |   |  +-> options
69                  |   +----> estimated weight
70                  +--------> listening port of client
71
72 server  ACK 655 321 0
73              |   |  +-> options
74                  |   +----> estimated weight
75                  +--------> listening port of server
76 --------------------------------------------------------------------------
77
78 This new scheme has several improvements, both in efficiency and security.
79
80 First of all, the server sends exactly the same kind of messages over the wire
81 as the client. The previous versions of tinc first authenticated the client,
82 and then the server. This scheme even allows both sides to send their messages
83 simultaneously, there is no need to wait for the other to send something first.
84 This means that any calculations that need to be done upon sending or receiving
85 a message can also be done in parallel. This is especially important when doing
86 RSA encryption/decryption. Given that these calculations are the main part of
87 the CPU time spent for the authentication, speed is improved by a factor 2.
88
89 Second, only one RSA encrypted message is sent instead of two. This reduces the
90 amount of information attackers can see (and thus use for a crypto attack). It
91 also improves speed by a factor two, making the total speedup a factor 4.
92
93 Third, and most important:
94
95 The symmetric cipher keys are exchanged first, the challenge is done
96 afterwards. In the previous authentication scheme, because a man-in-the-middle
97 could pass the challenge/chal_reply phase (by just copying the messages between
98 the two real tinc daemons), but no information was exchanged that was really
99 needed to read the rest of the messages, the challenge/chal_reply phase was of
100 no real use. The man-in-the-middle was only stopped by the fact that only after
101 the ACK messages were encrypted with the symmetric cipher. Potentially, it
102 could even send it's own symmetric key to the server (if it knew the server's
103 public key) and read some of the metadata the server would send it (it was
104 impossible for the mitm to read actual network packets though). The new scheme
105 however prevents this.
106
107 This new scheme makes sure that first of all, symmetric keys are exchanged. The
108 rest of the messages are then encrypted with the symmetric cipher. Then, each
109 side can only read received messages if they have their private key. The
110 challenge is there to let the other side know that the private key is really
111 known, because a challenge reply can only be sent back if the challenge is
112 decrypted correctly, and that can only be done with knowledge of the private
113 key.
114
115 Fourth: the first thing that is send via the symmetric cipher encrypted
116 connection is a totally random string, so that there is no known plaintext (for
117 an attacker) in the beginning of the encrypted stream.
118
119 Some things to be discussed:
120
121  - What should CHALLEN be? Same as RSAKEYLEN? 256 bits? More/less?