Blame SOURCES/libvirt-api-disallow-virDomainSaveImageGetXMLDesc-on-read-only-connections.patch

99cbc7
From 2e532b74b3100a06e0f1ba21f657883fe5aafcc5 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <2e532b74b3100a06e0f1ba21f657883fe5aafcc5@dist-git>
99cbc7
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
99cbc7
Date: Tue, 18 Jun 2019 13:29:59 +0200
99cbc7
Subject: [PATCH] api: disallow virDomainSaveImageGetXMLDesc on read-only
99cbc7
 connections
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
The virDomainSaveImageGetXMLDesc API is taking a path parameter,
99cbc7
which can point to any path on the system. This file will then be
99cbc7
read and parsed by libvirtd running with root privileges.
99cbc7
99cbc7
Forbid it on read-only connections.
99cbc7
99cbc7
Fixes: CVE-2019-10161
99cbc7
Reported-by: Matthias Gerstner <mgerstner@suse.de>
99cbc7
Signed-off-by: Ján Tomko <jtomko@redhat.com>
99cbc7
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
99cbc7
Signed-off-by: Ján Tomko <jtomko@redhat.com>
99cbc7
99cbc7
Conflicts:
99cbc7
  src/libvirt-domain.c
99cbc7
  src/remote/remote_protocol.x
99cbc7
99cbc7
Upstream commit 12a51f372 which introduced the VIR_DOMAIN_SAVE_IMAGE_XML_SECURE
99cbc7
alias for VIR_DOMAIN_XML_SECURE is not backported.
99cbc7
Just skip the commit since we now disallow the whole API on read-only
99cbc7
connections, regardless of the flag.
99cbc7
Message-Id: <4c14d609cd7b548459b9ef2f59728fa5c5e38268.1560857354.git.jtomko@redhat.com>
99cbc7
99cbc7
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
---
99cbc7
 src/libvirt-domain.c         | 11 ++---------
99cbc7
 src/qemu/qemu_driver.c       |  2 +-
99cbc7
 src/remote/remote_protocol.x |  3 +--
99cbc7
 3 files changed, 4 insertions(+), 12 deletions(-)
99cbc7
99cbc7
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
99cbc7
index 568023176b..697326ae9a 100644
99cbc7
--- a/src/libvirt-domain.c
99cbc7
+++ b/src/libvirt-domain.c
99cbc7
@@ -1073,9 +1073,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,
99cbc7
  * previously by virDomainSave() or virDomainSaveFlags().
99cbc7
  *
99cbc7
  * No security-sensitive data will be included unless @flags contains
99cbc7
- * VIR_DOMAIN_XML_SECURE; this flag is rejected on read-only
99cbc7
- * connections.  For this API, @flags should not contain either
99cbc7
- * VIR_DOMAIN_XML_INACTIVE or VIR_DOMAIN_XML_UPDATE_CPU.
99cbc7
+ * VIR_DOMAIN_XML_SECURE.
99cbc7
  *
99cbc7
  * Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of
99cbc7
  * error.  The caller must free() the returned value.
99cbc7
@@ -1091,12 +1089,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
99cbc7
 
99cbc7
     virCheckConnectReturn(conn, NULL);
99cbc7
     virCheckNonNullArgGoto(file, error);
99cbc7
-
99cbc7
-    if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
99cbc7
-        virReportError(VIR_ERR_OPERATION_DENIED, "%s",
99cbc7
-                       _("virDomainSaveImageGetXMLDesc with secure flag"));
99cbc7
-        goto error;
99cbc7
-    }
99cbc7
+    virCheckReadOnlyGoto(conn->flags, error);
99cbc7
 
99cbc7
     if (conn->driver->domainSaveImageGetXMLDesc) {
99cbc7
         char *ret;
99cbc7
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
99cbc7
index 704ba24215..25818f5d8c 100644
99cbc7
--- a/src/qemu/qemu_driver.c
99cbc7
+++ b/src/qemu/qemu_driver.c
99cbc7
@@ -6784,7 +6784,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
99cbc7
     if (fd < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
-    if (virDomainSaveImageGetXMLDescEnsureACL(conn, def, flags) < 0)
99cbc7
+    if (virDomainSaveImageGetXMLDescEnsureACL(conn, def) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
     ret = qemuDomainDefFormatXML(driver, def, flags);
99cbc7
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
99cbc7
index 28c8febabd..52b92334fa 100644
99cbc7
--- a/src/remote/remote_protocol.x
99cbc7
+++ b/src/remote/remote_protocol.x
99cbc7
@@ -5226,8 +5226,7 @@ enum remote_procedure {
99cbc7
     /**
99cbc7
      * @generate: both
99cbc7
      * @priority: high
99cbc7
-     * @acl: domain:read
99cbc7
-     * @acl: domain:read_secure:VIR_DOMAIN_XML_SECURE
99cbc7
+     * @acl: domain:write
99cbc7
      */
99cbc7
     REMOTE_PROC_DOMAIN_SAVE_IMAGE_GET_XML_DESC = 235,
99cbc7
 
99cbc7
-- 
99cbc7
2.22.0
99cbc7