Statistics
| Branch: | Tag: | Revision:

root / doc / security.rst @ 87c7621a

History | View | Annotate | Download (8.9 kB)

1 28cc354f Iustin Pop
Security in Ganeti
2 6884c0ca Iustin Pop
==================
3 28cc354f Iustin Pop
4 b830193c Guido Trotter
Documents Ganeti version 2.7
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 d70571bb Iustin Pop
- scripts under the ``/etc/ganeti/restricted-commands`` directory, if
54 d70571bb Iustin Pop
  this feature has been enabled at build time (see below)
55 28cc354f Iustin Pop
56 28cc354f Iustin Pop
It is therefore important to make sure that the contents of the
57 d70571bb Iustin Pop
``/etc/ganeti/hooks`` and ``/etc/ganeti/restricted-commands``
58 d70571bb Iustin Pop
directories are supervised and only trusted sources can populate them.
59 d70571bb Iustin Pop
60 d70571bb Iustin Pop
Restricted commands
61 d70571bb Iustin Pop
~~~~~~~~~~~~~~~~~~~
62 d70571bb Iustin Pop
63 d70571bb Iustin Pop
The restricted commands feature is new in Ganeti 2.7. It enables the
64 d70571bb Iustin Pop
administrator to run any commands in the
65 d70571bb Iustin Pop
``/etc/ganeti/restricted-commands`` directory, if the feature has been
66 d70571bb Iustin Pop
enabled at build time, subject to the following restrictions:
67 d70571bb Iustin Pop
68 d70571bb Iustin Pop
- No parameters may be passed
69 d70571bb Iustin Pop
- No absolute or relative path may be passed, only a filename
70 d70571bb Iustin Pop
- The ``/etc/ganeti/restricted-commands`` directory must
71 d70571bb Iustin Pop
  be owned by root:root and have mode 0755 or stricter
72 d70571bb Iustin Pop
- Executables must be regular files or symlinks, and must be executable
73 d70571bb Iustin Pop
  by root:root
74 d70571bb Iustin Pop
75 d70571bb Iustin Pop
Note that it's not possible to list the contents of the directory, and
76 d70571bb Iustin Pop
there is an intentional delay when trying to execute a non-existing
77 d70571bb Iustin Pop
command (to slow-down dictionary attacks).
78 d70571bb Iustin Pop
79 d70571bb Iustin Pop
Since for Ganeti itself this functionality is not needed, and is only
80 d70571bb Iustin Pop
provided as a way to help administrate or recover nodes, it is a local
81 d70571bb Iustin Pop
site decision whether to enable or not the restricted commands feature.
82 d70571bb Iustin Pop
83 d70571bb Iustin Pop
By default, this feature is disabled.
84 d70571bb Iustin Pop
85 28cc354f Iustin Pop
86 28cc354f Iustin Pop
Cluster issues
87 28cc354f Iustin Pop
--------------
88 28cc354f Iustin Pop
89 3397d13e Michael Hanselmann
As mentioned above, there are multiple ways of communication between
90 3397d13e Michael Hanselmann
cluster nodes:
91 6884c0ca Iustin Pop
92 6884c0ca Iustin Pop
- SSH-based, for high-volume traffic like image dumps or for low-level
93 6884c0ca Iustin Pop
  command, e.g. restarting the Ganeti node daemon
94 6884c0ca Iustin Pop
- RPC communication between master and nodes
95 6884c0ca Iustin Pop
- DRBD real-time disk replication traffic
96 28cc354f Iustin Pop
97 4fbe765c Michael Hanselmann
The SSH traffic is protected (after the initial login to a new node) by
98 4fbe765c Michael Hanselmann
the cluster-wide shared SSH key.
99 28cc354f Iustin Pop
100 7faf5110 Michael Hanselmann
RPC communication between the master and nodes is protected using
101 7faf5110 Michael Hanselmann
SSL/TLS encryption. Both the client and the server must have the
102 7faf5110 Michael Hanselmann
cluster-wide shared SSL/TLS certificate and verify it when establishing
103 7faf5110 Michael Hanselmann
the connection by comparing fingerprints. We decided not to use a CA to
104 7faf5110 Michael Hanselmann
simplify the key handling.
105 28cc354f Iustin Pop
106 6884c0ca Iustin Pop
The DRBD traffic is not protected by encryption, as DRBD does not
107 6884c0ca Iustin Pop
support this. It's therefore recommended to implement host-level
108 888891c7 Michael Hanselmann
firewalling or to use a separate range of IP addresses for the DRBD
109 3397d13e Michael Hanselmann
traffic (this is supported in Ganeti through the use of a secondary
110 3397d13e Michael Hanselmann
interface) which is not routed outside the cluster. DRBD connections are
111 3397d13e Michael Hanselmann
protected from erroneous connections to other machines (as may happen
112 3397d13e Michael Hanselmann
due to software issues), and from accepting connections from other
113 3397d13e Michael Hanselmann
machines, by using a shared secret, exchanged via RPC requests from the
114 3397d13e Michael Hanselmann
master to the nodes when configuring the device.
115 6884c0ca Iustin Pop
116 6884c0ca Iustin Pop
Master daemon
117 6884c0ca Iustin Pop
-------------
118 6884c0ca Iustin Pop
119 3397d13e Michael Hanselmann
The command-line tools to master daemon communication is done via a
120 3397d13e Michael Hanselmann
UNIX socket, whose permissions are reset to ``0660`` after listening but
121 7faf5110 Michael Hanselmann
before serving requests. This permission-based protection is documented
122 7faf5110 Michael Hanselmann
and works on Linux, but is not-portable; however, Ganeti doesn't work on
123 7faf5110 Michael Hanselmann
non-Linux system at the moment.
124 4fbe765c Michael Hanselmann
125 d70571bb Iustin Pop
Conf daemon
126 d70571bb Iustin Pop
-----------
127 d70571bb Iustin Pop
128 d70571bb Iustin Pop
In Ganeti 2.7, the ``confd`` daemon (if enabled at build time), serves
129 d70571bb Iustin Pop
both network-originated queries (about the static configuration) and
130 d70571bb Iustin Pop
local (UNIX socket) queries (about the run-time configuration; answering
131 d70571bb Iustin Pop
these means talking to other cluster nodes, which makes use of the
132 d70571bb Iustin Pop
internal RPC SSL certificate). This makes it a bit more sensitive to
133 d70571bb Iustin Pop
bugs (a remote attacker could get direct access to the intra-cluster
134 d70571bb Iustin Pop
RPC), so to harden security it's recommended to:
135 d70571bb Iustin Pop
136 d70571bb Iustin Pop
- disable confd at build time if it's not needed in your setup
137 d70571bb Iustin Pop
- otherwise, configure Ganeti (at build time) to use separate users, so
138 d70571bb Iustin Pop
  that the confd daemon doesn't also have access to the server SSL/TLS
139 d70571bb Iustin Pop
  certificates
140 d70571bb Iustin Pop
141 d70571bb Iustin Pop
It is planned to split the two functionalities (local/remote querying)
142 d70571bb Iustin Pop
of confd into two separate daemons in a future Ganeti version.
143 d70571bb Iustin Pop
144 4fbe765c Michael Hanselmann
Remote API
145 4fbe765c Michael Hanselmann
----------
146 4fbe765c Michael Hanselmann
147 7faf5110 Michael Hanselmann
Starting with Ganeti 2.0, Remote API traffic is encrypted using SSL/TLS
148 f1d243bd Michael Hanselmann
by default. It supports Basic authentication as per :rfc:`2617`. Users
149 f1d243bd Michael Hanselmann
can be granted different capabilities. Details can be found in the
150 f1d243bd Michael Hanselmann
:ref:`RAPI documentation <rapi-users>`.
151 4fbe765c Michael Hanselmann
152 7faf5110 Michael Hanselmann
Paths for certificate, private key and CA files required for SSL/TLS
153 7faf5110 Michael Hanselmann
will be set at source configure time. Symlinks or command line
154 7faf5110 Michael Hanselmann
parameters may be used to use different files.
155 558fd122 Michael Hanselmann
156 5b2069a9 Michael Hanselmann
Inter-cluster instance moves
157 5b2069a9 Michael Hanselmann
----------------------------
158 5b2069a9 Michael Hanselmann
159 5b2069a9 Michael Hanselmann
To move instances between clusters, different clusters must be able to
160 5b2069a9 Michael Hanselmann
communicate with each other over a secure channel. Up to and including
161 5b2069a9 Michael Hanselmann
Ganeti 2.1, clusters were self-contained entities and had no knowledge
162 5b2069a9 Michael Hanselmann
of other clusters. With Ganeti 2.2, clusters can exchange data if tokens
163 5b2069a9 Michael Hanselmann
(an encryption certificate) was exchanged by a trusted third party
164 5b2069a9 Michael Hanselmann
before.
165 5b2069a9 Michael Hanselmann
166 4e9dcb8a Guido Trotter
KVM Security
167 4e9dcb8a Guido Trotter
------------
168 4e9dcb8a Guido Trotter
169 4e9dcb8a Guido Trotter
When running KVM instances under Ganeti three security models ara
170 3397d13e Michael Hanselmann
available: "none", "user" and "pool".
171 4e9dcb8a Guido Trotter
172 3397d13e Michael Hanselmann
Under security model "none" instances run by default as root. This means
173 4e9dcb8a Guido Trotter
that, if an instance gets jail broken, it will be able to own the host
174 4e9dcb8a Guido Trotter
node, and thus the ganeti cluster. This is the default model, and the
175 4e9dcb8a Guido Trotter
only one available before Ganeti 2.1.2.
176 4e9dcb8a Guido Trotter
177 3397d13e Michael Hanselmann
Under security model "user" an instance is run as the user specified by
178 3397d13e Michael Hanselmann
the hypervisor parameter "security_domain". This makes it easy to run
179 f7b769b1 Iustin Pop
all instances as non privileged users, and allows one to manually
180 f7b769b1 Iustin Pop
allocate specific users to specific instances or sets of instances. If
181 f7b769b1 Iustin Pop
the specified user doesn't have permissions a jail broken instance will
182 f7b769b1 Iustin Pop
need some local privilege escalation before being able to take over the
183 f7b769b1 Iustin Pop
node and the cluster. It's possible though for a jail broken instance to
184 4e9dcb8a Guido Trotter
affect other ones running under the same user.
185 4e9dcb8a Guido Trotter
186 3397d13e Michael Hanselmann
Under security model "pool" a global cluster-level uid pool is used to
187 4e9dcb8a Guido Trotter
start each instance on the same node under a different user. The uids in
188 4e9dcb8a Guido Trotter
the cluster pool can be set with ``gnt-cluster init`` and ``gnt-cluster
189 4e9dcb8a Guido Trotter
modify``, and must correspond to existing users on all nodes. Ganeti
190 4e9dcb8a Guido Trotter
will then allocate one to each instance, as needed. This way a jail
191 4e9dcb8a Guido Trotter
broken instance won't be able to affect any other. Since the users are
192 4e9dcb8a Guido Trotter
handed out by ganeti in a per-node randomized way, in this mode there is
193 4e9dcb8a Guido Trotter
no way to make sure a particular instance is always run as a certain
194 3397d13e Michael Hanselmann
user. Use mode "user" for that.
195 4e9dcb8a Guido Trotter
196 4e9dcb8a Guido Trotter
In addition to these precautions, if you want to avoid instances sending
197 4e9dcb8a Guido Trotter
traffic on your node network, you can use an iptables rule such as::
198 4e9dcb8a Guido Trotter
199 4e9dcb8a Guido Trotter
  iptables -A OUTPUT -m owner --uid-owner <uid>[-<uid>] -j LOG \
200 4e9dcb8a Guido Trotter
    --log-prefix "ganeti uid pool user network traffic"
201 4e9dcb8a Guido Trotter
  iptables -A OUTPUT -m owner --uid-owner <uid>[-<uid>] -j DROP
202 4e9dcb8a Guido Trotter
203 4e9dcb8a Guido Trotter
This won't affect regular instance traffic (that comes out of the tapX
204 4e9dcb8a Guido Trotter
allocated to the instance, and can be filtered or subject to appropriate
205 4e9dcb8a Guido Trotter
policy routes) but will stop any user generated traffic that might come
206 4e9dcb8a Guido Trotter
from a jailbroken instance.
207 4e9dcb8a Guido Trotter
208 558fd122 Michael Hanselmann
.. vim: set textwidth=72 :
209 c71a1a3d Iustin Pop
.. Local Variables:
210 c71a1a3d Iustin Pop
.. mode: rst
211 c71a1a3d Iustin Pop
.. fill-column: 72
212 c71a1a3d Iustin Pop
.. End: