git-sig/README.md

174 lines
5.3 KiB
Markdown
Raw Permalink Normal View History

# git-sig #
2020-11-16 12:21:30 +00:00
The simple multisig toolchain for git repos.
2020-11-16 12:21:30 +00:00
## Features
* Attach any number of signatures to any given git ref
2024-04-07 15:31:28 +00:00
* Verify git history contains a minimum threshold of unique commit signatures
2020-11-16 12:21:30 +00:00
* Verify signatures belong to a defined GPG alias group
* Verify code changes made since last time minimum valid signatures were present
2020-11-18 00:11:29 +00:00
* Allow user to manually verify new keys and add to alias groups on the fly
* Prompt user to install or upgrade any required tools as needed
* Signs notes against git "tree hash" so signatures survive a rebase
* So long as the directory contents at a given ref do not change
2020-11-16 12:21:30 +00:00
## Install
1. Clone
2020-11-16 12:31:25 +00:00
```
git clone https://codeberg.org/distrust/git-sig.git
2020-11-16 12:31:25 +00:00
```
2020-11-16 12:21:30 +00:00
2. Review source code and signatures manually
2020-11-16 12:36:05 +00:00
Using `git-sig` to verify the signatures of `git-sig` itself is not
recommended as it could simply lie to you.
2020-11-16 12:31:25 +00:00
Consider using the following one liner which is much faster to review:
2020-11-16 12:31:25 +00:00
```
2023-04-05 22:38:12 +00:00
git fetch origin refs/notes/signatures:refs/notes/signatures
while read -r line; do \
gpg --verify \
<(printf "$line" | sed 's/.*pgp://g'| openssl base64 -d -A) \
<(printf "$line" | sed 's/pgp:.*/pgp/g'); \
done < <(git notes --ref=signatures show)
2020-11-16 12:31:25 +00:00
```
2020-11-16 12:21:30 +00:00
3. Copy to `$PATH`
2020-11-16 12:31:25 +00:00
```
cp git-sig ~/.local/bin/
2020-11-16 12:31:25 +00:00
```
2020-11-16 12:21:30 +00:00
2020-11-17 23:40:34 +00:00
## Usage
```
git sig add [-m,--method=<note|tag>] [-p,--push]
Add signature for this repository
git sig remove
Remove all signatures on current ref
git sig verify [-g,--group=<group>] [-t,--threshold=<N>] [d,--diff=<branch>]
Verify m-of-n signatures by given group are present for directory.
git sig push [-r,--remote=<remote>]
Push all signatures on current ref
git sig fetch [-g,--group=<group>]
Fetch key by fingerprint. Optionally add to group.
git sig help
Show this text.
git sig version
Show version information.
```
2020-11-17 23:40:34 +00:00
2020-11-16 12:21:30 +00:00
## Methods
* Note
* Store/Verify signatures via Git Notes (default)
* Can be exported and verified by external tools even without git history
* Tag
* Any git signed tags count towards total signatures
* Can optionally store new signatures as "sig-*" signed tag
* Commit
* Signed commits count as one valid signature
2020-11-16 12:21:30 +00:00
### Assumptions
- Single sig mode: Repo contents controlled by signer
- Multi-sig mode: Repo contents verified by multiple signers
- Multi-sig group mode: Repo contents approved by specified individuals
- Hashing scheme is not broken: (SHA1, blame Torvalds)
2020-11-16 12:21:30 +00:00
2020-11-16 12:43:14 +00:00
## Examples
#### Verify at least one signature is present with a known key
2020-11-16 12:21:30 +00:00
```
git sig verify
2020-11-16 12:21:30 +00:00
```
#### Verify 2 unique signatures from known keys
2020-11-16 12:21:30 +00:00
```
git sig verify --threshold 2
2020-11-16 12:21:30 +00:00
```
#### Verify 3 unique signatures from specified signing group
```
git sig verify --threshold 3 --group myteam
2020-11-16 12:21:30 +00:00
```
#### Show diff between HEAD and last ref with 2 verified unique signatures
```
git sig verify --threshold 2 --diff
2023-01-26 02:04:54 +00:00
```
#### Add signature
2020-11-16 12:21:30 +00:00
```
git sig add
2020-11-16 12:21:30 +00:00
```
2020-11-17 00:22:24 +00:00
## Frequently Asked Questions
### Why Bash?
2020-11-17 23:56:39 +00:00
Because it is easy to quickly verify at any time, has wide OS compatibility and
the majority of the needed operations are calling other programs already on
most systems like gpg and openssl.
2020-11-17 00:22:24 +00:00
If this were in another language it would be harder to audit on the fly, would
require the user to have a specific language toolchain installed, and it would
still mostly just be a bunch of shell executions to call system binaries
anyway.
### Why PGP?
In spite of many popular claims to the contrary, PGP is still the most well
supported protocol for distribution, verification, and signing for keys held
2020-11-18 00:37:13 +00:00
by individual humans. It is also the only protocol with wide HSM support
allowing you to keep keys out of system memory and require physical approval
2024-04-07 15:31:28 +00:00
for each operation. E.G a trezor, ledger, YubiKey, etc.
2020-11-17 00:22:24 +00:00
Admittedly the GnuPG codebase itself is a buggy dated mess, but PGP as a spec
is still Pretty Good for many use cases. A recent modern rewrite by a number
of former GnuPG team members is near complete and set to give PGP a long and
stable future.
See: https://sequoia-pgp.org/
2020-11-18 00:37:13 +00:00
### Why not "notary" ?
Notary is very well designed and well supports many HSMs.
It may be worth supporting as an alternate method in the future if m-of-n
multisig is ever implemented as a part of the TUF specification which has been
on their TODO list for a few years now.
It has the very desirable feature of conditionally expiring signatures which
no other solution has at the time of this writing, which comes from it being
purpose built for software signing concerns.
See: [The Update Framework](https://theupdateframework.io)
### Why not straight "openssl" ?
Openssl has HSM support via OpenSC that is fairly well supported via PKSC#11.
2024-04-07 15:31:28 +00:00
Contributions suggesting this an alternative backend to OpenPGP are welcome,
2020-11-18 00:37:13 +00:00
however they would have to also come with methods for key discovery and pinned
key groups via configuration files of some kind.
PGP gives us these features almost for free.
### Why not "signify", "age", or "crev" ?
These alternatives have poor if any support for HSM workflows and thus put
private keys at too much risk of theft or loss to recommend for general use at
this time.
2024-04-07 15:31:28 +00:00
That said, verifying folders/repos that use these methods is certainly of value
2020-11-18 00:37:13 +00:00
and contributions to support doing this on systems where those tools are
available are welcome.