Missing GIT tag/commit verification in Docker
The Docker build file clones a dependency from GitHub and checks out a tag without verifying its GPG signature or pinning a specific commit hash. An attacker who could tamper with the repository or its tags could get unverified code into the built image.
- Disclosed after under an hour
in: https://github.com/paragonie/airship/blob/master/docker/Dockerfile.airship#L14-L16
RUN git clone https://github.com/jedisct1/libsodium.git /tmp/sodium
WORKDIR /tmp/sodium
RUN git checkout tags/1.0.10
The code is fetched from Github without one of: 1. signature verification on relevant tag. (GPG) 2. specific commit. (SHA checksum) more information about this issue: https://www.qubes-os.org/doc/verifying-signatures/#verifying-qubes-code
fix: (implement 1 and/or 2)
-
verify GPG signature use:
``` git tag -v <tag name> ```to ensure the tag is signed.
Note: the tags in: https://github.com/jedisct1/libsodium/tags are signed, thus it's possible to implement this verification.
-
checkout known commit, such as:
git checkout fce6852d64339efa33c0ee4130b3107b888d6067
fce6852d64339efa33c0ee4130b3107b888d6067 is commit for tag 1.0.10 https://github.com/jedisct1/libsodium/commit/fce6852d64339efa33c0ee4130b3107b888d6067
Important note: The above operations need to be checked for errors (abort the script/don't proceed if error occurs)
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The build fetches a dependency by a mutable tag and never verifies a signature or pins an immutable commit hash.
Impact
An attacker able to alter the upstream repository or its tags could inject unverified code into the built image, though the text does not show this being exploited.
What the attacker needed
Control of upstream repo or tags
The fix
The build should verify the tag's GPG signature or check out a known commit hash, and abort if any of those checks fail.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a build downloads code from the internet, it should confirm the code is exactly what the author intended. Here the build trusts whatever the tag points to, so if someone changed the tag or the repository, the build would quietly use the altered code. Pinning a commit hash or checking a signature makes that tampering detectable.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.