Skip to content

Pin every image input and check measurements.txt in CI - #205

Merged
adambalogh merged 2 commits into
mainfrom
og/measurements-ci
Dec 1, 2026
Merged

adambalogh merged 2 commits into
mainfrom
og/measurements-ci

Conversation

@adambalogh

Copy link
Copy Markdown
Contributor

Why

measurements.txt is meant to publish the PCRs of the image this repo builds, so anyone can check what code an enclave runs, and third-party operators can match it. Today:

  • It's stale: it was last updated in July (Serve with gunicorn (1 worker) and raise the OHTTP request cap to 20 MiB #134).
  • Nothing checks it: no CI step compares it with what the code builds.
  • The build drifts: the same commit measures differently over time.
    • FROM golang:1.24 and FROM python:3.12.10-slim-bookworm are tags, re-pushed with patch updates.
    • apt-get update && apt-get install takes whatever Debian bookworm serves that day, and bookworm gets security updates roughly weekly.

The existing reproducible-build workflow doesn't catch the drift because it builds twice back to back.

What

Every input is pinned (Dockerfile):

  • golang 1.24.13, python 3.12.10-slim-bookworm and uv 0.7.3 are pinned by digest. Verified that Kaniko 1.9.2 resolves name:tag@sha256:… in both FROM and COPY --from.
  • apt reads from snapshot.debian.org at 2026-11-24 (ARG DEBIAN_SNAPSHOT), with Check-Valid-Until=false since snapshot Release files expire. Tested: the same package set installs from that snapshot on the pinned base.
  • Taking Debian security fixes is now a deliberate bump of DEBIAN_SNAPSHOT (plus re-recording the PCRs).

scripts/measure-enclave.sh builds the EIF with nitro-cli 1.5.3 inside a pinned amazonlinux:2023 container against the Docker socket, and prints PCR0–2 in measurements.txt's shape. No Nitro hardware needed.

  • I built a test image with every nitro-cli release Amazon Linux offers (1.3.4–1.5.3): PCR0–2 are identical across all of them, and PCR1 matches the July measurements.txt. The enclave kernel is the same in each, so the hosts' nitro-cli version doesn't affect the measurements.
  • build-enclave labels the algorithm Sha512_48 { .. } where describe-enclaves says Sha384 { ... }. The script writes the label the file has always carried.

make measurements builds the image and writes measurements.txt; pass MEASUREMENTS=path to write elsewhere. The image target now depends on everything the Dockerfile copies in, so an edited source file rebuilds it.

Measurements workflow runs on PRs that touch an image input, on pushes to main, and on demand. It builds and measures the image and fails if PCR0–2 differ from measurements.txt. On a mismatch it prints the JSON to commit, puts it in the job summary, and uploads it as an artifact.

Docs: README and CLAUDE.md say how to reproduce and update the measurements. I removed the README line saying "your PCR values will differ", the opposite of what this repo promises.

Follow-ups this creates

  • measurements.txt in this PR: I can't build the real image in my sandbox without changing it (its proxy needs an extra CA certificate). So this PR's first CI run computes the PCRs, and I'll commit them here so the check passes.
  • Serve one request per loopback connection (gunicorn keepalive = 0) #204 (keepalive = 0): it changes the image, so whichever of the two merges second needs its measurements.txt re-recorded.
  • Required check: if you make this required in branch protection, drop the paths filter first. A required check that never runs blocks the PR.
  • Image change: the pins themselves change the image, so the next deploy runs new PCRs. The Debian packages are those of 2026-11-24, newer than what the last build pulled.

Testing

  • scripts/measure-enclave.sh run locally on a test image: it produces the EIF and the measurements JSON.
  • The pinned Debian snapshot installs the same package set on the pinned python base.
  • Kaniko 1.9.2 resolves the three digest-pinned references.
  • Workflow YAML parses; bash -n on the script.
  • Not run here: the full gateway image build, which is this PR's CI run.

Generated by Claude Code

measurements.txt is meant to publish the PCRs of the image this repo
builds, but nothing kept it current (last updated in July), and the
build could not keep it stable: golang:1.24 and the python base were
floating tags, and apt installed whatever Debian served that day. The
same commit measured differently from week to week.

- Dockerfile: base images pinned by digest (golang 1.24.13, python
  3.12.10-slim-bookworm, uv 0.7.3). apt reads from snapshot.debian.org
  at 2026-11-24 (DEBIAN_SNAPSHOT), with Check-Valid-Until off because
  snapshot Release files expire.
- scripts/measure-enclave.sh: builds the EIF with nitro-cli 1.5.3 in a
  pinned Amazon Linux container against the Docker socket and prints
  PCR0-2 in measurements.txt's shape. No Nitro hardware needed. PCR1
  is identical across nitro-cli 1.3.4-1.5.3 (and matches the July
  file), so the hosts' nitro-cli version does not matter.
- make measurements: builds the image and writes measurements.txt. The
  image target now depends on the files the Dockerfile copies in, so an
  edited source file triggers a rebuild.
- Measurements workflow: on PRs touching image inputs and on pushes to
  main, builds and measures the image and fails if PCR0-2 differ from
  measurements.txt, printing the JSON to commit.
- README/CLAUDE.md: how to reproduce and update the measurements.

measurements.txt itself is updated in a follow-up commit with the PCRs
CI computes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SQvDLzSf3RR7U4hG3QQD24
PCR0-2 as computed by the Measurements job on 85644e4. PCR1 is unchanged
from July, as expected: it depends only on nitro-cli's enclave kernel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SQvDLzSf3RR7U4hG3QQD24
@adambalogh
adambalogh marked this pull request as ready for review November 30, 2026 13:52
Copilot AI balanced review requested due to automatic review settings November 30, 2026 13:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@adambalogh
adambalogh merged commit f88cbc3 into main Dec 1, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants