Skip to content

Commit fd4569e

Browse files
committed
fix(os): require pinned host tool for aws pcr computation
drop the unpinned docker amazonlinux:2023 + dnf fallback from assemble.sh: the computed PCRs feed measurement.aws.cbor -> sha256sum.txt -> os_image_hash, i.e. the measurement the KMS and verifiers enforce, so only a version-pinned operator-installed nitro-tpm-pcr-compute may produce it.
1 parent a230584 commit fd4569e

1 file changed

Lines changed: 18 additions & 25 deletions

File tree

os/image/assemble.sh

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,12 @@ fi
429429
# os_image_hash = sha256(sha256sum.txt) is fixed for the release artifact.
430430
# prepare/deploy only *embed* this material; they must never recompute it.
431431
#
432-
# Prefer a host `nitro-tpm-pcr-compute` (Rust tool from aws/NitroTPM-Tools).
432+
# Requires a host `nitro-tpm-pcr-compute` (Rust tool from aws/NitroTPM-Tools,
433+
# install with --locked). No unpinned container fallback: this value ends up
434+
# in os_image_hash, so only a version-pinned operator-installed tool may
435+
# produce it.
433436
# Optional: NITRO_TPM_PCR_COMPUTE_BIN=/path/to/bin
434437
# Optional Secure Boot ESL inputs (PCR7): NITRO_TPM_PCR_PK/KEK/DB (.esl paths)
435-
# Fallback: Docker amazonlinux:2023 + aws-nitro-tpm-tools when host tool missing.
436438
HAVE_MEASUREMENT_AWS=0
437439
if [[ "$UKI_CREATED" = "1" ]]; then
438440
if [[ -z "${UKI_IMAGE:-}" || ! -f "${UKI_IMAGE}" ]]; then
@@ -445,41 +447,32 @@ if [[ "$UKI_CREATED" = "1" ]]; then
445447
fi
446448

447449
uki_abs=$(realpath "$UKI_IMAGE")
448-
uki_dir=$(dirname "$uki_abs")
449-
uki_base=$(basename "$uki_abs")
450450
pcr_compute_bin="${NITRO_TPM_PCR_COMPUTE_BIN:-}"
451451
if [[ -z "$pcr_compute_bin" ]] && command -v nitro-tpm-pcr-compute >/dev/null 2>&1; then
452452
pcr_compute_bin=$(command -v nitro-tpm-pcr-compute)
453453
fi
454454

455+
# No unpinned fallback here on purpose: the computed PCRs feed
456+
# measurement.aws.cbor -> sha256sum.txt -> os_image_hash, i.e. the
457+
# measurement the KMS and verifiers enforce. Only a version-pinned,
458+
# operator-installed tool may produce it.
455459
pcr_json=
456-
if [[ -n "$pcr_compute_bin" ]]; then
457-
echo "Generating AWS PCRs via host ${pcr_compute_bin}"
458-
pcr_args=(--image "$uki_abs")
459-
# Secure Boot variable stores (optional; affects PCR7)
460-
[[ -n "${NITRO_TPM_PCR_PK:-}" ]] && pcr_args+=(--PK "$NITRO_TPM_PCR_PK")
461-
[[ -n "${NITRO_TPM_PCR_KEK:-}" ]] && pcr_args+=(--KEK "$NITRO_TPM_PCR_KEK")
462-
[[ -n "${NITRO_TPM_PCR_DB:-}" ]] && pcr_args+=(--db "$NITRO_TPM_PCR_DB")
463-
pcr_json=$("$pcr_compute_bin" "${pcr_args[@]}") \
464-
|| { echo "Error: nitro-tpm-pcr-compute failed" >&2; exit 1; }
465-
elif command -v docker >/dev/null 2>&1; then
466-
echo "Generating AWS PCRs via docker amazonlinux:2023 (nitro-tpm-pcr-compute)"
467-
pcr_json=$(
468-
docker run --rm --platform linux/amd64 \
469-
-e UKI_BASENAME="$uki_base" \
470-
-v "$uki_dir":/artifacts:ro \
471-
amazonlinux:2023 \
472-
bash -lc 'dnf install -y aws-nitro-tpm-tools >/tmp/dnf.log && nitro-tpm-pcr-compute --image "/artifacts/$UKI_BASENAME"'
473-
) || { echo "Error: docker nitro-tpm-pcr-compute failed" >&2; exit 1; }
474-
else
460+
if [[ -z "$pcr_compute_bin" ]]; then
475461
echo "Error: cannot produce measurement.aws.cbor for UKI image." >&2
476-
echo "Install host tool (preferred):" >&2
462+
echo "Install the pinned host tool:" >&2
477463
echo " cargo install --git https://github.com/aws/NitroTPM-Tools --locked nitro-tpm-pcr-compute" >&2
478464
echo " # or set NITRO_TPM_PCR_COMPUTE_BIN=/path/to/nitro-tpm-pcr-compute" >&2
479-
echo "Or provide Docker for the amazonlinux:2023 fallback." >&2
480465
echo "measurement.aws.cbor must be fixed at assemble time for a stable os_image_hash." >&2
481466
exit 1
482467
fi
468+
echo "Generating AWS PCRs via host ${pcr_compute_bin}"
469+
pcr_args=(--image "$uki_abs")
470+
# Secure Boot variable stores (optional; affects PCR7)
471+
[[ -n "${NITRO_TPM_PCR_PK:-}" ]] && pcr_args+=(--PK "$NITRO_TPM_PCR_PK")
472+
[[ -n "${NITRO_TPM_PCR_KEK:-}" ]] && pcr_args+=(--KEK "$NITRO_TPM_PCR_KEK")
473+
[[ -n "${NITRO_TPM_PCR_DB:-}" ]] && pcr_args+=(--db "$NITRO_TPM_PCR_DB")
474+
pcr_json=$("$pcr_compute_bin" "${pcr_args[@]}") \
475+
|| { echo "Error: nitro-tpm-pcr-compute failed" >&2; exit 1; }
483476

484477
pcr4=$(jq -r '.Measurements.PCR4 // empty' <<<"$pcr_json")
485478
pcr7=$(jq -r '.Measurements.PCR7 // empty' <<<"$pcr_json")

0 commit comments

Comments
 (0)