Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpg sign your commits #49

Closed
hasufell opened this issue Aug 30, 2014 · 29 comments
Closed

gpg sign your commits #49

hasufell opened this issue Aug 30, 2014 · 29 comments

Comments

@hasufell
Copy link
Contributor

https://ariejan.net/2014/06/04/gpg-sign-your-git-commits/

@urras
Copy link
Contributor

urras commented Sep 1, 2014

Will do, I've notified @zetok and @holgersson32644 to do the same.

@urras urras closed this as completed Sep 1, 2014
@l29ah
Copy link
Contributor

l29ah commented Sep 10, 2014

hasufell, how do you check those signatures btw?

@l29ah
Copy link
Contributor

l29ah commented Sep 10, 2014

urras, what do you actually denote signing a commit?

@urras
Copy link
Contributor

urras commented Sep 10, 2014

@l29ah Using git log --show-signature, you can verify the author of the Git commits

@l29ah
Copy link
Contributor

l29ah commented Sep 10, 2014

@urras sure, but different people seem to mean different things when they sign a commit.

@hasufell
Copy link
Contributor Author

The issue title says "gpg sign" and the provided link in the first post shows how it's done. I don't see how that can be misunderstood.

@l29ah
Copy link
Contributor

l29ah commented Sep 10, 2014

The link doesn't clarify on what do they mean. It seems like popular interpretations are "signature verifies that the signer is the author of the changeset" and "same + signer trusts all the commits done before his commit".

@hasufell
Copy link
Contributor Author

signer trusts all the commits done before his commit

That doesn't make sense for non-merge commits and is not my job. I take responsibility only for my own commits, unless I pull someone elses changes.

@l29ah
Copy link
Contributor

l29ah commented Sep 10, 2014

But Linus and people implementing the user-side validation think different:
http://git.661346.n2.nabble.com/GPG-signing-for-git-commit-td2582986.html
https://aur.archlinux.org/packages/pa/parcimonie-sh-git/PKGBUILD
So it seems the signing policy should be explicitly noted somewhere or so.

@hasufell
Copy link
Contributor Author

But Linus and people implementing the user-side validation think different

I don't see any indication of that in Linus posts.

Linux is developed in a hiearchy manner and applies to exactly what I described in my previous post. You take responsibility of other commits ONLY if you MERGE them. And that's the only way to propagate patches up to Linus tree. There is no one who has direct access to Linus tree except Linus.

@l29ah
Copy link
Contributor

l29ah commented Sep 10, 2014

… and his hoster. Just like in your project, but you have more than one valid pusher; that doesn't change the point.
Anyway, what's the correct way to verify your repo contents can be trusted if i trust the (keys of) three of you, according to your model?

@l29ah
Copy link
Contributor

l29ah commented Sep 10, 2014

Three of the devs, I mean.

@hasufell
Copy link
Contributor Author

… and his hoster

The hoster cannot push with a valid gpg key.

but you have more than one valid pusher

As a user, you have to trust all of the pushers, obviously. Any pull request goes through at least one of them. So it's enough to check for the signatures of those pushers.

Signed tags are usually used to review the whole state of a repository and mark it's integrity, but they don't make sense for overlays. If you want to automate the signature verification, write a script.

@l29ah
Copy link
Contributor

l29ah commented Sep 10, 2014

So what should the script do?

@hasufell
Copy link
Contributor Author

An incomplete example what it could do. Simple shell stuff.

git log --committer="urras" --committer="Zetok Zalbavar" --pretty="format:%h %an %G?" fcd9a208515e6aff8bf23c0d706a98c954e71050..HEAD | grep '.* [NBU]$'

@l29ah
Copy link
Contributor

l29ah commented Sep 10, 2014

I don't see the criteria of validity from your example.

@hasufell
Copy link
Contributor Author

I don't see the criteria of validity from your example.

Read the git-log manpage.

@l29ah
Copy link
Contributor

l29ah commented Sep 10, 2014

It doesn't specify how do i assert the validity of the repo.

@hasufell
Copy link
Contributor Author

It doesn't specify how do i assert the validity of the repo.

I gave you a working script that prints out all non-trusted commits. I'm not going to explain every piece of it. That's what the manpage is for.

@l29ah
Copy link
Contributor

l29ah commented Sep 11, 2014

So do you mean git log --committer="urras" --committer="Zetok Zalbavar" --pretty="format:%h %an %G?" fcd9a208515e6aff8bf23c0d706a98c954e71050..HEAD | grep -q '.*[NBU]$' && echo untrusted || echo trusted?

@hasufell
Copy link
Contributor Author

A more interesting problem is the following:
If you only trust the repository maintainers and only check their commits for validity, then you would still need to verify that any commit that's not done by those people are part of a merge. (imagine somebody hacked github again and committed straight to the repo... my above script wouldn't be able to catch that case)

There are several ways to fix this problem:

  • write a script that does this magic automatically and only verifies branch 'A' of a merge. This requires that there are no fast-forward merges! So it wouldn't only validate commits from the pushers, but any commit, as long as they are normal commits or in case of a merge branch 'A'. But I currently have no implementation for this. Afais this can't be done with a bash oneliner.
  • don't do merges at all, use 'git am' instead, so we wouldn't have any comitter except those that have direct push access. Git allows separation of committer and author, so this is no problem. However, in this case we wouldn't have the signature of the author, but only of the committer. This isn't a trust issue, but rather an information issue (you can't verify the identity of the author yourself).

@hasufell
Copy link
Contributor Author

So, here is the script that checks all commit signatures in a specific range except those that are part of a merged branch (but the merge commit is checked ofc).

git show -q --pretty="format:%h %an %G?" $(git rev-list --first-parent 0255e9ab84eb12784c054a4fd681333348f5912a..HEAD) | grep '.* [NBU]$'

This means:

  • if you do fast-forward merges in this repository, then the merged commits have to be signed by the repository maintainers! So best not doing fast-forward merges at all. Enforce merge commits via git merge --no-ff.
  • pull requests from other people don't necessarily need signed commits, although it's nice to have them signed
  • applying pull request manually via git am is also fine, since the committer is the one who signs, not the author

Something similar will probably be done via update hooks for the gentoo git tree (if it ever comes).

@hasufell
Copy link
Contributor Author

@urras do you have a complete list of people who have push access and their public gpg keys?

We could then add some instructions to the readme how to automatically validate the signatures.

@l29ah
Copy link
Contributor

l29ah commented Sep 14, 2014

@hasufell so it will succeed if the tree is totally fake w/o any signature whatsoever.

By the way, ‰ gpg --recv-key 0x53137C3033F09008
gpg: requesting key 0x53137C3033F09008 from hkps server hkps.pool.sks-keyservers.net
gpgkeys: key 53137C3033F09008 not found on keyserver
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0

@hasufell
Copy link
Contributor Author

so it will succeed if the tree is totally fake w/o any signature whatsoever.

no.

@urras
Copy link
Contributor

urras commented Sep 15, 2014

My PGP key is at https://pgp.mit.edu/pks/lookup?op=get&search=0x9DD9AB20E51227D2
I'm CCing @zetok and @holgersson32644 to get them to add their keys to this issue

@urras urras reopened this Sep 15, 2014
@urras urras closed this as completed Sep 15, 2014
@zetok
Copy link
Owner

zetok commented Sep 15, 2014

@holgersson32644
Copy link
Contributor

https://pgp.mit.edu/pks/lookup?op=get&search=0xE55E95E8220F34D7
(The key running until 2017.)

@urras
Copy link
Contributor

urras commented Sep 16, 2014

PGP keys were added to AUTHORS in 61489b5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants