<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/t/t7510-signed-commit.sh, branch v2.26.1</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.26.1</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.26.1'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2020-01-15T22:06:06Z</updated>
<entry>
<title>gpg-interface: add minTrustLevel as a configuration option</title>
<updated>2020-01-15T22:06:06Z</updated>
<author>
<name>Hans Jerry Illikainen</name>
<email>hji@dyntopia.com</email>
</author>
<published>2019-12-27T13:55:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=54887b46890582e60fcb8ee1f287f62870c2ac0f'/>
<id>urn:sha1:54887b46890582e60fcb8ee1f287f62870c2ac0f</id>
<content type='text'>
Previously, signature verification for merge and pull operations checked
if the key had a trust-level of either TRUST_NEVER or TRUST_UNDEFINED in
verify_merge_signature().  If that was the case, the process die()d.

The other code paths that did signature verification relied entirely on
the return code from check_commit_signature().  And signatures made with
a good key, irregardless of its trust level, was considered valid by
check_commit_signature().

This difference in behavior might induce users to erroneously assume
that the trust level of a key in their keyring is always considered by
Git, even for operations where it is not (e.g. during a verify-commit or
verify-tag).

The way it worked was by gpg-interface.c storing the result from the
key/signature status *and* the lowest-two trust levels in the `result`
member of the signature_check structure (the last of these status lines
that were encountered got written to `result`).  These are documented in
GPG under the subsection `General status codes` and `Key related`,
respectively [1].

The GPG documentation says the following on the TRUST_ status codes [1]:

    """
    These are several similar status codes:

    - TRUST_UNDEFINED &lt;error_token&gt;
    - TRUST_NEVER     &lt;error_token&gt;
    - TRUST_MARGINAL  [0  [&lt;validation_model&gt;]]
    - TRUST_FULLY     [0  [&lt;validation_model&gt;]]
    - TRUST_ULTIMATE  [0  [&lt;validation_model&gt;]]

    For good signatures one of these status lines are emitted to
    indicate the validity of the key used to create the signature.
    The error token values are currently only emitted by gpgsm.
    """

My interpretation is that the trust level is conceptionally different
from the validity of the key and/or signature.  That seems to also have
been the assumption of the old code in check_signature() where a result
of 'G' (as in GOODSIG) and 'U' (as in TRUST_NEVER or TRUST_UNDEFINED)
were both considered a success.

The two cases where a result of 'U' had special meaning were in
verify_merge_signature() (where this caused git to die()) and in
format_commit_one() (where it affected the output of the %G? format
specifier).

I think it makes sense to refactor the processing of TRUST_ status lines
such that users can configure a minimum trust level that is enforced
globally, rather than have individual parts of git (e.g. merge) do it
themselves (except for a grace period with backward compatibility).

I also think it makes sense to not store the trust level in the same
struct member as the key/signature status.  While the presence of a
TRUST_ status code does imply that the signature is good (see the first
paragraph in the included snippet above), as far as I can tell, the
order of the status lines from GPG isn't well-defined; thus it would
seem plausible that the trust level could be overwritten with the
key/signature status if they were stored in the same member of the
signature_check structure.

This patch introduces a new configuration option: gpg.minTrustLevel.  It
consolidates trust-level verification to gpg-interface.c and adds a new
`trust_level` member to the signature_check structure.

Backward-compatibility is maintained by introducing a special case in
verify_merge_signature() such that if no user-configurable
gpg.minTrustLevel is set, then the old behavior of rejecting
TRUST_UNDEFINED and TRUST_NEVER is enforced.  If, on the other hand,
gpg.minTrustLevel is set, then that value overrides the old behavior.

Similarly, the %G? format specifier will continue show 'U' for
signatures made with a key that has a trust level of TRUST_UNDEFINED or
TRUST_NEVER, even though the 'U' character no longer exist in the
`result` member of the signature_check structure.  A new format
specifier, %GT, is also introduced for users that want to show all
possible trust levels for a signature.

