Statistics
| Branch: | Tag: | Revision:

root / doc / security.rst @ 4355b2de

History | View | Annotate | Download (6.9 kB)

1 28cc354f Iustin Pop
Security in Ganeti
2 6884c0ca Iustin Pop
==================
3 28cc354f Iustin Pop
4 3397d13e Michael Hanselmann
Documents Ganeti version 2.6
5 3397d13e Michael Hanselmann
6 28cc354f Iustin Pop
Ganeti was developed to run on internal, trusted systems. As such, the
7 28cc354f Iustin Pop
security model is all-or-nothing.
8 28cc354f Iustin Pop
9 3397d13e Michael Hanselmann
Up to version 2.3 all Ganeti code ran as root. Since version 2.4 it is
10 3397d13e Michael Hanselmann
possible to run all daemons except the node daemon as non-root users by
11 3397d13e Michael Hanselmann
specifying user names and groups at build time. The node daemon
12 3397d13e Michael Hanselmann
continues to require root privileges to create logical volumes, DRBD
13 3397d13e Michael Hanselmann
devices, start instances, etc. Cluster commands can be run as root or by
14 3397d13e Michael Hanselmann
users in a group specified at build time.
15 28cc354f Iustin Pop
16 28cc354f Iustin Pop
Host issues
17 28cc354f Iustin Pop
-----------
18 28cc354f Iustin Pop
19 7faf5110 Michael Hanselmann
For a host on which the Ganeti software has been installed, but not
20 7faf5110 Michael Hanselmann
joined to a cluster, there are no changes to the system.
21 28cc354f Iustin Pop
22 28cc354f Iustin Pop
For a host that has been joined to the cluster, there are very important
23 28cc354f Iustin Pop
changes:
24 6884c0ca Iustin Pop
25 6884c0ca Iustin Pop
- The host will have its SSH host key replaced with the one of the
26 6884c0ca Iustin Pop
  cluster (which is the one the initial node had at the cluster
27 6884c0ca Iustin Pop
  creation)
28 3397d13e Michael Hanselmann
- A new public key will be added to root's ``authorized_keys`` file,
29 6884c0ca Iustin Pop
  granting root access to all nodes of the cluster. The private part of
30 6884c0ca Iustin Pop
  the key is also distributed to all nodes. Old files are renamed.
31 6884c0ca Iustin Pop
- Communication between nodes is encrypted using SSL/TLS. A common key
32 6884c0ca Iustin Pop
  and certificate combo is shared between all nodes of the cluster.  At
33 6884c0ca Iustin Pop
  this time, no CA is used.
34 6884c0ca Iustin Pop
- The Ganeti node daemon will accept RPC requests from any host within
35 6884c0ca Iustin Pop
  the cluster with the correct certificate, and the operations it will
36 6884c0ca Iustin Pop
  do as a result of these requests are:
37 6884c0ca Iustin Pop
38 3397d13e Michael Hanselmann
  - running commands under the ``/etc/ganeti/hooks`` directory
39 6884c0ca Iustin Pop
  - creating DRBD disks between it and the IP it has been told
40 6884c0ca Iustin Pop
  - overwrite a defined list of files on the host
41 28cc354f Iustin Pop
42 28cc354f Iustin Pop
As you can see, as soon as a node is joined, it becomes equal to all
43 28cc354f Iustin Pop
other nodes in the cluster, and the security of the cluster is
44 28cc354f Iustin Pop
determined by the weakest node.
45 28cc354f Iustin Pop
46 3397d13e Michael Hanselmann
Note that only the SSH key will allow other machines to run any command
47 3397d13e Michael Hanselmann
on this node; the RPC method will run only:
48 6884c0ca Iustin Pop
49 6884c0ca Iustin Pop
- well defined commands to create, remove, activate logical volumes,
50 6884c0ca Iustin Pop
  drbd devices, start/stop instances, etc;
51 3397d13e Michael Hanselmann
- run well-defined SSH commands on other nodes in the cluster
52 3397d13e Michael Hanselmann
- scripts under the ``/etc/ganeti/hooks`` directory
53 28cc354f Iustin Pop
54 28cc354f Iustin Pop
It is therefore important to make sure that the contents of the
55 3397d13e Michael Hanselmann
``/etc/ganeti/hooks`` directory is supervised and only trusted sources
56 3397d13e Michael Hanselmann
can populate it.
57 28cc354f Iustin Pop
58 28cc354f Iustin Pop
Cluster issues
59 28cc354f Iustin Pop
--------------
60 28cc354f Iustin Pop
61 3397d13e Michael Hanselmann
As mentioned above, there are multiple ways of communication between
62 3397d13e Michael Hanselmann
cluster nodes:
63 6884c0ca Iustin Pop
64 6884c0ca Iustin Pop
- SSH-based, for high-volume traffic like image dumps or for low-level
65 6884c0ca Iustin Pop
  command, e.g. restarting the Ganeti node daemon
66 6884c0ca Iustin Pop
- RPC communication between master and nodes
67 6884c0ca Iustin Pop
- DRBD real-time disk replication traffic
68 28cc354f Iustin Pop
69 4fbe765c Michael Hanselmann
The SSH traffic is protected (after the initial login to a new node) by
70 4fbe765c Michael Hanselmann
the cluster-wide shared SSH key.
71 28cc354f Iustin Pop
72 7faf5110 Michael Hanselmann
RPC communication between the master and nodes is protected using
73 7faf5110 Michael Hanselmann
SSL/TLS encryption. Both the client and the server must have the
74 7faf5110 Michael Hanselmann
cluster-wide shared SSL/TLS certificate and verify it when establishing
75 7faf5110 Michael Hanselmann
the connection by comparing fingerprints. We decided not to use a CA to
76 7faf5110 Michael Hanselmann
simplify the key handling.
77 28cc354f Iustin Pop
78 6884c0ca Iustin Pop
The DRBD traffic is not protected by encryption, as DRBD does not
79 6884c0ca Iustin Pop
support this. It's therefore recommended to implement host-level
80 888891c7 Michael Hanselmann
firewalling or to use a separate range of IP addresses for the DRBD
81 3397d13e Michael Hanselmann
traffic (this is supported in Ganeti through the use of a secondary
82 3397d13e Michael Hanselmann
interface) which is not routed outside the cluster. DRBD connections are
83 3397d13e Michael Hanselmann
protected from erroneous connections to other machines (as may happen
84 3397d13e Michael Hanselmann
due to software issues), and from accepting connections from other
85 3397d13e Michael Hanselmann
machines, by using a shared secret, exchanged via RPC requests from the
86 3397d13e Michael Hanselmann
master to the nodes when configuring the device.
87 6884c0ca Iustin Pop
88 6884c0ca Iustin Pop
Master daemon
89 6884c0ca Iustin Pop
-------------
90 6884c0ca Iustin Pop
91 3397d13e Michael Hanselmann
The command-line tools to master daemon communication is done via a
92 3397d13e Michael Hanselmann
UNIX socket, whose permissions are reset to ``0660`` after listening but
93 7faf5110 Michael Hanselmann
before serving requests. This permission-based protection is documented
94 7faf5110 Michael Hanselmann
and works on Linux, but is not-portable; however, Ganeti doesn't work on
95 7faf5110 Michael Hanselmann
non-Linux system at the moment.
96 4fbe765c Michael Hanselmann
97 4fbe765c Michael Hanselmann
Remote API
98 4fbe765c Michael Hanselmann
----------
99 4fbe765c Michael Hanselmann
100 7faf5110 Michael Hanselmann
Starting with Ganeti 2.0, Remote API traffic is encrypted using SSL/TLS
101 f1d243bd Michael Hanselmann
by default. It supports Basic authentication as per :rfc:`2617`. Users
102 f1d243bd Michael Hanselmann
can be granted different capabilities. Details can be found in the
103 f1d243bd Michael Hanselmann
:ref:`RAPI documentation <rapi-users>`.
104 4fbe765c Michael Hanselmann
105 7faf5110 Michael Hanselmann
Paths for certificate, private key and CA files required for SSL/TLS
106 7faf5110 Michael Hanselmann
will be set at source configure time. Symlinks or command line
107 7faf5110 Michael Hanselmann
parameters may be used to use different files.
108 558fd122 Michael Hanselmann
109 5b2069a9 Michael Hanselmann
Inter-cluster instance moves
110 5b2069a9 Michael Hanselmann
----------------------------
111 5b2069a9 Michael Hanselmann
112 5b2069a9 Michael Hanselmann
To move instances between clusters, different clusters must be able to
113 5b2069a9 Michael Hanselmann
communicate with each other over a secure channel. Up to and including
114 5b2069a9 Michael Hanselmann
Ganeti 2.1, clusters were self-contained entities and had no knowledge
115 5b2069a9 Michael Hanselmann
of other clusters. With Ganeti 2.2, clusters can exchange data if tokens
116 5b2069a9 Michael Hanselmann
(an encryption certificate) was exchanged by a trusted third party
117 5b2069a9 Michael Hanselmann
before.
118 5b2069a9 Michael Hanselmann
119 4e9dcb8a Guido Trotter
KVM Security
120 4e9dcb8a Guido Trotter
------------
121 4e9dcb8a Guido Trotter
122 4e9dcb8a Guido Trotter
When running KVM instances under Ganeti three security models ara
123 3397d13e Michael Hanselmann
available: "none", "user" and "pool".
124 4e9dcb8a Guido Trotter
125 3397d13e Michael Hanselmann
Under security model "none" instances run by default as root. This means
126 4e9dcb8a Guido Trotter
that, if an instance gets jail broken, it will be able to own the host
127 4e9dcb8a Guido Trotter
node, and thus the ganeti cluster. This is the default model, and the
128 4e9dcb8a Guido Trotter
only one available before Ganeti 2.1.2.
129 4e9dcb8a Guido Trotter
130 3397d13e Michael Hanselmann
Under security model "user" an instance is run as the user specified by
131 3397d13e Michael Hanselmann
the hypervisor parameter "security_domain". This makes it easy to run
132 f7b769b1 Iustin Pop
all instances as non privileged users, and allows one to manually
133 f7b769b1 Iustin Pop
allocate specific users to specific instances or sets of instances. If
134 f7b769b1 Iustin Pop
the specified user doesn't have permissions a jail broken instance will
135 f7b769b1 Iustin Pop
need some local privilege escalation before being able to take over the
136 f7b769b1 Iustin Pop
node and the cluster. It's possible though for a jail broken instance to
137 4e9dcb8a Guido Trotter
affect other ones running under the same user.
138 4e9dcb8a Guido Trotter
139 3397d13e Michael Hanselmann
Under security model "pool" a global cluster-level uid pool is used to
140 4e9dcb8a Guido Trotter
start each instance on the same node under a different user. The uids in
141 4e9dcb8a Guido Trotter
the cluster pool can be set with ``gnt-cluster init`` and ``gnt-cluster
142 4e9dcb8a Guido Trotter
modify``, and must correspond to existing users on all nodes. Ganeti
143 4e9dcb8a Guido Trotter
will then allocate one to each instance, as needed. This way a jail
144 4e9dcb8a Guido Trotter
broken instance won't be able to affect any other. Since the users are
145 4e9dcb8a Guido Trotter
handed out by ganeti in a per-node randomized way, in this mode there is
146 4e9dcb8a Guido Trotter
no way to make sure a particular instance is always run as a certain
147 3397d13e Michael Hanselmann
user. Use mode "user" for that.
148 4e9dcb8a Guido Trotter
149 4e9dcb8a Guido Trotter
In addition to these precautions, if you want to avoid instances sending
150 4e9dcb8a Guido Trotter
traffic on your node network, you can use an iptables rule such as::
151 4e9dcb8a Guido Trotter
152 4e9dcb8a Guido Trotter
  iptables -A OUTPUT -m owner --uid-owner <uid>[-<uid>] -j LOG \
153 4e9dcb8a Guido Trotter
    --log-prefix "ganeti uid pool user network traffic"
154 4e9dcb8a Guido Trotter
  iptables -A OUTPUT -m owner --uid-owner <uid>[-<uid>] -j DROP
155 4e9dcb8a Guido Trotter
156 4e9dcb8a Guido Trotter
This won't affect regular instance traffic (that comes out of the tapX
157 4e9dcb8a Guido Trotter
allocated to the instance, and can be filtered or subject to appropriate
158 4e9dcb8a Guido Trotter
policy routes) but will stop any user generated traffic that might come
159 4e9dcb8a Guido Trotter
from a jailbroken instance.
160 4e9dcb8a Guido Trotter
161 558fd122 Michael Hanselmann
.. vim: set textwidth=72 :
162 c71a1a3d Iustin Pop
.. Local Variables:
163 c71a1a3d Iustin Pop
.. mode: rst
164 c71a1a3d Iustin Pop
.. fill-column: 72
165 c71a1a3d Iustin Pop
.. End: