Statistics
| Branch: | Tag: | Revision:

root / doc / security.rst @ 3798b89a

History | View | Annotate | Download (9.9 kB)

1 28cc354f Iustin Pop
Security in Ganeti
2 6884c0ca Iustin Pop
==================
3 28cc354f Iustin Pop
4 dad226e3 Thomas Thrainer
Documents Ganeti version 2.9
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 0a689f79 Michele Tartara
possible to run all daemons except the node daemon and the monitoring daemon
11 0a689f79 Michele Tartara
as non-root users by specifying user names and groups at build time.
12 0a689f79 Michele Tartara
The node daemon continues to require root privileges to create logical volumes,
13 0a689f79 Michele Tartara
DRBD devices, start instances, etc. Cluster commands can be run as root or by
14 0a689f79 Michele Tartara
users in a group specified at build time. The monitoring daemon requires root
15 0a689f79 Michele Tartara
privileges in order to be able to access and present information that are only
16 0a689f79 Michele Tartara
avilable to root (such as the output of the ``xm`` command of Xen).
17 28cc354f Iustin Pop
18 28cc354f Iustin Pop
Host issues
19 28cc354f Iustin Pop
-----------
20 28cc354f Iustin Pop
21 7faf5110 Michael Hanselmann
For a host on which the Ganeti software has been installed, but not
22 7faf5110 Michael Hanselmann
joined to a cluster, there are no changes to the system.
23 28cc354f Iustin Pop
24 28cc354f Iustin Pop
For a host that has been joined to the cluster, there are very important
25 28cc354f Iustin Pop
changes:
26 6884c0ca Iustin Pop
27 6884c0ca Iustin Pop
- The host will have its SSH host key replaced with the one of the
28 6884c0ca Iustin Pop
  cluster (which is the one the initial node had at the cluster
29 6884c0ca Iustin Pop
  creation)
30 3397d13e Michael Hanselmann
- A new public key will be added to root's ``authorized_keys`` file,
31 6884c0ca Iustin Pop
  granting root access to all nodes of the cluster. The private part of
32 6884c0ca Iustin Pop
  the key is also distributed to all nodes. Old files are renamed.
33 6884c0ca Iustin Pop
- Communication between nodes is encrypted using SSL/TLS. A common key
34 6884c0ca Iustin Pop
  and certificate combo is shared between all nodes of the cluster.  At
35 6884c0ca Iustin Pop
  this time, no CA is used.
36 6884c0ca Iustin Pop
- The Ganeti node daemon will accept RPC requests from any host within
37 6884c0ca Iustin Pop
  the cluster with the correct certificate, and the operations it will
38 6884c0ca Iustin Pop
  do as a result of these requests are:
39 6884c0ca Iustin Pop
40 3397d13e Michael Hanselmann
  - running commands under the ``/etc/ganeti/hooks`` directory
41 6884c0ca Iustin Pop
  - creating DRBD disks between it and the IP it has been told
42 6884c0ca Iustin Pop
  - overwrite a defined list of files on the host
43 28cc354f Iustin Pop
44 28cc354f Iustin Pop
As you can see, as soon as a node is joined, it becomes equal to all
45 28cc354f Iustin Pop
other nodes in the cluster, and the security of the cluster is
46 28cc354f Iustin Pop
determined by the weakest node.
47 28cc354f Iustin Pop
48 3397d13e Michael Hanselmann
Note that only the SSH key will allow other machines to run any command
49 3397d13e Michael Hanselmann
on this node; the RPC method will run only:
50 6884c0ca Iustin Pop
51 6884c0ca Iustin Pop
- well defined commands to create, remove, activate logical volumes,
52 6884c0ca Iustin Pop
  drbd devices, start/stop instances, etc;
53 3397d13e Michael Hanselmann
- run well-defined SSH commands on other nodes in the cluster
54 3397d13e Michael Hanselmann
- scripts under the ``/etc/ganeti/hooks`` directory
55 d70571bb Iustin Pop
- scripts under the ``/etc/ganeti/restricted-commands`` directory, if
56 d70571bb Iustin Pop
  this feature has been enabled at build time (see below)
