From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id B68AD1FF0E0 for ; Thu, 09 Jul 2026 14:22:11 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 85B78214FB; Thu, 09 Jul 2026 14:22:11 +0200 (CEST) From: Jakob Klocker To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup 1/2] fix #6990: server: drop verify state on non-decrypt pull job Date: Thu, 9 Jul 2026 14:21:34 +0200 Message-ID: <20260709122136.352839-2-j.klocker@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260709122136.352839-1-j.klocker@proxmox.com> References: <20260709122136.352839-1-j.klocker@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 2 AWL -0.347 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: SVHLNNH3JM5DI5MM4TUYEUHUNKYWKWIG X-Message-ID-Hash: SVHLNNH3JM5DI5MM4TUYEUHUNKYWKWIG X-MailFrom: jklocker@iris.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Jakob Klocker X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On a non-decrypt pull the source manifest is written to the target as-is, so the target inherits the source's verify_state flag instead of being verified independently on its own storage. Because a snapshot carrying a verify_state is skipped by verify jobs, the target's copy can never be checked. The decrypt path already drops verify_state; do the same on the non-decrypt path when the snapshot is newly pulled or re-synced due to corruption. Also factor the manifest blob encoding and writing into a helper, shared by both paths. Link: https://bugzilla.proxmox.com/show_bug.cgi?id=6990 Signed-off-by: Jakob Klocker --- src/server/pull.rs | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/server/pull.rs b/src/server/pull.rs index e86a9c329..f8107911e 100644 --- a/src/server/pull.rs +++ b/src/server/pull.rs @@ -745,7 +745,8 @@ async fn pull_snapshot<'a>( }; let mut manifest_data = tmp_manifest_blob.raw_data().to_vec(); - let manifest = BackupManifest::try_from(tmp_manifest_blob).with_context(|| prefix.clone())?; + let mut manifest = + BackupManifest::try_from(tmp_manifest_blob).with_context(|| prefix.clone())?; if ignore_not_verified_or_encrypted( &manifest, @@ -885,19 +886,15 @@ async fn pull_snapshot<'a>( new_manifest.set_sync_source_signature(expected.bytes())?; } - let manifest_string = new_manifest.to_string(None)?; - let manifest_blob = DataBlob::encode(manifest_string.as_bytes(), None, true)?; - // update contents to be uploaded to backend - manifest_data = manifest_blob.raw_data().to_vec(); - - let mut tmp_manifest_file = OpenOptions::new() - .write(true) - .truncate(true) // clear pre-existing manifest content - .open(&tmp_manifest_name) - .await?; - tmp_manifest_file.write_all(&manifest_data).await?; - tmp_manifest_file.flush().await?; - nix::unistd::fsync(tmp_manifest_file.as_raw_fd())?; + manifest_data = write_manifest_blob(&new_manifest, &tmp_manifest_name).await?; + } else if (is_new || corrupt) && manifest.unprotected.get("verify_state").is_some() { + // the manifest is copied as-is on the non-decrypted path, drop verify_state explicitly + if let Some(unprotected) = manifest.unprotected.as_object_mut() { + unprotected.remove("verify_state"); + } else { + bail!("Encountered unexpected manifest without 'unprotected' section."); + } + manifest_data = write_manifest_blob(&manifest, &tmp_manifest_name).await?; } if let Err(err) = std::fs::rename(&tmp_manifest_name, &manifest_name) { @@ -927,6 +924,23 @@ async fn pull_snapshot<'a>( Ok(Some(sync_stats)) } +async fn write_manifest_blob( + manifest: &BackupManifest, + path: &std::path::Path, +) -> Result, Error> { + let manifest_blob = DataBlob::encode(manifest.to_string(None)?.as_bytes(), None, true)?; + let manifest_data = manifest_blob.raw_data().to_vec(); + let mut manifest_file = OpenOptions::new() + .write(true) + .truncate(true) + .open(path) + .await?; + manifest_file.write_all(&manifest_data).await?; + manifest_file.flush().await?; + nix::unistd::fsync(manifest_file.as_raw_fd())?; + Ok(manifest_data) +} + /// Check if the decryption key should be used to decrypt the snapshot during /// pull based on given pull parameter, source and optionally already present /// target manifest. -- 2.47.3