Well-Typed and the Industrial Haskell Group are very happy to announce the beta release of the
hackage-security library, along with its integration in
cabal-install. The new security features of
hackage are now deployed on the central server hackage.haskell.org and there is a beta release of
cabal available. You can install it through
cabal install \ http://www.well-typed.com/hackage-security/Cabal-184.108.40.206.tar.gz \ http://www.well-typed.com/hackage-security/cabal-secure-beta.tar.gz \ http://www.well-typed.com/hackage-security/hackage-security-0.4.0.0.tar.gz \ http://www.well-typed.com/hackage-security/tar-0.4.2.2.tar.gz
This will install a
cabal-secure-beta binary which you can use alongside your normal installation of
For a more detailed discussion of the rationale behind this project, see the annoucement of the alpha release or the initial announcement of this project. We will also be giving a talk about the details at the upcoming Haskell Implementors Workshop. In the remainder of this blog post we will describe what’s available, right now.
What’s in it for you?
The Hackage server now does index signing. This means that if an attacker sits between you and Hackage and tries to feed you different packages than you think you are installing,
cabal will notice this and throw a security exception. Index signing provides no (or very limited) security against compromise of the central server itself, but allows clients to verify that what they are getting is indeed what is on the central server.
## (Untrusted) mirrors
A very important corollary of the previous point is that we can now have untrusted mirrors. Anyone can offer to mirror
hackage and we can gratefully accept these offers without having to trust those mirror operators. Whether we are downloading from the mirror or from the primary server, the new security features make it possible to verify that what we are downloading is what is on the primary server.
In practice this mean we can have mirrors at all, and we can use them fully automatically with no client side configuration required. This should give a huge boost to the reliability of Hackage; even AWS goes down from time to time but properly decentralised mirrors should mean there’s always a recent snapshot available.
On the client-side, the very first time
cabal updates from the primary server it also finds out what mirrors are available. On subsequent updates it will automatically make use of any of those mirrors: if it encounters a problem with one it will try another. Updates to the list of mirrors is also fully automatic.
For operating a mirror, we have extended the
hackage-mirror client (currently bundled in the
hackage-server package) so that it can be used to mirror a Hackage repository to a simple set of local files which can then be served by an ordinary HTTP server.
We already have one mirror available in time for the beta. The OSU Open Source Lab have very kindly agreed to host a Hackage mirror for the benefit of the Haskell community. This mirror is now live at http://ftp.osuosl.org/pub/hackage/, but we didn’t need to tell you that: (the beta release of) cabal will notice this automatically without any configuration on the part of the user thanks to hackage.haskell.org/mirrors.json.
Getting a mirror up and running is very easy, so if you would like to host a public Hackage mirror, then please do get in touch; during the beta period get in touch with us, or later on get in touch with the Hackage admins.
Hackage provides a
00-index.tar.gz resource which is a tarball containing the
.cabal files for all packages available on Hackage. It is this file that
cabal downloads when you call
cabal update, and that it uses during dependency resolution.
However, this file is quite large, which is why
cabal update can take a few seconds to complete. In fact at nearly 10Mb the index is now considerably larger than almost all package source tarballs.
As part of the security work we have had to extend this index with extra security metadata, making the file even larger. So we have also taken the opportunity to dramatically reduce download sizes by allowing clients to update this file incrementally. The index tarball is now extended in an append-only way. This means that once
cabal has downloaded the tarball once, on subsequent updates it can just download the little bit it doesn’t yet have. To avoid making existing clients download the new larger index file each time, the
00-index.tar.gz is kept as it always was and repositories supporting the new features additionally provide a
01-index.tar.gz. In future we could additionally provide a
.tar.xz variant and thereby keep the first-time update size to a minimum.
The append-only nature of the index has additional benefits; in effect, the index becomes a log of Hackage’s history. This log can be used for various purposes; for example, we can track how install plans for packages change over time. As another example, Herbert Valerio Riedel has been working on an “package-index wayback” feature for Cabal. This uses the index to recreate a past view of the package index for recovering now bit-rotted install-plans that were known to work in the past.
There are currently a few known issues that make
cabal update slower than it needs to be, even though it’s doing an incremental update. This will be addressed before the official release.
Host your own private repository
It has always been possible to host your own Hackage repository, either for private packages or as a mirror of the public collection, but it has not always been convenient.
There is the “smart” server in the form of the
hackage-server, which while relatively easy to build and run, isn’t as simple as just a bunch of files. There has also always been the option of a “dumb” server, in the form of a bunch of files in the right format hosted by an ordinary HTTP server. While the format is quite simple (reusing the standard
tar format), there have not been convenient tools for creating or managing these file based repositories.
As part of the security work we have made a simple command line tool to create and manage file based Hackage repositories, including all the necessary security metadata. This tool has been released as hackage-repo-tool on Hackage.
So whether you want a private mirror of the public packages, or a repository for your own private packages, or both, we hope these new tools will make that much more convenient. Currently documentation on how to use these tools is still somewhat lacking; this is something we will address after this beta release. Getting started is not difficult; there are some brief instructions in the reddit discussion, and feel free to talk to us on
#hackage on IRC or contact us directly at firstname.lastname@example.org if you need help.
As mentioned, we would like to invite you to install
cabal-secure-beta and start testing it; just use it as you would
cabal right now, and report any problems you may find on the
hackage-security issue tracker. Additionally, if you would like to host a public mirror for
Hackage, please contact us.
This release is primarily intended as an in-the-wild test of the infrastructure; there are still several details to be dealt with before we call this an official release.
The most important of these is proper key management. Much like, say, HTTPS, the chain of trust starts at a set of root keys. We have asked the Haskell.org committee to act as the root of trust and the committee has agreed in principle. The committee members will hold a number of the root keys themselves and the committee may also invite other organisations and individuals within the community to hold root keys. There are some policy details that remain to be reviewed and agreed. For example we need to decide on how many root keys to issue, what threshold number of keys be required to re-sign the root info, and agree policies for storing the root keys to keep them safe (for instance, mandate an air gap where the root key is never on a machine that is connected to the Internet). We will use the opportunity of ICFP (and the HIW talk) in a couple weeks time to present more details and get feedback.
If you would like to help with development, please take a look at the issue list and get in touch!