Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions .github/workflows/ci-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ jobs:
archive_dir="$RUNNER_TEMP/n2api-tested-image-${{ matrix.suffix }}"
mkdir -p "$archive_dir"
docker image inspect --format '{{.Id}}' "$LOCAL_IMAGE" \
> "$archive_dir/config-digest"
> "$archive_dir/image-id"
docker save "$LOCAL_IMAGE" | gzip -1 > "$archive_dir/image.tar.gz"
sha256sum "$archive_dir/image.tar.gz" > "$archive_dir/image.tar.gz.sha256"

Expand Down Expand Up @@ -761,18 +761,18 @@ jobs:
archive_dir="$RUNNER_TEMP/n2api-tested-image-${{ matrix.suffix }}"
cd "$archive_dir"
sha256sum --check image.tar.gz.sha256
expected_config_digest="$(tr -d '[:space:]' < config-digest)"
if [[ ! "$expected_config_digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "Invalid tested image config digest" >&2
expected_image_id="$(tr -d '[:space:]' < image-id)"
if [[ ! "$expected_image_id" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "Invalid tested image ID" >&2
exit 1
fi
gzip -dc image.tar.gz | docker load
actual_config_digest="$(docker image inspect --format '{{.Id}}' "$LOCAL_IMAGE")"
if [ "$actual_config_digest" != "$expected_config_digest" ]; then
echo "Downloaded image does not match the tested config digest" >&2
actual_image_id="$(docker image inspect --format '{{.Id}}' "$LOCAL_IMAGE")"
if [ "$actual_image_id" != "$expected_image_id" ]; then
echo "Downloaded image does not match the tested image ID" >&2
exit 1
fi
echo "LOCAL_CONFIG_DIGEST=$actual_config_digest" >> "$GITHUB_ENV"
echo "LOCAL_IMAGE_ID=$actual_image_id" >> "$GITHUB_ENV"

- name: Login to GitHub Container Registry
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4
Expand Down Expand Up @@ -801,21 +801,23 @@ jobs:
docker push "$platform_ref"
fi

platform_digest="$(digest_for "$platform_ref")"
if [[ ! "$platform_digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "Could not resolve the pushed manifest digest for $platform_ref" >&2
exit 1
fi

remote_config_digest="$(
docker buildx imagetools inspect --raw "$platform_ref" \
| jq -r '.config.digest // empty'
)"
if [ "$remote_config_digest" != "$LOCAL_CONFIG_DIGEST" ]; then
# Docker image stores expose either config or manifest digests as image IDs.
if [ "$remote_config_digest" != "$LOCAL_IMAGE_ID" ] &&
[ "$platform_digest" != "$LOCAL_IMAGE_ID" ]; then
echo "$platform_ref does not match the image that passed the smoke test" >&2
exit 1
fi

platform_digest="$(digest_for "$platform_ref")"
if [[ ! "$platform_digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "Could not resolve the pushed manifest digest for $platform_ref" >&2
exit 1
fi

mkdir -p "$RUNNER_TEMP/n2api-digests"
printf '%s\n' "$platform_digest" > "$RUNNER_TEMP/n2api-digests/${{ matrix.suffix }}"

Expand Down
35 changes: 35 additions & 0 deletions dev/ci/test-security-policy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,41 @@ extract_run() {
script { sub(/^ /, ""); print }
' "$1"
}
extract_run "$workflow" 'Push tested platform image' |
sed 's/${{ matrix.suffix }}/amd64/g' > "$work_dir/publish-platform.sh"
mkdir "$work_dir/platform-bin"
cat <<'DOCKER' > "$work_dir/platform-bin/docker"
#!/usr/bin/env bash
set -euo pipefail
[[ "$1 $2 $3" == "buildx imagetools inspect" ]] || exit 1
if [[ "$*" == *--raw* ]]; then
jq -cn --arg digest "$N2API_TEST_CONFIG_DIGEST" '{config:{digest:$digest}}'
else
printf 'Digest: %s\n' "$N2API_TEST_MANIFEST_DIGEST"
fi
DOCKER
chmod +x "$work_dir/platform-bin/docker"
config_id="sha256:$(printf 'a%.0s' {1..64})"
manifest_id="sha256:$(printf 'b%.0s' {1..64})"
publish_platform() {
env PATH="$work_dir/platform-bin:$PATH" RUNNER_TEMP="$work_dir" \
REGISTRY=ghcr.io IMAGE_NAME=knowsky404/n2api SHORT_SHA=example \
LOCAL_IMAGE_ID="$1" \
N2API_TEST_CONFIG_DIGEST="$config_id" \
N2API_TEST_MANIFEST_DIGEST="${2:-$manifest_id}" \
bash "$work_dir/publish-platform.sh"
}
publish_platform "$config_id" >/dev/null
publish_platform "$manifest_id" >/dev/null
if publish_platform "sha256:$(printf 'c%.0s' {1..64})" >/dev/null 2>&1; then
echo "platform publication unexpectedly accepted an unrelated image ID" >&2
exit 1
fi
if publish_platform "$config_id" sha256:invalid >/dev/null 2>&1; then
echo "platform publication unexpectedly accepted an invalid manifest digest" >&2
exit 1
fi

extract_run "$release_workflow" 'Resolve release inputs' > "$work_dir/resolve-release.sh"
mkdir "$work_dir/release-bin"
cat <<'DOCKER' > "$work_dir/release-bin/docker"
Expand Down
27 changes: 27 additions & 0 deletions docs/specs/2026-11-09-release-image-identity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Release Image Identity Compatibility

## Evidence and scope

Release run 42580798250 built and smoke-tested both architectures, then failed
publication because the exported Docker image ID equalled the remote manifest
digest rather than its config digest. Docker image-store implementations can
expose either identity. The workflow incorrectly named and compared every local
ID as a config digest.

## Acceptance criteria

- Keep checksum verification and the exported/loaded local image ID comparison.
- Accept a published platform only when its config digest or manifest digest
equals that exact tested local ID.
- Reject unrelated image IDs and malformed manifest digests.
- Preserve existing immutable platform tags and all smoke, provenance, SBOM,
vulnerability, and stable-promotion gates.

## Implementation plan

1. Add mock-driven coverage to the existing extracted workflow security tests:
config IDs, manifest IDs, unrelated IDs, and invalid manifest digests.
2. Rename the archive identity and variables to image ID, resolve and validate
the remote manifest digest, and compare both supported identities.
3. Run focused checks and the required managed development check, then review,
commit, and deliver through the normal PR workflow before retrying release.
Loading