tools/ocaml/xenstored: do permission checks on xenstore root
authorEdwin Török <edvin.torok@citrix.com>
Tue, 15 Dec 2020 13:05:16 +0000 (14:05 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 15 Dec 2020 13:05:16 +0000 (14:05 +0100)
commitf130d5f013b205d1b15fa8395e473e422cb51945
tree3695f88c078ac0fc8614088254c61f04590b84d9
parent1d1d1f5391976456a79daac0dcfe7157da1e54f7
tools/ocaml/xenstored: do permission checks on xenstore root

This was lacking in a disappointing number of places.

The xenstore root node is treated differently from all other nodes, because it
doesn't have a parent, and mutation requires changing the parent.

Unfortunately this lead to open-coding the special case for root into every
single xenstore operation, and out of all the xenstore operations only read
did a permission check when handling the root node.

This means that an unprivileged guest can:

 * xenstore-chmod / to its liking and subsequently write new arbitrary nodes
   there (subject to quota)
 * xenstore-rm -r / deletes almost the entire xenstore tree (xenopsd quickly
   refills some, but you are left with a broken system)
 * DIRECTORY on / lists all children when called through python
   bindings (xenstore-ls stops at /local because it tries to list recursively)
 * get-perms on / works too, but that is just a minor information leak

Add the missing permission checks, but this should really be refactored to do
the root handling and permission checks on the node only once from a single
function, instead of getting it wrong nearly everywhere.

This is XSA-353.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/ocaml/xenstored/store.ml