57 28cc354f Iustin Pop
58 28cc354f Iustin Pop
It is therefore important to make sure that the contents of the
59 d70571bb Iustin Pop
``/etc/ganeti/hooks`` and ``/etc/ganeti/restricted-commands``
60 d70571bb Iustin Pop
directories are supervised and only trusted sources can populate them.
61 d70571bb Iustin Pop
62 d70571bb Iustin Pop
Restricted commands
63 d70571bb Iustin Pop
~~~~~~~~~~~~~~~~~~~
64 d70571bb Iustin Pop
65 d70571bb Iustin Pop
The restricted commands feature is new in Ganeti 2.7. It enables the
66 d70571bb Iustin Pop
administrator to run any commands in the
67 d70571bb Iustin Pop
``/etc/ganeti/restricted-commands`` directory, if the feature has been
68 d70571bb Iustin Pop
enabled at build time, subject to the following restrictions:
69 d70571bb Iustin Pop
70 d70571bb Iustin Pop
- No parameters may be passed
71 d70571bb Iustin Pop
- No absolute or relative path may be passed, only a filename
72 d70571bb Iustin Pop
- The ``/etc/ganeti/restricted-commands`` directory must
73 d70571bb Iustin Pop
  be owned by root:root and have mode 0755 or stricter
74 d70571bb Iustin Pop
- Executables must be regular files or symlinks, and must be executable
75 d70571bb Iustin Pop
  by root:root
76 d70571bb Iustin Pop
77 d70571bb Iustin Pop
Note that it's not possible to list the contents of the directory, and
78 d70571bb Iustin Pop
there is an intentional delay when trying to execute a non-existing
79 d70571bb Iustin Pop
command (to slow-down dictionary attacks).
80 d70571bb Iustin Pop
81 d70571bb Iustin Pop
Since for Ganeti itself this functionality is not needed, and is only
82 d70571bb Iustin Pop
provided as a way to help administrate or recover nodes, it is a local
83 d70571bb Iustin Pop
site decision whether to enable or not the restricted commands feature.
84 d70571bb Iustin Pop
85 d70571bb Iustin Pop
By default, this feature is disabled.
86 d70571bb Iustin Pop
87 28cc354f Iustin Pop
88 28cc354f Iustin Pop
Cluster issues
89 28cc354f Iustin Pop
--------------
90 28cc354f Iustin Pop
91 3397d13e Michael Hanselmann
As mentioned above, there are multiple ways of communication between
92 3397d13e Michael Hanselmann
cluster nodes:
93 6884c0ca Iustin Pop
94 6884c0ca Iustin Pop
- SSH-based, for high-volume traffic like image dumps or for low-level
95 6884c0ca Iustin Pop
  command, e.g. restarting the Ganeti node daemon
96 6884c0ca Iustin Pop
- RPC communication between master and nodes
97 6884c0ca Iustin Pop
- DRBD real-time disk replication traffic
98 28cc354f Iustin Pop
99 4fbe765c Michael Hanselmann
The SSH traffic is protected (after the initial login to a new node) by
100 4fbe765c Michael Hanselmann
the cluster-wide shared SSH key.
101 28cc354f Iustin Pop
102 7faf5110 Michael Hanselmann
RPC communication between the master and nodes is protected using
103 7faf5110 Michael Hanselmann
SSL/TLS encryption. Both the client and the server must have the
104 7faf5110 Michael Hanselmann
cluster-wide shared SSL/TLS certificate and verify it when establishing
105 7faf5110 Michael Hanselmann
the connection by comparing fingerprints. We decided not to use a CA to
106 7faf5110 Michael Hanselmann
simplify the key handling.
107 28cc354f Iustin Pop
108 6884c0ca Iustin Pop
The DRBD traffic is not protected by encryption, as DRBD does not
109 6884c0ca Iustin Pop
support this. It's therefore recommended to implement host-level
110 888891c7 Michael Hanselmann
firewalling or to use a separate range of IP addresses for the DRBD
111 3397d13e Michael Hanselmann
traffic (this is supported in Ganeti through the use of a secondary
112 3397d13e Michael Hanselmann
interface) which is not routed outside the cluster. DRBD connections are
113 3397d13e Michael Hanselmann
protected from erroneous connections to other machines (as may happen
114 3397d13e Michael Hanselmann
due to software issues), and from accepting connections from other
115 3397d13e Michael Hanselmann
machines, by using a shared secret, exchanged via RPC requests from the
116 3397d13e Michael Hanselmann
master to the nodes when configuring the device.
117 6884c0ca Iustin Pop
118 6884c0ca Iustin Pop
Master daemon
119 6884c0ca Iustin Pop
-------------
120 6884c0ca Iustin Pop
121 3397d13e Michael Hanselmann
The command-line tools to master daemon communication is done via a
122 3397d13e Michael Hanselmann
UNIX socket, whose permissions are reset to ``0660`` after listening but
123 7faf5110 Michael Hanselmann
before serving requests. This permission-based protection is documented
124 7faf5110 Michael Hanselmann
and works on Linux, but is not-portable; however, Ganeti doesn't work on
125 7faf5110 Michael Hanselmann
non-Linux system at the moment.
126 4fbe765c Michael Hanselmann
127 d70571bb Iustin Pop
Conf daemon
128 d70571bb Iustin Pop
-----------
129 d70571bb Iustin Pop
130 cd30f3e6 Michele Tartara
In Ganeti 2.8, the ``confd`` daemon (if enabled at build time), serves
131 d70571bb Iustin Pop
both network-originated queries (about the static configuration) and
132 d70571bb Iustin Pop
local (UNIX socket) queries (about the run-time configuration; answering
133 d70571bb Iustin Pop
these means talking to other cluster nodes, which makes use of the
134 d70571bb Iustin Pop
internal RPC SSL certificate). This makes it a bit more sensitive to
135 d70571bb Iustin Pop
bugs (a remote attacker could get direct access to the intra-cluster
136 d70571bb Iustin Pop
RPC), so to harden security it's recommended to:
137 d70571bb Iustin Pop
138 d70571bb Iustin Pop
- disable confd at build time if it's not needed in your setup
139 d70571bb Iustin Pop
- otherwise, configure Ganeti (at build time) to use separate users, so
140 d70571bb Iustin Pop
  that the confd daemon doesn't also have access to the server SSL/TLS
