Repository navigation
Description
👋 Haskell docker is exploring some alternative installation methods as https://downloads.haskell.org/debian/ is increasingly slow to be updated. This includes cabal-install which is currently installed via the debian package.
The direction we are thinking of going is directly installing ghc / cabal based on the releases on haskell.org. For example, we can download and GPG verify ghc releases.
Cabal on the other hand do not include GPG sig files that we can use for verification - https://downloads.haskell.org/~cabal/cabal-install-3.6.0.0/
May relate to #6616
Options
1. Cabal to provide GPG signature files
This would be ideal and is the simplest for us and the most secure. GHC has some doco about how this is done - https://gitlab.haskell.org/ghc/ghc/-/wikis/making-releases#sign-and-hash-the-release-artifacts . Perhaps Cabal releases can include a step like this?
2. Verify SHA256SUMS.sig
Cabal does include SHA256SUMS.sig + SHA256SUMS. The process would be something like:
- GPG verify
SHA256SUMS.sig - Fetch SHA from
SHA256SUMS. - Verify SHA256 of the release tar.
The current issue with this is I don't know what GPG key I need to verify SHA256SUMS.sig - https://downloads.haskell.org/~cabal/cabal-install-3.6.0.0/SHA256SUMS.sig.
$ gpg -vv SHA256SUMS.sig
gpg: WARNING: no command supplied. Trying to guess what you mean ...
# off=0 ctb=89 tag=2 hlen=3 plen=435
:signature packet: algo 1, keyid B3D9F94B8DCAE210
version 4, created 1631239102, md5len 0, sigclass 0x00
digest algo 10, begin of digest 39 ed
hashed subpkt 33 len 21 (issuer fpr v4 A970DF3AC3B9709706D74544B3D9F94B8DCAE210)
hashed subpkt 2 len 4 (sig created 2021-09-10)
subpkt 16 len 8 (issuer key ID B3D9F94B8DCAE210)
data: [3071 bits]
gpg: assuming signed data in 'SHA256SUMS'
gpg: Signature made Fri 10 Sep 2021 11:58:22 AEST
gpg: using RSA key A970DF3AC3B9709706D74544B3D9F94B8DCAE210
gpg: Can't check signature: No public key
I cannot find key B3D9F94B8DCAE210 anywhere. If this is the preferred option, can details of the key be given and can it be uploaded to some keysevers?
Activity
[-]Secure cabal installation method[/-][+]Secure cabal-install installation method[/+]Mikolaj commentedon Sep 13, 2021
@hasufell: doesn't ghcup provide that by chance?
hasufell commentedon Sep 13, 2021
I think the docker images maintainer has no interest in using ghcup.
GPG signing in ghcup has been discussed years ago, but no one really came up with a good proposal on how to integrate it:
gpgvia cli? What if it doesn't exist? What do we do on windows? How do we educate the user about it? Etc etcAnd lastly: you can already verify ghcup metadata (which contains the hashes of all tarballs) through hoops:
ghcup -s <file/http>://<uri> listIt's basically all there if you know what you're doing.
Mikolaj commentedon Sep 13, 2021
Oh, that's interesting. Let's brainstorm.
AlistairB commentedon Sep 13, 2021
As @hasufell notes ghcup does not do GPG verification. As noted
Not all tarballs provide valid signatures, cabal does not provide signatures for the release tars, which if resolved would allow for option 1 I have listed. My understanding of ghcup is that it checks the sha256 hash of the releases.Ideally we want to do the GPG (PGP) verification as official docker images are recommended to do PGP based verification. My understand is that this is stronger as it ties the verification to the user that publishes the artefacts and signature files. You can then choose to trust that user's key. (I've just learnt about all of this recently.. so don't have a deep understanding 😅)
Stack does provide GPG signature files and the current ghc / cabal debian packages also provides this. Which is why we don't want lose it if possible with a new installation approach.
Can we please assume that everyone is just aiming for the best technical solution? I was directly pushing for a ghcup based solution until @psftw highlighted the shortcomings around the GPG verification. I have no bias other than the best result for the official haskell docker users.
If you really want ghcup to be used in the images I would suggest looking into lack of GPG verification support. (FWIW I think ghcup is AWESOME and I use it :) )
Mikolaj commentedon Sep 13, 2021
Uhoh, I apparently made a faux pas. Apologies.
I, too, think that ghcup (and docker-haskell) is AWESOME. :)
hasufell commentedon Sep 13, 2021
Well, GPG is widely misunderstood and I think this misunderstanding is present here as well.
Again: GPG is useless if you don't verify the key. In the sense that it has similar guarantees as SSL, which you're already using successfully. It makes only sense if you trust the person and can manually verify that the key belongs to that person. For all other intents and purposes, GPG is in fact useless. Verifying that a key belongs to a person requires effort (e.g. calling them, sharing secrets, meeting in person, also see https://en.wikipedia.org/wiki/Key_signing_party).
Also, I've already described how you can use gpg today:
git log --show-signaturedata/metadata/ghcup-0.0.6.yamlto your Dockerfile repo and then have the Dockerfil copy it into the docker imageghcup -s file:///path/to/ghcup-0.0.6.yaml install ghc ...to only use the previously verified metadata fileBut... I mean... what's the point? How does the user know the image they download correspond to the Dockerfile that does the gpg verification? How does the user even know the gpg signature in the Dockerfile is correct/good? You have to sign the Dockerfile as well (or every git commit in your repo). And... does the user even trust you? How are they gonna establish trust with you and verify your key?
So you see... automatic verification isn't really possible.
emilypi commentedon Sep 13, 2021
@AlistairB just to update, I uploaded my key to OpenPGP (https://keys.openpgp.org/vks/v1/by-fingerprint/A970DF3AC3B9709706D74544B3D9F94B8DCAE210) and ubuntu's keyservers. I hope that helps
AlistairB commentedon Sep 14, 2021
Thanks @emilypi !
I can confirm this is working and I can do:
And it will successfully verify. Which means we can do option 2.
Although, options 1 is ideal as it is simpler (ahem for haskell docker, or others who care) and I think more secure as the final cabal-install binary is being gpg verified, not something in a chain.
Is it possible for you to execute these steps which is what ghc releases are doing?
I would be happy to help in any way that I can ie. add this info to the release checklist or making a release?
@hasufell you may be right, but the point is somewhat moot as the official docker images are recommended to gpg verify any downloaded artefacts as part of the docker build process. There is a review process when updating official images where they will call out stuff like this. Ideally we want to follow their best practice standards unless we have a good reason.
hasufell commentedon Sep 14, 2021
Yeah, I read it and it clearly states that sha256 sums are valid as well.
AlistairB commentedon Sep 14, 2021
True, they are considered acceptable but as a "Less Secure Alternate" option. I don't want to downgrade the security from the "Preferred" option if possible. The more secure, the more considered best practice by the official images the better I think.
hasufell commentedon Sep 14, 2021
So from ghcup perspective I think there's nothing to do. The releases are gpg signed, the metadata can be gpg verified too.
16 remaining items
ulysses4ever commentedon Aug 9, 2022
This issue is still locked. Should we pick a venue where Docker people will be able to engage (e.g. unlock the issue, open a new one, etc.)?
@fgaz is there a reason to believe managing SSH keys will be any easier than GPG ones? If not, perhaps, it's better to follow what Docker people already support and/or what GHC does? @bgamari do you have an advice on what cabal should do w.r.t. signing its binaries?
fgaz commentedon Aug 9, 2022
Yes: most developers already have an SSH key (and cabal contributors must have one - by virtue of the project being hosted on github), while not many have a GPG key. Other advantages are mentioned in the article I linked.
hasufell commentedon Aug 9, 2022
They are already signed: https://downloads.haskell.org/~cabal/cabal-install-3.8.1.0/SHA256SUMS.sig
I'm not sure who is the signer though.
Signing binaries is not required. Signing the hashes is enough.
ulysses4ever commentedon Aug 9, 2022
This has been discussed: the Docker people ask to do what GHC does, i.e. not (only) signing the hashes, but also the binaries.
Mikolaj commentedon Aug 9, 2022
I'm the signer and I've uploaded my key to keys.openpgp.org.
AlistairB commentedon Aug 9, 2022
Firstly, apologies for my part in the heated discussion 🙇
I wish to avoid rehashing the same arguments but I'll briefly state my current thoughts.
Providing more mechanisms to verify the cabal-install releases, such as signing the all the files in the release is just a good thing IMO. People can select which verification method they prefer and can continue to use
SHA256SUMS.sigif that is what they like.In the case of the haskell docker images, the docker official images people recommend a specific verification strategy which requires signing the release tars/artefacts themselves. This is what stack and GHC provide and we conform to this pattern.
Lacking this for cabal-install with some help from the official images people we have used an alternate method utilizing
SHA256SUMS.sigwhich is a bit more cumbersome. I will decline to discuss the merits of these 2 methods. I simply wish to follow their recommended practices. However, I think it is fair to say the current method we use is still pretty good, so if the decision is to keep doing things as is that is OK. Feel free to close the issue if so.If you want to provide these additional signature files, I believe the making a release wiki instructions need to be updated with something like the GHC release signing instructions. eg.
gpg --detach-sign SHA256SUMS->gpg --detach-sign *.tar.xz SHA256SUMS. I think a cabal maintainer will need to make those changes.@Mikolaj would you mind uploading your key to
keyserver.ubuntu.com. That is what we use in the haskell docker images. If I recall we had issues usingkeys.openpgp.orgin the past.ffaf1 commentedon Aug 10, 2022
hasufell commentedon Aug 10, 2022
Again: it does not make any sense cryptographically and there is nothing in the docker documentation suggesting this is necessary. Otherwise using package managers inside docker would violate their policy too.
AlistairB commentedon Aug 10, 2022
Ah awesome, thanks for the info. Indeed this is now available and working.
Mikolaj commentedon Aug 10, 2022
Is that really it? That's no burden at all. I have these files in a directory anyway, whenever I release. I've made the change to the wiki, please kindly verify.
AlistairB commentedon Aug 10, 2022
Looks good! You may as well include
.zipie.gpg --detach-sign *.tar.xz *.tar.gz *.zip SHA256SUMSfor good measure as stack and GHC sign these as well, although the haskell official images don't need the zip signed (none of the official images do the gpg verify step on windows. I'm guessing the gpg windows cli support is not great). Either way looks great thanks!Mikolaj commentedon Aug 10, 2022
Done. I guess we are going to use this for the next release. Anything else needed to complete the ticket?
AlistairB commentedon Aug 10, 2022
Nope that is it. Thank you! ❤️