From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C07996D169 for ; Wed, 31 Mar 2021 16:18:19 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B8A8110C24 for ; Wed, 31 Mar 2021 16:18:19 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 4975B10C1A for ; Wed, 31 Mar 2021 16:18:19 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0C965434A5 for ; Wed, 31 Mar 2021 16:18:19 +0200 (CEST) Date: Wed, 31 Mar 2021 16:15:30 +0200 From: Oguz Bektas To: Proxmox Backup Server development discussion Message-ID: <20210331141530.GB12845@gaia.proxmox.com> References: <20210331102202.14767-1-s.reiter@proxmox.com> <20210331102202.14767-15-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210331102202.14767-15-s.reiter@proxmox.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-SPAM-LEVEL: Spam detection results: 0 AWL 1.073 Adjusted score from AWL reputation of From: address KAM_ASCII_DIVIDERS 0.8 Spam that uses ascii formatting tricks KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox-restore-qemu-helper.rs] Subject: Re: [pbs-devel] [PATCH v3 proxmox-backup 14/20] file-restore: add qemu-helper setuid binary X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Mar 2021 14:18:19 -0000 hi, On Wed, Mar 31, 2021 at 12:21:56PM +0200, Stefan Reiter wrote: > + // Try starting QEMU in a loop to retry if we fail because of a bad 'cid' value > + let mut attempts = 0; > + loop { > + let mut qemu_cmd = std::process::Command::new("qemu-system-x86_64"); > + qemu_cmd.args(base_args.iter()); is vulnerable to path confusion, since setuid helper can be called directly by unprivileged user. please add this: ================================================== diff --git a/src/bin/proxmox-restore-qemu-helper.rs b/src/bin/proxmox-restore-qemu-helper.rs index f56a6607..ad707d69 100644 --- a/src/bin/proxmox-restore-qemu-helper.rs +++ b/src/bin/proxmox-restore-qemu-helper.rs @@ -212,6 +212,7 @@ async fn start_vm( // Try starting QEMU in a loop to retry if we fail because of a bad 'cid' value let mut attempts = 0; + loop { let mut qemu_cmd = std::process::Command::new("qemu-system-x86_64"); qemu_cmd.args(base_args.iter()); @@ -349,6 +350,7 @@ async fn start(param: Value) -> Result { } fn main() -> Result<(), Error> { + proxmox_backup::tools::setup_safe_path_env(); let effective_uid = nix::unistd::Uid::effective(); if !effective_uid.is_root() { bail!("this program needs to be run with setuid root"); ================================================== and then it should be alright from some quick tests... maybe it also makes sense to add this in the backup client too.