all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server] remote migration: fix online migration via API clients
Date: Fri,  9 Aug 2024 12:17:12 +0200	[thread overview]
Message-ID: <20240809101712.37212-1-f.ebner@proxmox.com> (raw)

As reported in the community forum [0], when a remote migration
request comes in via an API client, the -T flag for Perl is set, so an
insecure dependency in a call like unlink() in forward_unix_socket()
will fail with:

> failed to write forwarding command - Insecure dependency in unlink while running with -T switch

To fix it, untaint the problematic socket addresses coming from the
remote side. Require that all sockets are below '/run/qemu-server/'
and end with '.migrate'. This allows extensions in the future while
still being quite strict.

[0]: https://forum.proxmox.com/threads/123048/post-691958

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

There is no direct call to forward_unix_socket() in pve-container and
the call in PVE::StorageTunnel::storage_migrate() has no insecure
dependency for the local socket path.

 PVE/QemuMigrate.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index e71face4..7a7183e0 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -1095,7 +1095,8 @@ sub phase2 {
 	die "only UNIX sockets are supported for remote migration\n"
 	    if $tunnel_info->{proto} ne 'unix';
 
-	my $remote_socket = $tunnel_info->{addr};
+	my ($remote_socket) = $tunnel_info->{addr} =~ m!^(/run/qemu-server/.*\.migrate)$! #untaint
+	    or die "unexpected socket address '$tunnel_info->{addr}'\n";
 	my $local_socket = $remote_socket;
 	$local_socket =~ s/$remote_vmid/$vmid/g;
 	$tunnel_info->{addr} = $local_socket;
@@ -1104,6 +1105,8 @@ sub phase2 {
 	PVE::Tunnel::forward_unix_socket($self->{tunnel}, $local_socket, $remote_socket);
 
 	foreach my $remote_socket (@{$tunnel_info->{unix_sockets}}) {
+	    ($remote_socket) = $remote_socket =~ m!^(/run/qemu-server/.*\.migrate)$! # untaint
+		or die "unexpected socket address '$remote_socket'\n";
 	    my $local_socket = $remote_socket;
 	    $local_socket =~ s/$remote_vmid/$vmid/g;
 	    next if $self->{tunnel}->{forwarded}->{$local_socket};
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


             reply	other threads:[~2024-08-09 10:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09 10:17 Fiona Ebner [this message]
2024-08-13  8:47 ` Fiona Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240809101712.37212-1-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal