Skip to content

Commit 4b7372d

Browse files
authored
Merge pull request #672 from barakeinav1/reproducible-key-provider-build
Thanks for the careful diagnosis and the well-scoped fix — pinning APT_SNAPSHOT plus the rustup-init sha256 and exact toolchain patch closes off the three real drift channels for mr_enclave reproducibility, and the env-var plumbing through docker-compose makes it painless for downstream consumers to override. Appreciated!
2 parents 2e915bb + 864a988 commit 4b7372d

2 files changed

Lines changed: 47 additions & 6 deletions

File tree

key-provider-build/Dockerfile.key-provider

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,45 @@
33
# SPDX-License-Identifier: Apache-2.0
44
FROM gramineproject/gramine:1.9-jammy@sha256:84b3d222e0bd9ab941f0078a462af0dbc5518156b99b147c10a7b83722ac0c38
55

6-
RUN apt-get update && apt-get install -y \
7-
git=1:2.34.1-1ubuntu1.17 \
8-
build-essential=12.9ubuntu3 \
9-
&& rm -rf /var/lib/apt/lists/*
6+
# Pin Ubuntu apt sources to a fixed snapshot date so transitive dependencies
7+
# (e.g. libcurl3-gnutls, libc6) don't drift between builds. Without this,
8+
# Ubuntu point updates to packages pulled in by `build-essential` change the
9+
# bytes of files referenced by the Gramine manifest's trusted_files list,
10+
# which changes mr_enclave — breaking any attestation flow that pins to a
11+
# specific expected value.
12+
#
13+
# Each consumer should override APT_SNAPSHOT to the date that matches their
14+
# expected mr_enclave:
15+
#
16+
# docker build --build-arg APT_SNAPSHOT=YYYYMMDDT000000Z ...
17+
ARG APT_SNAPSHOT=20260423T000000Z
18+
RUN { \
19+
echo "deb https://snapshot.ubuntu.com/ubuntu/${APT_SNAPSHOT} jammy main universe restricted multiverse"; \
20+
echo "deb https://snapshot.ubuntu.com/ubuntu/${APT_SNAPSHOT} jammy-updates main universe restricted multiverse"; \
21+
echo "deb https://snapshot.ubuntu.com/ubuntu/${APT_SNAPSHOT} jammy-security main universe restricted multiverse"; \
22+
} > /etc/apt/sources.list \
23+
&& rm -rf /etc/apt/sources.list.d/* \
24+
&& apt-get update && apt-get install -y \
25+
git=1:2.34.1-1ubuntu1.17 \
26+
build-essential=12.9ubuntu3 \
27+
&& rm -rf /var/lib/apt/lists/*
1028

11-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.85 -y
29+
# Pin rustup-init by sha256 instead of `curl https://sh.rustup.rs | sh` so the
30+
# installer bytes are deterministic. Pin --default-toolchain to the exact patch
31+
# version (1.85 alone resolves to the latest 1.85.x at install time).
32+
#
33+
# To bump RUSTUP_VERSION, fetch the matching sha256 with:
34+
# curl -sf https://static.rust-lang.org/rustup/archive/<VERSION>/x86_64-unknown-linux-gnu/rustup-init.sha256
35+
ARG RUSTUP_VERSION=1.28.2
36+
ARG RUSTUP_INIT_SHA256=20a06e644b0d9bd2fbdbfd52d42540bdde820ea7df86e92e533c073da0cdd43c
37+
ARG RUST_TOOLCHAIN=1.85.1
38+
RUN curl --proto '=https' --tlsv1.2 -fsSL \
39+
"https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/x86_64-unknown-linux-gnu/rustup-init" \
40+
-o /tmp/rustup-init \
41+
&& echo "${RUSTUP_INIT_SHA256} /tmp/rustup-init" | sha256sum -c - \
42+
&& chmod +x /tmp/rustup-init \
43+
&& /tmp/rustup-init -y --default-toolchain "${RUST_TOOLCHAIN}" \
44+
&& rm /tmp/rustup-init
1245
ENV PATH="/root/.cargo/bin:${PATH}"
1346

1447
# Set environment variables

key-provider-build/docker-compose.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,21 @@ services:
2525
- "./sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf"
2626
- "aesmd:/var/run/aesmd/"
2727
network_mode: "host"
28-
28+
2929
gramine-sealing-key-provider:
3030
<<: *common-config
3131
container_name: gramine-sealing-key-provider
3232
build:
3333
context: .
3434
dockerfile: Dockerfile.key-provider
35+
# Defaults reproduce a canonical build; consumers that pin to a specific
36+
# mr_enclave (e.g. attestation flows) override these via environment
37+
# variables, e.g. `APT_SNAPSHOT=YYYYMMDDT000000Z ./run.sh`.
38+
args:
39+
APT_SNAPSHOT: ${APT_SNAPSHOT:-20260423T000000Z}
40+
RUSTUP_VERSION: ${RUSTUP_VERSION:-1.28.2}
41+
RUSTUP_INIT_SHA256: ${RUSTUP_INIT_SHA256:-20a06e644b0d9bd2fbdbfd52d42540bdde820ea7df86e92e533c073da0cdd43c}
42+
RUST_TOOLCHAIN: ${RUST_TOOLCHAIN:-1.85.1}
3543
privileged: true
3644
devices:
3745
- "/dev/sgx_enclave:/dev/sgx_enclave"

0 commit comments

Comments
 (0)