Adds replacements for gsign
and gverify
.
Personally I’m not a big fan of using the word “sign” as it’s been used to refer to both codesigning and GPG signing.
Adds replacements for gsign
and gverify
.
Personally I’m not a big fan of using the word “sign” as it’s been used to refer to both codesigning and GPG signing.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
No conflicts as of last run.
Perhaps we can test this by doing a trial run? I’ve PR’ed my attestations of 5da0e361b8b5a6d730a244e774c6810946619229 here: https://github.com/bitcoin-core/guix.sigs/pull/1
What I did:
guix-build
env GUIX_SIGS_REPO=<path/to/guix.sigs> SIGNER=0x96AB007F1A7ED999=dongcarl ./contrib/guix/guix-attest
Once you’ve run ./contrib/guix/guix-attest
, you can verify against my signatures using:
0$ env GUIX_SIGS_REPO=<path/to/guix.sigs> ./contrib/guix/guix-verify
Tested 5da0e361b8b5a6d730a244e774c6810946619229.
Result: https://github.com/bitcoin-core/guix.sigs/pull/2
Once you’ve run
./contrib/guix/guix-attest
, you can verify against my signatures using:0$ env GUIX_SIGS_REPO=<path/to/guix.sigs> ./contrib/guix/guix-verify
I think it is possible when https://github.com/bitcoin-core/guix.sigs/pull/1 is merged, no?
I think it is possible when bitcoin-core/guix.sigs#1 is merged, no?
The PR doesn’t have to be merged, you should be able to just fetch and checkout the branch you want to verify against.
I have done a trial run through the attestation / verify steps as well. https://github.com/bitcoin-core/guix.sigs/pull/3.
Note that for anyone attesting/verifying on macOS, the invocations of find
and xargs
used in the attestation script are not currently compatible with BSD find
or xargs
. I just swapped them out for gfind
and gxargs
for now.
146+ (
147+ cd "$outdir"
148+ find . -type f -printf '%P\0' | env LC_ALL=C sort -z | xargs -r0 sha256sum >> "$outsigdir"/SHA256SUMS
149+ )
150+ echo "${outname}: Signing SHA256SUMS to produce SHA256SUMS.asc"
151+ gpg --detach-sign --local-user "$gpg_key_name" --output "$outsigdir"/SHA256SUMS.asc "$outsigdir"/SHA256SUMS
--armor
); otherwise use the .sig extension (this doesn’t really matter, but it’s a convention).
Personally I’m not a big fan of using the word “sign” as it’s been used to refer to both codesigning and GPG signing.
I tend to agree, “gitian signature” has always been somewhat ambiguous and confusing, attestation is a better word.
FWIW: I have a multi-step flow:
gitian-sign
with -p true
to generate .assert
files but bypass the actual signing.assert
files to signing machineI’m not sure how far it is reasonable to accommodate my specific way of working (though there may be more people doing this, it’s good to be careful with signing keys). But it would be nice to be able to skip the gpg
invocation in guix-attest
.
For checking gitian signatures, I have been using my own script for this as well, see: bitcoin-core/bitcoin-maintainer-tools#71 bitcoin-core/bitcoin-maintainer-tools#90 . I think I can straightforwardly adapt it to Guix attestations when needed.
Pushed 5da0e361b8b5a6d730a244e774c6810946619229 -> 0c238fd118742d6c059dc114b5cc0747adf7f6c5
laanwj: Please let me know if the NO_SIGN
flag is enough for your workflow!
My attestations: https://github.com/dongcarl/guix.sigs/commit/fb313a28a57dc7020309b1521cef0b783d3ca81f
laanwj: Please let me know if the NO_SIGN flag is enough for your workflow!
Yes seems perfect!
16+
17+################
18+# Required non-builtin commands should be invokable
19+################
20+
21+check_tools cat env basename mkdir xargs find gpg
gpg
check can be skipped in case of NO_SIGN
?
85+IFS='=' read -r gpg_key_name signer_name <<< "$SIGNER"
86+if [ -z "${signer_name}" ]; then
87+ signer_name="$gpg_key_name"
88+fi
89+
90+if ! gpg --dry-run --list-secret-keys "${gpg_key_name}" >/dev/null 2>&1; then
I succeeded in generating attestations and signing them externally after removing the above checks and
0GUIX_SIGS_REPO=/home/guest/guix.sigs SIGNER=laanwj NO_SIGN=1 contrib/guix/guix-attest
My only comment really is that having one attestation file per architecture means having to create a lot of signatures. I need to push the button on my external signer device for every one of them :smile:
Building 816c70c3cef2dde50436461f3fe43f8915840a26
EDIT: see attestation result https://github.com/bitcoin-core/guix.sigs/pull/5
Tested ACK 816c70c3cef2dde50436461f3fe43f8915840a26. I tried building, attesting, and verifying (as well as testing that verification fails with invalid signature).
As a follow-up, I think the output of guix-verify could be improved a bit (giving a global success/fail output, and perhaps grouping the output by signer).
Tested 816c70c3cef2dde50436461f3fe43f8915840a26: https://github.com/bitcoin-core/guix.sigs/pull/6
Tested both contrib/guix/guix-attest
and contrib/guix/guix-verify
.
Actually, I think it would be better if the signed data contained a stronger commitment to the source code it was built from than just a truncated git commit id.
Attestations are really claims by the builder that certain input source code corresponds to the resulting build output. As the gpg-signed SHA256SUMS file doesn’t actually commit the source code, someone could try to grind git commit ids to a collide with honest source code, get signers to accidentally guix attest the malicious source code, and then distribute the malicious build output along with a claim it was built from honest source code.
A possibility would be including the dist-archive source tgz in every SHA256SUMS file.
dist-archive/$SIGNER/SHA256SUMS
like we do now?
@dongcarl You can’t modify the SHA256SUMS without invalidating its signatures. The signatures are per-SHA256SUMS-file, so you can mix and match different SHA256SUMS files, but you can’t mix and match lines within one file.
I’m not talking about a malicious signer. I’m talking about for example someone creating a PR with a hidden backdoor (which never gets merged or even reviewed) that leads to a collision in the short git commit id with honest code, and then they get honest signers to produce an attested guix build for that. They can then take the dist-archive SHA256SUMS + honest sigs on it from the good source code, and the x86_64 SHA256SUMS file + its (honestly created) sigs on the malicious code.
My point is: a guix attestation isn’t and shouldn’t be interpreted as the builder/attester vouching for the code they are building - we have the review process for that. It is purely a statement that particular source code (good or bad) corresponds to particular binaries, and in order to do so with cryptographic assurances, the SHA256SUMS file (or whatever is signed) needs to commit to both the input and the output of the build process.
They can then take the dist-archive SHA256SUMS + honest sigs on it from the good source code, and the x86_64 SHA256SUMS file + its (honestly created) sigs on the malicious code.
Okay I see… And if the malicious person combines them, they can make it seem like the honest signer is producing malicious code… Am I understanding that right?
So, if you’d want to do this exactly, I think you’d want to have a build process that first creates the dist-archive, and then afterwards builds the binaries, using just the dist-archive output as input (rather than the source tree you were working on).
Perhaps something for later, as you obviously trust the guix build scripts themselves not to do anything crazy here.
Pushed 816c70c3cef2dde50436461f3fe43f8915840a26 -> 7cd57f3ac308ba296842289542b15e902f105964
Please see commit messages for more explanations.
Signatures up here: https://github.com/dongcarl/guix.sigs/tree/2021-04-PR21462/7cd57f3ac308
142+
143+echo "Attesting to build outputs for version: '${VERSION}'"
144+echo ""
145+
146+# MAIN LOGIC: Loop through each output for VERSION and attest to output in
147+# GUIX_SIGS_REPO as SIGNERif attestation does not exist
8dd3c4a7ce9ac744668517a365cf8757713e7e7a:
0# GUIX_SIGS_REPO as SIGNER, if attestation does not exist
160- files="$(find . -type f)"
161+
162+ if [ -e inputs.SHA256SUMS ]; then
163+ echo "${outname}: Including existent input SHA256SUMS"
164+ cat inputs.SHA256SUMS >> "$outsigdir"/SHA256SUMS
165+ fi
dist-archive
does not have an inputs.SHA256SUMS
… Right now, we attest to the bitcoin repo’s git-archive in distsrc-archive
, but I think perhaps it only makes sense to attest to it in the context of it being inputs to the host-specific outputs. When we add codesignatures, similarly it only makes sense to attest to the detached-sigs repo’s git-archive in the context of it being inputs to the host-specific codesigned outputs. Will make a change so that we don’t attest to dist-archive
directly.
Concept ACK 7cd57f3ac308ba296842289542b15e902f105964 🍠
Signature:
0-----BEGIN PGP SIGNED MESSAGE-----
1Hash: SHA512
2
3Concept ACK 7cd57f3ac308ba296842289542b15e902f105964 🍠
4-----BEGIN PGP SIGNATURE-----
5
6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
7pUiWMwv+MSUhxaO+wyNQ7iSyL1e3PrBcw5kLsXZDz8aWT27W8ZMJLoArJWD6K10p
8o5QHYUJSg9HL/4QOQ+g+VCt6fdA2ktjpeKsrKfoivgMwfV5ZO2UowUHazuaxzi/k
9oAR+xOLaWpsuKqvwSEsV9n0E53A7a5E/6jj5O2U9Nt2QFStRCW82q5Sm6cApy/mn
10wTrvHQn4cqFqe+Io2WKnIvLFP8V/blggXRbGynm8+v1PBGyVTXoBP/CVbklc7JNj
11Wl2hcY2Fzn0LfWgqRagtAlOTH/xxwbvPm/6PMfOqJg0u2Y4/e6KojTuFBYEQrXM4
12vrjI3rRqjzg6fMa3miSZAwfknCIQJbDX1u7QIie4cqDolVM0HyGZizFxIr3m6hsc
13VQ0Wu+eCrHzB3K2UdI5lo4Nn8O+quCICmue5d9Iix1obNdxCR4Q915EMWIejjkkR
1445e2IOwJOT0ADQy3Drd2X6CQAHZTHJGtaoPecFR6DRTUE2uKHTYiKLEEb4QYJHBC
151B6vN1+j
16=bEwp
17-----END PGP SIGNATURE-----
Timestamp of file with hash bc7b8ef6e6110dba1bb1148d42a8626cc8670590bd75fcef192668f241327364 -
🕵️ @practicalswift has been requested to review this pull request as specified in the REVIEWERS file.
While files are being output to $OUTDIR, it will be under
${DISTSRC}/output, and only when everything is done, will
${DISTSRC}/output be moved to the actual $OUTDIR.
This makes it so that a Ctrl-C in the middle of a build is less likely
to result in a partially-constructed $OUTDIR. In fact, if I understand
correctly, if $OUTDIR and $DISTSRC reside on the same filesystem, the
move (rename) is likely atomic.
Also, since the "working $OUTDIR" is under ${DISTSRC}/output, it will be
cleaned properly by the guix-clean script.
At build/codesigning-time, hash build inputs and output the digest to
${OUTDIR}/inputs.SHA256SUMS, which gets included in the final SHA256SUMS
constructed by guix-attest.
Example final SHA256SUMS:
ee832d2a35b7701bff581dea05a536118b118e3ad0a587a2855b6ee8cd6fba20 inputs/bitcoin-78199266af7b.tar.gz
ca765e70a0c12866dd63c0be228b675278a26329e5f8f5b5c52fd09200fedf21 bitcoin-78199266af7b-powerpc64le-linux-gnu-debug.tar.gz
dae95327d7f2c324e2728c4b73627be6cb2c0d2f2e5bea940d1d5e6463939327 bitcoin-78199266af7b-powerpc64le-linux-gnu.tar.gz
We already attest to the relevant dist-archive in inputs.SHA256SUMS,
which is recorded at build-time.
We use a SKIPATTEST.TAG file to indicate output directories which do not
require attestation (much like the CACHEDIR.TAG specification).
Generally, it's better to have build scripts declare properties of
directories instead of introducing name-based special cases in attest
scripts since build scripts have a more detailed context of what is
going on.
Pushed 7cd57f3ac308ba296842289542b15e902f105964 -> feda2c8e3180cb983c35976d4440cea23a155b7f
As always, guix.sigs are up at: https://github.com/dongcarl/guix.sigs/tree/2021-04-PR21462/feda2c8e3180
Sometimes GPG connects to the wrong agent... or you don't have your
smartcard handy...
Pushed feda2c8e31..d420e5c1c0:
guix.sigs up at: https://github.com/dongcarl/guix.sigs/tree/2021-04-PR21462/d420e5c1c015
Tested ACK I get the same output.
0for x in *; do diff -du $x/dongcarl/SHA256SUMS $x/laanwj/SHA256SUMS; done
Would it be useful to have a concatenated SHA256SUMS (with all files) as well? I mean, depending on how we’re going to do the distribution on the website and torrent.
I guess if we’re redesigning this it makes sense to have the two match up, not sign a different file with the ‘distribution signing key’ anymore but the same one (or forego my distribution signing key completely, just collect the attestations).
Or is the idea is to start using a subdirectory per platform there (each with its own SHA256SUMS) too? In this case, having inputs/bitcoin-d420e5c1c015.tar.gz
in every one might not be practical, it implies having to duplicate the tarball . Maybe ../bitcoin-d420e5c1c015.tar.gz
then have the tarball in the top-level directory?
Or is the idea is to start using a subdirectory per platform there (each with its own SHA256SUMS) too? In this case, having
inputs/bitcoin-d420e5c1c015.tar.gz
in every one might not be practical, it implies having to duplicate the tarball .
Hmmm, are you talking about for the webserver? I think it can be done using hard/symlinks at the FS level, or just using virtualized paths at the HTTP level.
Wondering what particular user-flow you have in mind :-)
Code review and tested ACK d420e5c1c015f58d07aca4d6a805086488f74d03
Wondering what particular user-flow you have in mind :-)
After discussion on IRC: let’s leave this for another PR.
164+ (
165+ cd "$outdir"
166+
167+ if [ -e inputs.SHA256SUMS ]; then
168+ echo "${outname}: Including existent input SHA256SUMS"
169+ cat inputs.SHA256SUMS >> "$outsigdir"/SHA256SUMS
GUIX_SIGS_REPO
is a relative path like ../guix.sigs
.
170+ fi
171+
172+ echo "${outname}: Hashing build outputs to produce SHA256SUMS"
173+ files="$(find -L . -type f ! -iname '*.SHA256SUMS')"
174+ if [ -n "$files" ]; then
175+ cut -c3- <<< "$files" | env LC_ALL=C sort | xargs sha256sum >> "$outsigdir"/SHA256SUMS
shasum -a 256
or the user has to make an alias or brew install coreutils
shasum -a 256
produce identical output to sha256sum
?
dongcarl
DrahtBot
hebasto
fanquake
sipa
RonSherfey
laanwj
Emzy
MarcoFalke
Sjors
Labels
Build system
Scripts and tools
Milestone
22.0