`-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
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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).
- Lingua principale
- C++
- Stelle
- 4.6k
- Fork
- 519
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ip7z/7zip
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
area::installer documentation engine::sd enhancement wg::platform-core
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
lemonade-sdk/lemonade#4349 ·
I maintainer di solito rispondono entro 1 giorno
-
Python example: list a model's scenes and their camerasForse già presa @rudraparmar76 l’ha presa oggi. Apertadocumentation good first issue python
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
iamahsanmehmood/openskp#796 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
tenstorrent/tt-umd#4183 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
odelaneau/GLIMPSE#353 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni