mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
gpg: Make the use of "--verify FILE" for detached sigs harder.
* g10/openfile.c (open_sigfile): Factor some code out to ...
(get_matching_datafile): new function.
* g10/plaintext.c (hash_datafiles): Do not try to find matching file
in batch mode.
* g10/mainproc.c (check_sig_and_print): Print a warning if a possibly
matching data file is not used by a standard signatures.
--
Allowing to use the abbreviated form for detached signatures is a long
standing bug which has only been noticed by the public with the
release of 2.1.0. :-(
What we do is to remove the ability to check detached signature in
--batch using the one file abbreviated mode. This should exhibit
problems in scripts which use this insecure practice. We also print a
warning if a matching data file exists but was not considered because
the detached signature was actually a standard signature:
gpgv: Good signature from "Werner Koch (dist sig)"
gpgv: WARNING: not a detached signature; \
file 'gnupg-2.1.0.tar.bz2' was NOT verified!
We can only print a warning because it is possible that a standard
signature is indeed to be verified but by coincidence a file with a
matching name is stored alongside the standard signature.
Reported-by: Simon Nicolussi (to gnupg-users on Nov 7)
Signed-off-by: Werner Koch <wk@gnupg.org>
(backported from commit 69384568f6
)
This commit is contained in:
parent
da95d0d378
commit
a5ca45e616
4 changed files with 115 additions and 39 deletions
|
@ -1959,6 +1959,44 @@ check_sig_and_print( CTX c, KBNODE node )
|
|||
sig->sig_class==0x01?_("textmode"):_("unknown"),
|
||||
gcry_md_algo_name (sig->digest_algo));
|
||||
|
||||
if (!rc && !c->signed_data.used)
|
||||
{
|
||||
/* Signature is basically good but we test whether the
|
||||
deprecated command
|
||||
gpg --verify FILE.sig
|
||||
was used instead of
|
||||
gpg --verify FILE.sig FILE
|
||||
to verify a detached signature. If we figure out that a
|
||||
data file with a matching name exists, we print a warning.
|
||||
|
||||
The problem is that the first form would also verify a
|
||||
standard signature. This behavior could be used to
|
||||
create a made up .sig file for a tarball by creating a
|
||||
standard signature from a valid detached signature packet
|
||||
(for example from a signed git tag). Then replace the
|
||||
sig file on the FTP server along with a changed tarball.
|
||||
Using the first form the verify command would correctly
|
||||
verify the signature but don't even consider the tarball. */
|
||||
kbnode_t n;
|
||||
char *dfile;
|
||||
|
||||
dfile = get_matching_datafile (c->sigfilename);
|
||||
if (dfile)
|
||||
{
|
||||
for (n = c->list; n; n = n->next)
|
||||
if (n->pkt->pkttype != PKT_SIGNATURE)
|
||||
break;
|
||||
if (n)
|
||||
{
|
||||
/* Not only signature packets in the tree thus this
|
||||
is not a detached signature. */
|
||||
log_info (_("WARNING: not a detached signature; "
|
||||
"file '%s' was NOT verified!\n"), dfile);
|
||||
}
|
||||
xfree (dfile);
|
||||
}
|
||||
}
|
||||
|
||||
if( rc )
|
||||
g10_errors_seen = 1;
|
||||
if( opt.batch && rc )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue