]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: snapshot: Set umask for 'qemu-img' when creating external inactive snapshots CVE-2025-13193
authorPeter Krempa <pkrempa@redhat.com>
Wed, 12 Nov 2025 16:52:05 +0000 (17:52 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 13 Nov 2025 07:31:39 +0000 (08:31 +0100)
External inactive snapshots are created by invoking 'qemu-img' which
creates the file. Currently qemu-img creates image with mode 644 based
on default umask as libvirt doesn't set any.

Having a world-readable image is obviously wrong so set the umask to
077 to have the file readable only by the owner.

Resolves: https://bugs.debian.org/1120119
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_snapshot.c

index 5aa7d1b3a79d5dbe0811f2b4d7961878fc1171e9..302775af926f38d05918aa8caea8c1424d5e40bf 100644 (file)
@@ -228,6 +228,9 @@ qemuSnapshotCreateQcow2Files(virDomainDef *def,
                                          NULL)))
             return -1;
 
+        /* ensure that new files are only readable by the user */
+        virCommandSetUmask(cmd, 0077);
+
         /* adds cmd line arg: backing_fmt=format,backing_file=/path/to/backing/file */
         virBufferAsprintf(&buf, "backing_fmt=%s,backing_file=",
                           virStorageFileFormatTypeToString(defdisk->src->format));