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 25E2469CD1 for ; Mon, 10 Aug 2020 13:25:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1EAE9147AA for ; Mon, 10 Aug 2020 13:25:22 +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 73EFA147A0 for ; Mon, 10 Aug 2020 13:25:21 +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 429EF44548 for ; Mon, 10 Aug 2020 13:25:21 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Mon, 10 Aug 2020 13:25:05 +0200 Message-Id: <20200810112509.70129-3-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200810112509.70129-1-f.gruenbichler@proxmox.com> References: <20200810112509.70129-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.046 Adjusted score from AWL reputation of From: address 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 Subject: [pbs-devel] [PATCH proxmox-backup 1/5] datastore api: only decode unencrypted indices 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: Mon, 10 Aug 2020 11:25:52 -0000 these checks were already in place for regular downloading of backed up files, also do them when attempting to decode a catalog, or when downloading decoded files referenced by a pxar index. Signed-off-by: Fabian Grünbichler --- src/api2/admin/datastore.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index a0a14a2f..d535b4d2 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -1133,9 +1133,18 @@ fn catalog( let allowed = (user_privs & PRIV_DATASTORE_READ) != 0; if !allowed { check_backup_owner(&datastore, backup_dir.group(), &userid)?; } + let file_name = CATALOG_NAME; + + let (_manifest, files) = read_backup_index(&datastore, &backup_dir)?; + for file in files { + if file.filename == file_name && file.crypt_mode == Some(CryptMode::Encrypt) { + bail!("cannot decode '{}' - is encrypted", file_name); + } + } + let mut path = datastore.base_path(); path.push(backup_dir.relative_path()); - path.push(CATALOG_NAME); + path.push(file_name); let index = DynamicIndexReader::open(&path) .map_err(|err| format_err!("unable to read dynamic index '{:?}' - {}", &path, err))?; @@ -1238,19 +1247,24 @@ fn pxar_file_download( let allowed = (user_privs & PRIV_DATASTORE_READ) != 0; if !allowed { check_backup_owner(&datastore, backup_dir.group(), &userid)?; } - let mut path = datastore.base_path(); - path.push(backup_dir.relative_path()); - let mut components = base64::decode(&filepath)?; if components.len() > 0 && components[0] == '/' as u8 { components.remove(0); } let mut split = components.splitn(2, |c| *c == '/' as u8); - let pxar_name = split.next().unwrap(); + let pxar_name = std::str::from_utf8(split.next().unwrap())?; let file_path = split.next().ok_or(format_err!("filepath looks strange '{}'", filepath))?; + let (_manifest, files) = read_backup_index(&datastore, &backup_dir)?; + for file in files { + if file.filename == pxar_name && file.crypt_mode == Some(CryptMode::Encrypt) { + bail!("cannot decode '{}' - is encrypted", pxar_name); + } + } - path.push(OsStr::from_bytes(&pxar_name)); + let mut path = datastore.base_path(); + path.push(backup_dir.relative_path()); + path.push(pxar_name); let index = DynamicIndexReader::open(&path) .map_err(|err| format_err!("unable to read dynamic index '{:?}' - {}", &path, err))?; -- 2.20.1