`-p` is silently ignored for tar/wim/gzip/xz (plaintext archive, rc=0, no warning); same for `-mhe=on` and `-mem=AES256` without a password
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Start with the update handlers named in the report: CPP/7zip/UI/Console/UpdateCallbackConsole.cpp, UI/Common/Update.cpp, and the 7z, Zip, Tar, Gzip, Xz, and Wim output handlers. Trace how password and encryption options reach each handler, then check the relevant command-line tests or add a focused regression test for unsupported formats and missing passwords. Done means these requests produce the specified warning or error and exit status instead of silently creating an unencrypted archive.
Written by the indexing model from the issue text.
Description
Environment
- 7-Zip (z) 26.06 (arm64),
ip7z/7zip@d3296e3 - macOS 26.4.1 arm64, Apple clang 21.0.0
Description
When -p{password} is given for a format that cannot encrypt, 7-Zip creates a plain archive and reports success. The same happens when header encryption (-mhe=on) or an AES method (-mem=AES256) is requested without a password. A user who relies on the password to protect the data ends up with readable content and no signal.
Steps to reproduce
Z=7zz
d=$(mktemp -d) && cd "$d" && printf 'TOP-SECRET-PAYLOAD' > a.txt
for t in tar wim gzip xz zip 7z; do
rm -f s.$t
out=$($Z a -bd -t$t -psecret s.$t a.txt 2>&1); rc=$?
echo "-t$t -psecret rc=$rc msgs=$(echo "$out" | grep -ciE 'warn|error') plaintext_in_file=$(grep -c TOP-SECRET-PAYLOAD s.$t) x_without_password_rc=$($Z x -bd -y -oxo_$t s.$t </dev/null >/dev/null 2>&1; echo $?)"
done
$Z a -bd -mhe=on h.7z a.txt >/dev/null 2>&1; echo "7z -mhe=on (no -p) rc=$? ; l without password lists names: $($Z l -bd h.7z </dev/null | grep -c a.txt)"
$Z a -bd -tzip -mem=AES256 e.zip a.txt >/dev/null 2>&1; echo "zip -mem=AES256 (no -p) rc=$? ; encrypted items: $($Z l -slt e.zip </dev/null | grep -c 'Encrypted = +')"
Output:
-ttar -psecret rc=0 msgs=0 plaintext_in_file=1 x_without_password_rc=0
-twim -psecret rc=0 msgs=0 plaintext_in_file=1 x_without_password_rc=0
-tgzip -psecret rc=0 msgs=0 plaintext_in_file=1 x_without_password_rc=0
-txz -psecret rc=0 msgs=0 plaintext_in_file=1 x_without_password_rc=0
-tzip -psecret rc=0 msgs=0 plaintext_in_file=0 x_without_password_rc=255
-t7z -psecret rc=0 msgs=0 plaintext_in_file=0 x_without_password_rc=255
7z -mhe=on (no -p) rc=0 ; l without password lists names: 1
zip -mem=AES256 (no -p) rc=0 ; encrypted items: 0
(for gzip and xz the "plaintext" grep is a stored/deflated check of the small payload; extraction works without any password in all four cases)
Expected
-p is documented as "Specifies password." and the example 7z a archive.7z -psecret -mhe *.txt is described as *"compresses .txt files to archive.7z using password "secret". Also it encrypts archive headers (-mhe switch), so filenames will be encrypted." (https://7-zip.opensource.jp/chm/cmdline/switches/password.htm). 7zz --help lists -p{Password} : set Password with no format restriction. For a format that cannot encrypt, expected: a command-line error or at least a warning ("password is ignored for this format", exit code 1), and likewise when -mhe=on / -mem=AES* has no password to apply.
Actual
rc=0, no message, archive stored without encryption.
Root cause (analysis on d3296e3)
- The console always offers the password through
CUpdateCallbackConsole::CryptoGetTextPassword2(CPP/7zip/UI/Console/UpdateCallbackConsole.cpp:830-852),PasswordIsDefinedbeing set from the command line (UI/Console/Main.cpp:1586). - Only the 7z and zip update handlers ask for it:
Archive/7z/7zHandlerOut.cpp:731andArchive/Zip/ZipHandlerOut.cpp:408. The tar, gzip, xz and wim update handlers never callCryptoGetTextPassword2(no occurrence inTarHandlerOut.cpp,GzHandler.cpp,XzHandler.cpp,WimHandlerOut.cpp), and nothing inUI/Common/Update.cppchecks that a password was consumed. - Header encryption in 7z is gated on a password:
7zHandlerOut.cpp:750:if (methodMode.PasswordIsDefined) { ... encryptHeaders = _encryptHeaders ...}. Without a password the-mhesetting is dropped without a message. The zip handler setsIsAesModeonly whenPassword_Defined(ZipHandlerOut.cpp:410-413), so-mem=AES256without-pis dropped as well.
Suggested fix
After the update finishes (or before it starts), report a warning (exit code 1) or error when a password was supplied (PasswordEnabled) and no handler requested it, and when -mhe=on / -mem=AES* is specified without a password. At minimum, document on the -p and -mhe pages which formats support encryption.
Found with a differential test setup (a model of the documented behavior, and for some reports an independent tool such as libarchive/bsdtar, compared against the real binary) and then checked by hand: every command above was re-run verbatim on the tested build, and the root cause was read in the source. Tested commit: d3296e3 (26.06).
- Dominant language
- C++
- Stars
- 4.6k
- Forks
- 519
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ip7z/7zip
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
area::installer documentation engine::sd enhancement wg::platform-core
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
lemonade-sdk/lemonade#4349 ·
Maintainers usually reply within 1 day
-
Python example: list a model's scenes and their camerasPossibly taken @rudraparmar76 claimed this today. Opendocumentation good first issue python
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
iamahsanmehmood/openskp#796 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tenstorrent/tt-umd#4183 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
odelaneau/GLIMPSE#353 · 1 comment ·
Maintainers usually reply within 4 days