From a4eac0b62c189d72ea9a4a46340ab2e68df54ea3 Mon Sep 17 00:00:00 2001 From: Mrityunjay Raj Date: Mon, 1 Jun 2026 23:56:26 +0530 Subject: [PATCH] testsuite: move manifest corruption offset into data_encrypted region, refs #8572 Corruption at offset 123 lands inside meta_encrypted (header is 49 bytes), causing extract_crypted_data to return a shifted slice whose first byte is a random AES-OCB ciphertext byte. When that byte equals 0x02 (PlaintextKey type) key detection silently selects the wrong key, leading to a flaky IntegrityError in rebuild_archives. Move the insertion point to offset 250, which is safely inside data_encrypted for any realistic manifest size, so key detection always reads the correct type byte and the corruption is caught by AEAD authentication instead. --- src/borg/testsuite/archiver/check_cmd_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/borg/testsuite/archiver/check_cmd_test.py b/src/borg/testsuite/archiver/check_cmd_test.py index 7d6290c90..162b4c198 100644 --- a/src/borg/testsuite/archiver/check_cmd_test.py +++ b/src/borg/testsuite/archiver/check_cmd_test.py @@ -225,7 +225,7 @@ def test_corrupted_manifest(archivers, request): archive, repository = open_archive(archiver.repository_path, "archive1") with repository: manifest = repository.get_manifest() - corrupted_manifest = manifest[:123] + b"corrupted!" + manifest[123:] + corrupted_manifest = manifest[:250] + b"corrupted!" + manifest[250:] repository.put_manifest(corrupted_manifest) cmd(archiver, "check", exit_code=1) output = cmd(archiver, "check", "-v", "--repair", exit_code=0) @@ -273,7 +273,7 @@ def test_manifest_rebuild_corrupted_chunk(archivers, request): archive, repository = open_archive(archiver.repository_path, "archive1") with repository: manifest = repository.get_manifest() - corrupted_manifest = manifest[:123] + b"corrupted!" + manifest[123:] + corrupted_manifest = manifest[:250] + b"corrupted!" + manifest[250:] repository.put_manifest(corrupted_manifest) chunk = repository.get(archive.id) corrupted_chunk = chunk + b"corrupted!" @@ -312,7 +312,7 @@ def test_spoofed_archive(archivers, request): with repository: # attacker would corrupt or delete the manifest to trigger a rebuild of it: manifest = repository.get_manifest() - corrupted_manifest = manifest[:123] + b"corrupted!" + manifest[123:] + corrupted_manifest = manifest[:250] + b"corrupted!" + manifest[250:] repository.put_manifest(corrupted_manifest) archive_dict = { "command_line": "",