<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/gpg-interface.c, branch v2.25.0</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://www.git.shady.money/git/atom?h=v2.25.0</id>
<link rel='self' href='https://www.git.shady.money/git/atom?h=v2.25.0'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/'/>
<updated>2019-11-30T21:52:35Z</updated>
<entry>
<title>gpg-interface: prefer check_signature() for GPG verification</title>
<updated>2019-11-30T21:52:35Z</updated>
<author>
<name>Hans Jerry Illikainen</name>
<email>hji@dyntopia.com</email>
</author>
<published>2019-11-27T17:48:21Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=72b006f4bfd30b7c5037c163efaf279ab65bea9c'/>
<id>urn:sha1:72b006f4bfd30b7c5037c163efaf279ab65bea9c</id>
<content type='text'>
This commit refactors the use of verify_signed_buffer() outside of
gpg-interface.c to use check_signature() instead.  It also turns
verify_signed_buffer() into a file-local function since it's now only
invoked internally by check_signature().

There were previously two globally scoped functions used in different
parts of Git to perform GPG signature verification:
verify_signed_buffer() and check_signature().  Now only
check_signature() is used.

The verify_signed_buffer() function doesn't guard against duplicate
signatures as described by Michał Górny [1].  Instead it only ensures a
non-erroneous exit code from GPG and the presence of at least one
GOODSIG status field.  This stands in contrast with check_signature()
that returns an error if more than one signature is encountered.

The lower degree of verification makes the use of verify_signed_buffer()
problematic if callers don't parse and validate the various parts of the
GPG status message themselves.  And processing these messages seems like
a task that should be reserved to gpg-interface.c with the function
check_signature().

Furthermore, the use of verify_signed_buffer() makes it difficult to
introduce new functionality that relies on the content of the GPG status
lines.

Now all operations that does signature verification share a single entry
point to gpg-interface.c.  This makes it easier to propagate changed or
additional functionality in GPG signature verification to all parts of
Git, without having odd edge-cases that don't perform the same degree of
verification.

[1] https://dev.gentoo.org/~mgorny/articles/attack-on-git-signature-verification.html

Signed-off-by: Hans Jerry Illikainen &lt;hji@dyntopia.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>gpg-interface: limit search for primary key fingerprint</title>
<updated>2019-11-23T00:18:40Z</updated>
<author>
<name>Hans Jerry Illikainen</name>
<email>hji@dyntopia.com</email>
</author>
<published>2019-11-22T20:23:12Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=67a6ea63008bcee32a239934ad29eb5c5a554509'/>
<id>urn:sha1:67a6ea63008bcee32a239934ad29eb5c5a554509</id>
<content type='text'>
The VALIDSIG status line from GnuPG with --status-fd is documented to
have 9 required and 1 optional fields [1].  The final, and optional,
field is used to specify the fingerprint of the primary key that made
the signature in case it was made by a subkey.  However, this field is
only available for OpenPGP signatures; not for CMS/X.509.

If the VALIDSIG status line does not have the optional 10th field, the
current code will continue reading onto the next status line.  And this
is the case for non-OpenPGP signatures [1].

The consequence is that a subsequent status line may be considered as
the "primary key" for signatures that does not have an actual primary
key.

Limit the search of these 9 or 10 fields to the single line to avoid
this problem.  If the 10th field is missing, report that there is no
primary key fingerprint.

[Reference]

[1] GnuPG Details, General status codes
https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=doc/DETAILS;h=6ce340e8c04794add995e84308bb3091450bd28f;hb=HEAD#l483

The documentation says:

    VALIDSIG &lt;args&gt;

    The args are:

    - &lt;fingerprint_in_hex&gt;
    - &lt;sig_creation_date&gt;
    - &lt;sig-timestamp&gt;
    - &lt;expire-timestamp&gt;
    - &lt;sig-version&gt;
    - &lt;reserved&gt;
    - &lt;pubkey-algo&gt;
    - &lt;hash-algo&gt;
    - &lt;sig-class&gt;
    - [ &lt;primary-key-fpr&gt; ]

    This status indicates that the signature is cryptographically
    valid. [...] PRIMARY-KEY-FPR is the fingerprint of the primary key
    or identical to the first argument.

    The primary-key-fpr parameter is used for OpenPGP and not available
    for CMS signatures.  [...]

Signed-off-by: Hans Jerry Illikainen &lt;hji@dyntopia.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>gpg-interface: refactor the free-and-xmemdupz pattern</title>
<updated>2019-11-23T00:09:32Z</updated>
<author>
<name>Hans Jerry Illikainen</name>
<email>hji@dyntopia.com</email>
</author>
<published>2019-11-21T23:43:35Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=392b862e9aea69acf43532527e27644c97e3ea56'/>
<id>urn:sha1:392b862e9aea69acf43532527e27644c97e3ea56</id>
<content type='text'>
Introduce a static replace_cstring() function to simplify repeated
pattern of free-and-xmemdupz() for GPG status line parsing.

This also helps us avoid potential memleaks if parsing of new status
lines are introduced in the future.

Signed-off-by: Hans Jerry Illikainen &lt;hji@dyntopia.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>gpg-interface: do not scan past the end of buffer</title>
<updated>2019-07-16T19:15:12Z</updated>
<author>
<name>Steven Roberts</name>
<email>fenderq@gmail.com</email>
</author>
<published>2019-07-16T18:47:37Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=64c45dc72ef039215f23d1b8f077dd6f9f254d38'/>
<id>urn:sha1:64c45dc72ef039215f23d1b8f077dd6f9f254d38</id>
<content type='text'>
If the GPG output ends with trailing blank lines, after skipping
them over inside the loop to find the terminating NUL at the end,
the loop ends up looking for the next line, starting past the end.

Signed-off-by: Steven Roberts &lt;sroberts@fenderq.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'mg/gpg-fingerprint'</title>
<updated>2018-11-02T15:53:58Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-11-02T15:53:58Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=11cc180fa5c4428faa64acf3507fa96d9636ad34'/>
<id>urn:sha1:11cc180fa5c4428faa64acf3507fa96d9636ad34</id>
<content type='text'>
New "--pretty=format:" placeholders %GF and %GP that show the GPG
key fingerprints have been invented.

* mg/gpg-fingerprint:
  gpg-interface.c: obtain primary key fingerprint as well
  gpg-interface.c: support getting key fingerprint via %GF format
  gpg-interface.c: use flags to determine key/signer info presence
</content>
</entry>
<entry>
<title>Merge branch 'mg/gpg-parse-tighten'</title>
<updated>2018-11-02T15:53:58Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-11-02T15:53:57Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=02561896de9d4cd2354e825bf7e6304a3c19d1c3'/>
<id>urn:sha1:02561896de9d4cd2354e825bf7e6304a3c19d1c3</id>
<content type='text'>
Detect and reject a signature block that has more than one GPG
signature.

* mg/gpg-parse-tighten:
  gpg-interface.c: detect and reject multiple signatures on commits
</content>
</entry>
<entry>
<title>gpg-interface.c: obtain primary key fingerprint as well</title>
<updated>2018-10-22T23:00:43Z</updated>
<author>
<name>Michał Górny</name>
<email>mgorny@gentoo.org</email>
</author>
<published>2018-10-22T16:38:21Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=4de9394dcb769394f490a0285015a1d26beb54d1'/>
<id>urn:sha1:4de9394dcb769394f490a0285015a1d26beb54d1</id>
<content type='text'>
Obtain the primary key fingerprint off VALIDSIG status message,
and expose it via %GP format.

Signed-off-by: Michał Górny &lt;mgorny@gentoo.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>gpg-interface.c: support getting key fingerprint via %GF format</title>
<updated>2018-10-22T23:00:09Z</updated>
<author>
<name>Michał Górny</name>
<email>mgorny@gentoo.org</email>
</author>
<published>2018-10-22T16:38:20Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=3daaaabe7ed22c17bff04d19c711be427bd2e225'/>
<id>urn:sha1:3daaaabe7ed22c17bff04d19c711be427bd2e225</id>
<content type='text'>
Support processing VALIDSIG status that provides additional information
for valid signatures.  Use this information to propagate signing key
fingerprint and expose it via %GF pretty format.  This format can be
used to build safer key verification systems that verify the key via
complete fingerprint rather than short/long identifier provided by %GK.

Signed-off-by: Michał Górny &lt;mgorny@gentoo.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>gpg-interface.c: use flags to determine key/signer info presence</title>
<updated>2018-10-22T22:58:54Z</updated>
<author>
<name>Michał Górny</name>
<email>mgorny@gentoo.org</email>
</author>
<published>2018-10-22T16:38:19Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=0b11a84e1ba26fa3c9995f19e224848d8afc9bcf'/>
<id>urn:sha1:0b11a84e1ba26fa3c9995f19e224848d8afc9bcf</id>
<content type='text'>
Replace the logic used to determine whether key and signer information
is present to use explicit flags in sigcheck_gpg_status[] array.  This
is more future-proof, since it makes it possible to add additional
statuses without having to explicitly update the conditions.

Signed-off-by: Michał Górny &lt;mgorny@gentoo.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>gpg-interface.c: detect and reject multiple signatures on commits</title>
<updated>2018-10-22T03:42:30Z</updated>
<author>
<name>Michał Górny</name>
<email>mgorny@gentoo.org</email>
</author>
<published>2018-10-20T19:30:20Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=da6cf1b3360eefdce3dbde7632eca57177327f37'/>
<id>urn:sha1:da6cf1b3360eefdce3dbde7632eca57177327f37</id>
<content type='text'>
GnuPG supports creating signatures consisting of multiple signature
packets.  If such a signature is verified, it outputs all the status
messages for each signature separately.  However, git currently does not
account for such scenario and gets terribly confused over getting
multiple *SIG statuses.

For example, if a malicious party alters a signed commit and appends
a new untrusted signature, git is going to ignore the original bad
signature and report untrusted commit instead.  However, %GK and %GS
format strings may still expand to the data corresponding
to the original signature, potentially tricking the scripts into
trusting the malicious commit.

Given that the use of multiple signatures is quite rare, git does not
support creating them without jumping through a few hoops, and finally
supporting them properly would require extensive API improvement, it
seems reasonable to just reject them at the moment.

Signed-off-by: Michał Górny &lt;mgorny@gentoo.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