Another approach would have been to simply drop the trust-level
requirement in verify_merge_signature().  This would also have made the
behavior consistent with other parts of git that perform signature
verification.  However, requiring a minimum trust level for signing keys
does seem to have a real-world use-case.  For example, the build system
used by the Qubes OS project currently parses the raw output from
verify-tag in order to assert a minimum trust level for keys used to
sign git tags [2].

[1] https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=doc/doc/DETAILS;h=bd00006e933ac56719b1edd2478ecd79273eae72;hb=refs/heads/master
[2] https://github.com/QubesOS/qubes-builder/blob/9674c1991deef45b1a1b1c71fddfab14ba50dccf/scripts/verify-git-tag#L43

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>commit-tree: add missing --gpg-sign flag</title>
<updated>2019-01-22T19:08:35Z</updated>
<author>
<name>Brandon Richardson</name>
<email>brandon1024.br@gmail.com</email>
</author>
<published>2019-01-19T23:23:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=70ddbd7767c24076975a176e734767facd3b5380'/>
<id>urn:sha1:70ddbd7767c24076975a176e734767facd3b5380</id>
<content type='text'>
Add --gpg-sign option in commit-tree, which was documented, but not
implemented, in 55ca3f99ae. Add tests for the --gpg-sign option.

Signed-off-by: Brandon Richardson &lt;brandon1024.br@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t7510: invoke git as part of &amp;&amp;-chain</title>
<updated>2019-01-22T19:08:33Z</updated>
<author>
<name>Martin Ågren</name>
<email>martin.agren@gmail.com</email>
</author>
<published>2019-01-19T23:23:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=41a74bd01301d2976e7f9ab1ef55733f9ea1a919'/>
<id>urn:sha1:41a74bd01301d2976e7f9ab1ef55733f9ea1a919</id>
<content type='text'>
If `git commit-tree HEAD^{tree}` fails on us and produces no output on
stdout, we will substitute that empty string and execute `git tag
ninth-unsigned`, i.e., we will tag HEAD rather than a newly created
object. But we are lucky: we have a signature on HEAD, so we should
eventually fail the next test, where we verify that "ninth-unsigned" is
indeed unsigned.

We have a similar problem a few lines later. If `git commit-tree -S`
fails with no output, we will happily tag HEAD as "tenth-signed". Here,
we are not so lucky. The tag ends up on the same commit as
"eighth-signed-alt", and that's a signed commit, so t7510-signed-commit
will pass, despite `git commit-tree -S` failing.

Make these `git commit-tree` invocations a direct part of the &amp;&amp;-chain,
so that we can rely less on luck and set a better example for future
tests modeled after this one. Fix a 9/10 copy/paste error while at it.

Signed-off-by: Martin Ågren &lt;martin.agren@gmail.com&gt;
Signed-off-by: Brandon Richardson &lt;brandon1024.br@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t/t7510-signed-commit.sh: add signing subkey to Eris Discordia key</title>
<updated>2018-11-05T02:00:58Z</updated>
<author>
<name>Michał Górny</name>
<email>mgorny@gentoo.org</email>
</author>
<published>2018-11-04T09:47:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1e690847d14034072379fb1382ef09fda3ed12bc'/>
<id>urn:sha1:1e690847d14034072379fb1382ef09fda3ed12bc</id>
<content type='text'>
Add a dedicated signing subkey to the key identified as 'Eris
Discordia', and update tests appropriately.  GnuPG will now sign commits
using the dedicated signing subkey, changing the value of %GK and %GF,
and effectively creating a test case for %GF!=%GP.

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>t/t7510-signed-commit.sh: Add %GP to custom format checks</title>
<updated>2018-11-05T02:00:56Z</updated>
<author>
<name>Michał Górny</name>
<email>mgorny@gentoo.org</email>
</author>
<published>2018-11-04T09:47:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1a550529b123f1b45334b6ed3d9b2c3e94e319e2'/>
<id>urn:sha1:1a550529b123f1b45334b6ed3d9b2c3e94e319e2</id>
<content type='text'>
Test %GP in addition to %GF in custom format checks.  With current
keyring, both have the same value.

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://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: 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://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>
<entry>
<title>t/t7510: check the validation of the new config gpg.format</title>
<updated>2018-07-18T17:02:00Z</updated>
<author>
<name>Henning Schild</name>
<email>henning.schild@siemens.com</email>
</author>
<published>2018-07-18T09:30:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1865a647c3d8bb6367be4b799dd95217ccfbe26e'/>
<id>urn:sha1:1865a647c3d8bb6367be4b799dd95217ccfbe26e</id>
<content type='text'>
Test setting gpg.format to both invalid and valid values.