141 cd30f3e6 Michele Tartara
  certificates.
142 d70571bb Iustin Pop
143 cd30f3e6 Michele Tartara
NB: the second suggestion is not valid since Ganeti 2.8.0~beta1, because confd
144 cd30f3e6 Michele Tartara
needs access to the certificate in order to communicate on the network.
145 cd30f3e6 Michele Tartara
This will be fixed when the planned split of the two functionalities
146 cd30f3e6 Michele Tartara
(local/remote querying) of confd into two separate daemons will take place,
147 cd30f3e6 Michele Tartara
in a future Ganeti version.
148 d70571bb Iustin Pop
149 0a689f79 Michele Tartara
Monitoring daemon
150 0a689f79 Michele Tartara
-----------------
151 0a689f79 Michele Tartara
152 0a689f79 Michele Tartara
The monitoring daemon provides information about the status and the
153 0a689f79 Michele Tartara
performance of the cluster over HTTP.
154 0a689f79 Michele Tartara
It is currently unencrypted and non-authenticated, therefore it is strongly
155 0a689f79 Michele Tartara
advised to set proper firewalling rules to prevent unwanted access.
156 0a689f79 Michele Tartara
157 0a689f79 Michele Tartara
The monitoring daemon runs as root, because it needs to be able to access
158 0a689f79 Michele Tartara
privileged information (such as the state of the instances as provided by
159 0a689f79 Michele Tartara
the Xen hypervisor). Nevertheless, the security implications are mitigated
160 0a689f79 Michele Tartara
by the fact that the agent only provides reporting functionalities,
161 0a689f79 Michele Tartara
without the ability to actually modify the state of the cluster.
162 0a689f79 Michele Tartara
163 4fbe765c Michael Hanselmann
Remote API
164 4fbe765c Michael Hanselmann
----------
165 4fbe765c Michael Hanselmann
166 7faf5110 Michael Hanselmann
Starting with Ganeti 2.0, Remote API traffic is encrypted using SSL/TLS
167 f1d243bd Michael Hanselmann
by default. It supports Basic authentication as per :rfc:`2617`. Users
168 f1d243bd Michael Hanselmann
can be granted different capabilities. Details can be found in the
169 f1d243bd Michael Hanselmann
:ref:`RAPI documentation <rapi-users>`.
170 4fbe765c Michael Hanselmann
171 7faf5110 Michael Hanselmann
Paths for certificate, private key and CA files required for SSL/TLS
172 7faf5110 Michael Hanselmann
will be set at source configure time. Symlinks or command line
173 7faf5110 Michael Hanselmann
parameters may be used to use different files.
174 558fd122 Michael Hanselmann
175 5b2069a9 Michael Hanselmann
Inter-cluster instance moves
176 5b2069a9 Michael Hanselmann
----------------------------
177 5b2069a9 Michael Hanselmann
178 5b2069a9 Michael Hanselmann
To move instances between clusters, different clusters must be able to
179 5b2069a9 Michael Hanselmann
communicate with each other over a secure channel. Up to and including
180 5b2069a9 Michael Hanselmann
Ganeti 2.1, clusters were self-contained entities and had no knowledge
181 5b2069a9 Michael Hanselmann
of other clusters. With Ganeti 2.2, clusters can exchange data if tokens
182 5b2069a9 Michael Hanselmann
(an encryption certificate) was exchanged by a trusted third party
183 5b2069a9 Michael Hanselmann
before.
184 5b2069a9 Michael Hanselmann
185 4e9dcb8a Guido Trotter
KVM Security
186 4e9dcb8a Guido Trotter
------------
187 4e9dcb8a Guido Trotter
188 4e9dcb8a Guido Trotter
When running KVM instances under Ganeti three security models ara
189 3397d13e Michael Hanselmann
available: "none", "user" and "pool".
190 4e9dcb8a Guido Trotter
191 3397d13e Michael Hanselmann
Under security model "none" instances run by default as root. This means
192 4e9dcb8a Guido Trotter
that, if an instance gets jail broken, it will be able to own the host
193 4e9dcb8a Guido Trotter
node, and thus the ganeti cluster. This is the default model, and the
194 4e9dcb8a Guido Trotter
only one available before Ganeti 2.1.2.
195 4e9dcb8a Guido Trotter
196 3397d13e Michael Hanselmann
Under security model "user" an instance is run as the user specified by
197 3397d13e Michael Hanselmann
the hypervisor parameter "security_domain". This makes it easy to run
198 f7b769b1 Iustin Pop
all instances as non privileged users, and allows one to manually
199 f7b769b1 Iustin Pop
allocate specific users to specific instances or sets of instances. If
200 f7b769b1 Iustin Pop
the specified user doesn't have permissions a jail broken instance will
201 f7b769b1 Iustin Pop
need some local privilege escalation before being able to take over the
202 f7b769b1 Iustin Pop
node and the cluster. It's possible though for a jail broken instance to
203 4e9dcb8a Guido Trotter
affect other ones running under the same user.
204 4e9dcb8a Guido Trotter
205 3397d13e Michael Hanselmann
Under security model "pool" a global cluster-level uid pool is used to
206 4e9dcb8a Guido Trotter
start each instance on the same node under a different user. The uids in
207 4e9dcb8a Guido Trotter
the cluster pool can be set with ``gnt-cluster init`` and ``gnt-cluster
208 4e9dcb8a Guido Trotter
modify``, and must correspond to existing users on all nodes. Ganeti
209 4e9dcb8a Guido Trotter
will then allocate one to each instance, as needed. This way a jail
210 4e9dcb8a Guido Trotter
broken instance won't be able to affect any other. Since the users are
211 4e9dcb8a Guido Trotter
handed out by ganeti in a per-node randomized way, in this mode there is
212 4e9dcb8a Guido Trotter
no way to make sure a particular instance is always run as a certain
213 3397d13e Michael Hanselmann
user. Use mode "user" for that.
214 4e9dcb8a Guido Trotter
215 4e9dcb8a Guido Trotter
In addition to these precautions, if you want to avoid instances sending
216 4e9dcb8a Guido Trotter
traffic on your node network, you can use an iptables rule such as::
217 4e9dcb8a Guido Trotter
218 4e9dcb8a Guido Trotter
  iptables -A OUTPUT -m owner --uid-owner <uid>[-<uid>] -j LOG \
219 4e9dcb8a Guido Trotter
    --log-prefix "ganeti uid pool user network traffic"
220 4e9dcb8a Guido Trotter
  iptables -A OUTPUT -m owner --uid-owner <uid>[-<uid>] -j DROP
221 4e9dcb8a Guido Trotter
222 4e9dcb8a Guido Trotter
This won't affect regular instance traffic (that comes out of the tapX
223 4e9dcb8a Guido Trotter
allocated to the instance, and can be filtered or subject to appropriate
224 4e9dcb8a Guido Trotter
policy routes) but will stop any user generated traffic that might come
225 4e9dcb8a Guido Trotter
from a jailbroken instance.
226 4e9dcb8a Guido Trotter
227 558fd122 Michael Hanselmann
.. vim: set textwidth=72 :
228 c71a1a3d Iustin Pop
.. Local Variables:
229 c71a1a3d Iustin Pop
.. mode: rst
230 c71a1a3d Iustin Pop
.. fill-column: 72
231 c71a1a3d Iustin Pop
.. End: