Check hardened Dockerfiles in CI.
Keep the Dockerfile you commit the one Rivex hardened, by checking it against its signed attestation on every push.
How it works.
A Rivex attestation is a signed statement that Rivex hardened a Dockerfile. It holds the SHA-256 digest of the hardened file, so a change of even one byte breaks the match. The verify page explains what it contains.
The workflow has four steps:
- Harden the Dockerfile and save the attestation next to it:
rivex harden --attestation-out attestation.sigstore.json -o Dockerfile Dockerfile. Add--sbom-out sbom.jsonto save the software bill of materials too. - Commit the Dockerfile and
attestation.sigstore.jsontogether. - Let CI run
rivex verify Dockerfileon every push. It fails when the Dockerfile is not the one Rivex hardened. - After an edit you meant to make, re-harden the Dockerfile and commit the new pair.
rivex verify runs on the CI machine. It needs no API key or secret, and it never contacts Rivex. Its only network access is to Sigstore's public trust root, which it uses to check the signature. It accepts only bundles signed by Rivex, and it checks that the signing record is in Sigstore's public log.
Success prints the run, the signing time and any rules a policy turned off:
Verified: Dockerfile is the file Rivex hardened.
Run: 0d1b8f0e-0000-4000-8000-000000000000
Signed: 2026-12-03 09:15:42 UTC
Rules turned off: none Add --no-disabled-rules to fail when a policy turned off any rule for that Dockerfile.
Exit codes.
0: the Dockerfile is the one Rivex hardened.1: the command was used wrongly, or a file can't be read.2: Sigstore's public trust root could not be fetched. Check the network and run the job again.5: the check failed. The message says why: the attestation is missing, was made before Rivex switched to standard attestations, is not signed by Rivex, or does not match the Dockerfile.
The attest input of the GitHub Action is a different thing: it asks GitHub for its own build provenance. It is separate from the Rivex attestation that rivex verify checks.
GitHub Actions.
Use the Rivex action in verify mode. It needs no api-key. Replace <release-commit-sha> with the commit SHA of the latest release on github.com/Rivex-Security/rivex-cli/releases, so the job runs a version you have looked at:
name: Check Dockerfile
on: [push]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- uses: Rivex-Security/rivex-cli@<release-commit-sha>
with:
verify: Dockerfile Add attestation: path/to/bundle.json when the bundle is not next to the Dockerfile, and no-disabled-rules: 'true' to refuse a Dockerfile hardened with rules turned off.
GitLab CI.
verify-dockerfile:
image: alpine:3.20
script:
- wget -q https://github.com/Rivex-Security/rivex-cli/releases/latest/download/rivex_linux_amd64 https://github.com/Rivex-Security/rivex-cli/releases/latest/download/checksums.txt
- grep ' rivex_linux_amd64$' checksums.txt | sha256sum -c -
- chmod +x rivex_linux_amd64 && mv rivex_linux_amd64 rivex
- ./rivex verify Dockerfile Bitbucket Pipelines.
pipelines:
default:
- step:
name: Check Dockerfile
image: alpine:3.20
script:
- wget -q https://github.com/Rivex-Security/rivex-cli/releases/latest/download/rivex_linux_amd64 https://github.com/Rivex-Security/rivex-cli/releases/latest/download/checksums.txt
- grep ' rivex_linux_amd64$' checksums.txt | sha256sum -c -
- chmod +x rivex_linux_amd64 && mv rivex_linux_amd64 rivex
- ./rivex verify Dockerfile Azure Pipelines.
steps:
- script: |
wget -q https://github.com/Rivex-Security/rivex-cli/releases/latest/download/rivex_linux_amd64 https://github.com/Rivex-Security/rivex-cli/releases/latest/download/checksums.txt
grep ' rivex_linux_amd64$' checksums.txt | sha256sum -c -
chmod +x rivex_linux_amd64 && mv rivex_linux_amd64 rivex
./rivex verify Dockerfile
displayName: 'Check Dockerfile' Jenkins.
pipeline {
agent {
docker { image 'alpine:3.20' }
}
stages {
stage('Check Dockerfile') {
steps {
sh '''
wget -q https://github.com/Rivex-Security/rivex-cli/releases/latest/download/rivex_linux_amd64 https://github.com/Rivex-Security/rivex-cli/releases/latest/download/checksums.txt
grep ' rivex_linux_amd64$' checksums.txt | sha256sum -c -
chmod +x rivex_linux_amd64 && mv rivex_linux_amd64 rivex
./rivex verify Dockerfile
'''
}
}
}
} Plain shell.
The same steps work in any CI system, or on your own machine:
wget -q https://github.com/Rivex-Security/rivex-cli/releases/latest/download/rivex_linux_amd64 https://github.com/Rivex-Security/rivex-cli/releases/latest/download/checksums.txt
grep ' rivex_linux_amd64$' checksums.txt | sha256sum -c -
chmod +x rivex_linux_amd64 && mv rivex_linux_amd64 rivex
./rivex verify Dockerfile Every job checks the download against checksums.txt before it runs the file. None pipes a download into a shell.
Keep the Dockerfile byte for byte.
The attestation matches the exact bytes of the file, so anything that rewrites the file breaks the check. Two things do:
- Git can convert line endings. Stop it for the Dockerfile with this line in
.gitattributes:
Dockerfile -text - On Windows, PowerShell's
>writes a file in another encoding. Save the hardened Dockerfile with-oor--output, not with>.
Check with another tool.
If you prefer a tool that Rivex did not make, check the attestation with cosign 2.4.2 or later. Save the Dockerfile as Dockerfile.hardened and run:
cosign verify-blob-attestation \
--bundle attestation.sigstore.json \
--type slsaprovenance1 \
--certificate-identity rivex-api@rivex-5616-prod.iam.gserviceaccount.com \
--certificate-oidc-issuer https://accounts.google.com \
Dockerfile.hardened The identity and the issuer must match exactly. The verify page explains each part of the command.