LearnSecurity and privacy

Reproducible builds

Why anyone can check that a Liana binary was built from the published source.

Reviewers read Liana's source code. You run something else: an executable of tens of megabytes, such as liana-16.0.exe, which a compiler made from that source and nobody reads.

Reviewing the source does not cover the binary

Between the source and your file sits a build: a machine, a compiler, libraries, and the person who runs them. If one of them is compromised, the binary can carry code that appears in no source file.

This has happened. Malware called XcodeGhost spread through modified installers of Xcode, Apple's developer tools. Developers who used them shipped iOS apps with malicious code they never wrote. reproducible-builds.org draws the lesson: "Recompiling these applications with a clean compiler would have made the problem easily visible."

A tampered Liana binary puts you in the case of a compromised computer. It can show you a receive address that is not yours.

A signature proves who published the file, not how it was built

Verify your download shows that your file is the one Wizardsardine published. The hash proves nobody altered your copy. The PGP signature proves Edouard Paris's key signed the list of hashes.

If the release machine was compromised, or a maintainer turned malicious, that signed list carries the hash of a poisoned file. Your check still prints Good signature. You need both checks: the signature for who published the file, a reproducible build for what it contains.

Four files on two axes: whether a hash and PGP signature prove who published the file, and whether a reproducible build ties its bytes to the public source.
A file from a compromised release machine still carries a good signature. Only a reproducible build ties the file to the source.

A reproducible build lets anyone compare the bytes

reproducible-builds.org gives the definition: "A build is reproducible if given the same source code, build environment and build instructions, any party can recreate bit-by-bit identical copies of all specified artifacts."

You no longer have to trust the release machine. Several people build the same release tag on their own computers and hash the results. If every hash matches, the binary comes from the public source. If one differs, do not trust the file until someone explains why.

Four independent builders build one public source tree at release tag v16.0 on their own machines. Their SHA-256 hashes of liana-16.0-noncodesigned.exe converge on one matching hash.
Matching hashes from independent machines prove the binary comes from the public source.

An ordinary build leaves traces of when and where it ran. As reproducible-builds.org puts it, "Timestamps make the biggest source of reproducibility issues." The GNU linker writes the time of linking into a Windows .exe unless told not to. Liana's Windows build tells it not to, with --no-insert-timestamp. Liana's release script also dates the files in its .tar.gz archives and in its macOS .dmg to the release commit, and sorts the files of each .tar.gz by name.

A reproducible build does not prove the source is honest

A backdoor written into the source comes out of every build, byte for byte. Public review of the source covers that risk.

Guix and Nix give every builder the same environment

The same source gives the same bytes only with the same compiler, libraries and options. Guix and Nix are functional package managers. Guix names each package directory after a hash of every input used to build it. Nix builds in isolation: "a build process will only find resources that have been declared explicitly as dependencies."

Liana's Linux build runs guix time-machine on one fixed Guix commit, so a builder gets the same compiler years later. The Nix build pins every input in flake.lock. The Guix container has no network access. The build script downloads the Rust libraries listed in Cargo.lock before the container starts.

Someone still compiles the compiler

Pinning the compiler leaves one question: who built that compiler? As bootstrappable.org puts it, "Compilers are often written in the language they are compiling." Rust is one of them. Nobody can audit an opaque binary, so bootstrappable builds shrink the binaries at the start of that chain.

Guix announced its Full-Source Bootstrap in April 2023, for x86_64 and i686 Linux:

  • A 256-byte program, hex0, turns hexadecimal text into bytes. Its source is commented hexadecimal, so a person can check it byte by byte. It was 357 bytes at the announcement. A second seed of 640 bytes, kaem-optional, runs the build commands.
  • hex0 builds the stage0-posix tools, each a little more capable, up to M2-Planet, a compiler for "a subset of the C language".
  • M2-Planet builds GNU Mes, a Scheme interpreter that comes with a C compiler.
  • Mes builds a patched TinyCC. That TinyCC builds a newer one, which builds GCC 2.95.3.
  • That old GCC builds newer ones up to the modern toolchain, then "a package graph of more than 22,000 nodes".

Guix builds Rust the same way, starting from mrustc, a Rust compiler written in C++.

A staircase of builds rising from hex0, the 256-byte seed drawn as a leaf, through stage0-posix, M2-Planet, GNU Mes, two TinyCC builds, GCC 2.95.3 and the modern toolchain to more than 22,000 packages, all resting on a precompiled 12 MiB GNU Guile.
Each step builds the next one, from a seed a person can read, on top of a precompiled Guile.

Some binaries stay outside the chain: the 12 MiB Guile that drives these first builds, four static tools that unpack it, 92 MiB of static tools that patch sources, and the kernel of the build machine. Guix can also download the tools pre-built from its build farm, which you then trust. You can refuse them and build the whole chain yourself. Bootstrap a release takes you there one stage at a time.

Bitcoin Core set the precedent

The Guix announcement names the Bitcoin community as one of the first to put bootstrappable builds into practice. Since version 22.0, Bitcoin Core builds its releases with Guix. Independent contributors publish their PGP-signed hash lists in the public guix.sigs repository. Bitcoin Core publishes a release only after six or more of them get matching results. Carl Dong's talk Bitcoin Build System Security, from Breaking Bitcoin 2019, is a short introduction to these builds.

How Liana builds each platform

One Linux machine builds every Liana release with contrib/release/release.sh:

PlatformRelease filesBuilt withBootstrappable
Linux, x86_64liana-16.0-x86_64-linux-gnu.tar.gz, liana-16.0-1_amd64.debGuixYes
macOS, Intel and Apple siliconliana-16.0-x86_64-apple-darwin.tar.gz, liana-16.0-aarch64-apple-darwin.tar.gz, liana-16.0-macos-noncodesigned.dmgNixC compilers only
Windowsliana-16.0-noncodesigned.exeNixC compilers only

The Linux build compiles with Guix's own Rust, so its chain goes down to the 256-byte seed. Nix cross-compiles macOS and Windows with the official Rust 1.88.0 binary, pinned by hash. macOS also needs Apple's Xcode_12.2.xip, which each builder downloads from Apple. The build compiles neither from source: Nix only edits the Rust binary so that it loads its libraries from the Nix store. Bootstrap a release lists the other binaries that these builds take.

contrib/release/release.sh builds the Linux files with Guix, bootstrappable down to a 256-byte seed, and the macOS and Windows files with Nix, from Rust 1.88.0 and Xcode_12.2.xip taken as is. Code signing then turns two noncodesigned twins into files only the key holder can produce.

Two code-signed release files are not in the table. liana-16.0-macos.dmg carries a macOS code signature from Edouard Paris's Apple Developer ID. liana-16.0.exe carries a Windows code signature from Wizardsardine, LDA. Only the holder of the signing keys can produce these bytes. You rebuild their noncodesigned twins instead. liana-16.0.exe is liana-16.0-noncodesigned.exe with a few header bytes changed and a signature appended. In Liana 16.0, signing changed seven bytes and appended 10,560 bytes.

Signed commits tie the source to its authors

A reproducible build says nothing about who wrote the source. Maintainers sign nearly every merge commit that brings changes into master. Wizardsardine's maintainer-tools repository lists the two keys it trusts for them. Edouard Paris signs the release tag, then the hash list.

Liana has no equivalent of guix.sigs. When you reproduce a Liana release, you are the independent builder. Reproduce a release walks you through the builds and the checks.

Next steps