Signed-off-by: Henning Schild &lt;henning.schild@siemens.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>tests: make forging GPG signed commits and tags more robust</title>
<updated>2018-06-11T17:19:03Z</updated>
<author>
<name>SZEDER Gábor</name>
<email>szeder.dev@gmail.com</email>
</author>
<published>2018-06-04T13:39:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2f3cbcd8c5a00dc043aabc13f2af221c7c0e89ad'/>
<id>urn:sha1:2f3cbcd8c5a00dc043aabc13f2af221c7c0e89ad</id>
<content type='text'>
A couple of test scripts create forged GPG signed commits or tags to
check that such forgery can't fool various git commands' signature
verification.  All but one of those test scripts are prone to
occasional failures because the forgery creates a bogus GPG signature,
and git commands error out with an unexpected error message, e.g.
"Commit deadbeef does not have a GPG signature" instead of "...  has a
bad GPG signature".

't5573-pull-verify-signatures.sh', 't7510-signed-commit.sh' and
't7612-merge-verify-signatures.sh' create forged signed commits like
this:

  git commit -S -m "bad on side" &amp;&amp;
  git cat-file commit side-bad &gt;raw &amp;&amp;
  sed -e "s/bad/forged bad/" raw &gt;forged &amp;&amp;
  git hash-object -w -t commit forged &gt;forged.commit

On rare occasions the given pattern occurs not only in the commit
message but in the GPG signature as well, and after it's replaced in
the signature the resulting signature becomes invalid, GPG will report
CRC error and that it couldn't find any signature, which will then
ultimately cause the test failure.

Since in all three cases the pattern to be replaced during the forgery
is the first word of the commit message's subject line, and since the
GPG signature in the commit object is indented by a space, let's just
anchor those patterns to the beginning of the line to prevent this
issue.

The test script 't7030-verify-tag.sh' creates a forged signed tag
object in a similar way by replacing the pattern "seventh", but the
GPG signature in tag objects is not indented by a space, so the above
solution is not applicable in this case.  However, in the tag object
in question the pattern "seventh" occurs not only in the tag message
but in the 'tag' header as well.  To create a forged tag object it's
sufficient to replace only one of the two occurences, so modify the
sed script to limit the pattern to the 'tag' header (i.e. a line
beginning with "tag ", which, because of the space character, can
never occur in the base64-encoded GPG signature).

Note that the forgery in 't7004-tag.sh' is not affected by this issue:
while 't7004' does create a forged signed tag kind of the same way,
it replaces "signed-tag" in the tag object, which, because of the '-'
character, can never occur in the base64-encoded GPG signarute.

Signed-off-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t7510-signed-commit: use 'test_must_fail'</title>
<updated>2018-06-11T17:19:03Z</updated>
<author>
<name>SZEDER Gábor</name>
<email>szeder.dev@gmail.com</email>
</author>
<published>2018-06-04T13:39:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9dd39821e3d0adf3f160642589291965c73a529e'/>
<id>urn:sha1:9dd39821e3d0adf3f160642589291965c73a529e</id>
<content type='text'>
The two tests 'detect fudged signature' and 'detect fudged signature
with NUL' in 't7510-signed-commit.sh' check that 'git verify-commit'
errors out when encountering a forged commit, but they do so by
running

  ! git verify-commit ...

Use 'test_must_fail' instead, because that would catch potential
unexpected errors like a segfault as well.

Signed-off-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
