]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: validate VNC password length
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 16 Dec 2021 10:20:37 +0000 (10:20 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 16 Dec 2021 18:02:18 +0000 (18:02 +0000)
The VNC password authentication scheme is quite horrendous in that it
takes the user password and directly uses it as a DES case. DES is a
byte 8 keyed cipher, so the VNC password can never be more than 8
characters long. Anything over that length will be silently dropped.

We should validate this length restriction when accepting user XML
configs and report an error. For the global VNC password we don't
really want to break daemon startup by reporting an error, but
logging a warning is worthwhile.

https://bugzilla.redhat.com/show_bug.cgi?id=1506689

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_conf.c
src/qemu/qemu_validate.c

index 7eb04e66a0c80eb36cb7791fbbe0d4d2478f7b94..6077457ff4a8cde444750da595df4dc02b98f41e 100644 (file)
@@ -451,6 +451,12 @@ virQEMUDriverConfigLoadVNCEntry(virQEMUDriverConfig *cfg,
     if (virConfGetValueBool(conf, "vnc_allow_host_audio", &cfg->vncAllowHostAudio) < 0)
         return -1;
 
+    if (cfg->vncPassword &&
+        strlen(cfg->vncPassword) > 8) {
+        VIR_WARN("VNC password is %zu characters long, only 8 permitted, truncating",
+                 strlen(cfg->vncPassword));
+        cfg->vncPassword[8] = '\0';
+    }
     return 0;
 }
 
index f9a195e99133d42a44c57dc772785738b8d1f52c..46b40303f6af6fe1c969edadf1ef759a7cd8e0ad 100644 (file)
@@ -4109,6 +4109,14 @@ qemuValidateDomainDeviceDefVNCGraphics(const virDomainGraphicsDef *graphics,
         return -1;
     }
 
+    if (graphics->data.vnc.auth.passwd &&
+        strlen(graphics->data.vnc.auth.passwd) > 8) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("VNC password is %zu characters long, only 8 permitted"),
+                       strlen(graphics->data.vnc.auth.passwd));
+        return -1;
+    }
+
     return 0;
 }