ZIP encryption extraction fails with "invalid password" error #197

Closed
opened 2026-04-12 10:29:22 +00:00 by fuzzy · 1 comment
Owner

Description
ZIP encryption support was added in commit 94076a7. While listing encrypted archives works correctly, extraction fails with zip: invalid password error for both traditional PKWARE and AES-256 encryption methods.

Steps to reproduce

  1. Create an encrypted ZIP archive:
    reptar -c -f test.zip --format=zip --zip-password=pass123 --zip-encryption=aes256 secret.txt
    
  2. List contents (works):
    reptar -t -f test.zip --zip-password=pass123
    
  3. Extract archive (fails):
    reptar -x -f test.zip --zip-password=pass123 -C out
    
    Error: Error: error extracting secret.txt: zip: invalid password

Expected behavior
Extraction should succeed with the correct password.

Possible cause
The password may not be properly applied to the file entry when reading data during extraction, even though it works for listing. The issue might be in the interaction between the archive reader and the zip package's decryption logic.

Impact
Encrypted ZIP archives cannot be extracted, limiting the usefulness of the encryption feature.

Priority: Medium

Labels: bug, zip, encryption

**Description** ZIP encryption support was added in commit 94076a7. While listing encrypted archives works correctly, extraction fails with `zip: invalid password` error for both traditional PKWARE and AES-256 encryption methods. **Steps to reproduce** 1. Create an encrypted ZIP archive: ``` reptar -c -f test.zip --format=zip --zip-password=pass123 --zip-encryption=aes256 secret.txt ``` 2. List contents (works): ``` reptar -t -f test.zip --zip-password=pass123 ``` 3. Extract archive (fails): ``` reptar -x -f test.zip --zip-password=pass123 -C out ``` Error: `Error: error extracting secret.txt: zip: invalid password` **Expected behavior** Extraction should succeed with the correct password. **Possible cause** The password may not be properly applied to the file entry when reading data during extraction, even though it works for listing. The issue might be in the interaction between the archive reader and the zip package's decryption logic. **Impact** Encrypted ZIP archives cannot be extracted, limiting the usefulness of the encryption feature. **Priority**: Medium **Labels**: bug, zip, encryption
Author
Owner

Fixed in commit a21f2b5

The extraction bug was caused by missing password setting for the main archive reader in runExtract() and runValidate() functions. The password was only set for the parity data reader used during repair operations.

Changes made:

  1. Added password setting after opening the main reader in runExtract() (lines 1344-1350)
  2. Added password setting after opening the main reader in runValidate() (lines 1777-1783)
  3. Verified both traditional PKWARE and AES-256 encryption now work correctly for extraction, listing, and validation

Testing performed:

  • Created encrypted ZIP archives with both AES-256 and traditional encryption
  • Successfully listed contents with correct password
  • Successfully extracted files with correct password
  • Verified wrong password correctly fails with "invalid password" error
  • Validated archives with correct password passes, wrong password fails

The fix is minimal and follows the same pattern already used in runList(), runConvert(), and runRepair().

**Fixed in commit a21f2b5** The extraction bug was caused by missing password setting for the main archive reader in `runExtract()` and `runValidate()` functions. The password was only set for the parity data reader used during repair operations. **Changes made:** 1. Added password setting after opening the main reader in `runExtract()` (lines 1344-1350) 2. Added password setting after opening the main reader in `runValidate()` (lines 1777-1783) 3. Verified both traditional PKWARE and AES-256 encryption now work correctly for extraction, listing, and validation **Testing performed:** - Created encrypted ZIP archives with both AES-256 and traditional encryption - Successfully listed contents with correct password - Successfully extracted files with correct password - Verified wrong password correctly fails with "invalid password" error - Validated archives with correct password passes, wrong password fails The fix is minimal and follows the same pattern already used in `runList()`, `runConvert()`, and `runRepair()`.
fuzzy closed this issue 2026-04-12 10:35:52 +00:00
Sign in to join this conversation.
No description provided.