Verifying Open Source Packages: From Checksums to GPG Signatures
When downloading binaries or source archives from open source projects, the common practice is to “check the hash.” While this ensures the file wasn’t corrupted during transit, it does nothing to prove the file was actually produced by the legitimate maintainer.
For security-focused users and developers, verification should be a pipeline: moving from Integrity (Has the file changed?) to Authenticity (Who signed this?).
The Baseline: Integrity via Checksums
Checksums (hashes) are the first line of defense. They detect accidental corruption or naive tampering.
Common Commands
Depending on your OS, you’ll use different utilities to generate the hash of the downloaded file.
Linux (GNU Coreutils):
macOS:
The Flaw
If an attacker compromises the download server, they can replace both the binary AND the sha256sum.txt file. The hashes will match, but you are verifying a malicious file. This is why cryptographic signatures are required.
The Gold Standard: Authenticity via GPG
A GPG signature proves that the holder of a specific private key signed the file. Even if the server is compromised, the attacker cannot forge a signature without the private key.
Step-by-Step Verification
A. Acquire the Public Key
You cannot verify a signature without the maintainer’s public key. Warning: Downloading a key from the same server as the binary is a security risk. The most robust method is downloading a key file via a separate trusted channel and importing it.
B. Verify the Signature
Packages usually come with a detached signature file (e.g., package.tar.gz.asc for ASCII-armored text or package.tar.gz.sig for binary).
Interpreting the Result
You will likely see output like this:
Critical Warning: A “Good signature” only means that the file was signed by the private key corresponding to the public key you imported. If you imported a malicious key that claimed to be the developer’s, the signature will still be “Good.”
A “Good signature” is ONLY sufficient if you have verified the key’s fingerprint out-of-band (see Section 3).
The Trust Gap: Finding the Key
The hardest part of PGP is “Out-of-Band” verification. To be truly secure, you should verify the key’s fingerprint.
- Find the fingerprint on the official project website or the developer’s trusted profile.
- Compare it to the imported key:
If the fingerprints match, the key is authentic.
Real-World Examples
Example 1: LibreWolf (bsys6)
LibreWolf provides binaries with specific versioning (e.g., librewolf-152.0.6-1-linux-x86_64-package.tar.xz).
Workflow:
- Download the binary and the corresponding signature file.
- Get the public key from the official LibreWolf security channel.
- Run the verification:
Example 2: Restic
Restic provides signed releases to ensure the backup tool itself hasn’t been tampered with.
Workflow:
- Download the binary (e.g.,
restic_0.19.1_linux_amd64.bz2),SHA256SUMS, andSHA256SUMS.asc. - Import the Restic maintainer’s public key (Key ID:
91A6868BD3F7A907). - Execute the verification:
Restic also signs its Git tags. You can verify the tag signature directly:
Note: If the signature is valid, GPG will report “Good signature from fd0 (Alexander Neumann)”. Always cross-reference the key ID (91A6868BD3F7A907) with Restic’s official documentation to ensure you aren’t verifying against a spoofed key.
Developer’s Quick Reference
| Goal | Command | Note |
|---|---|---|
| Check SHA256 | sha256sum <file> | macOS: shasum -a 256 |
| Import Key | gpg --import <file> or gpg --recv-keys <ID> | Use hkps://keys.openpgp.org |
| Verify Sig | gpg --verify <sig> [file] | .asc (armored) or .sig (binary) |
| Check Fingerprint | gpg --fingerprint <ID> | Compare with official source |
| Export Public Key | gpg --export -a <ID> | For sharing your own key |