validate: check artifact manifests structurally instead of as images - #2408
Draft
RogerHYang wants to merge 1 commit into
Draft
validate: check artifact manifests structurally instead of as images#2408RogerHYang wants to merge 1 commit into
RogerHYang wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
RogerHYang
force-pushed
the
validate-skip-attestation-manifests
branch
from
August 14, 2026 17:33
21ff288 to
622e62f
Compare
Index children that are not images (BuildKit SBOM/provenance attestations, or any manifest with an artifactType or non-image config) failed image invariants like ConfigFile.RootFS.Type == "layers". Validate their manifest, config blob, and layer blobs for existence and digest/size consistency instead. A child counts as an artifact when its index descriptor declares an artifactType, its manifest does, or its config media type is not an image config. Also fix two bounds bugs in validateLayers (computed-layer slices misaligned when non-layer media types are skipped, and a panic when the config has fewer diff_ids than the image has layers), and propagate IndexAddendum.ArtifactType in mutate.AppendManifests, which previously dropped it.
RogerHYang
force-pushed
the
validate-skip-attestation-manifests
branch
from
August 14, 2026 20:24
622e62f to
05ef061
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
crane validatefails on any multi-arch image published by BuildKit with provenance/SBOM attestations enabled:BuildKit attaches attestation manifests to the image index, and recent versions give them the OCI empty descriptor (
{}) as their config.validate.Indexvalidates everyOCIManifestSchema1/DockerManifestSchema2child as a container image, so the attestation's config fails theConfigFile.RootFS.Type == "layers"invariant and validation of an otherwise well-formed image reports failure.Rather than skipping these children, this change validates them as what they are. A child is treated as an artifact manifest when its index descriptor or manifest declares an
artifactType, or its config media type is not an image config (!IsConfig()). Artifact children get structural validation — manifest digest/size/content consistency, config blob existence and digest/size match, layer blob existence (Fast) or digest/size verification (full) — while image-only invariants (rootfs type, diff_ids, platform) are not applied. A registry copy with a missing or corrupt attestation blob still fails validation.Also fixes two bounds bugs in
validateLayers, found while testing with attestation-shaped images:IsLayer()media types but indexed by overall layer position, so an image with a leading non-layer blob panics or compares the wrong layers;cf.RootFS.DiffIDs[i]panics with index out of range when the config declares fewer diff_ids than the image has layers (previously reachable via any image whose config is missing rootfs data — now reported as a validation error).Testing the descriptor-level
artifactTypepath surfaced thatmutate.AppendManifestssilently droppedIndexAddendum.ArtifactType; it now propagates like the other descriptor overrides.Tests cover: an index with a BuildKit-style attestation child validates clean (full and
Fast); a child detected only via its descriptorartifactTypevalidates clean; a child with a tampered config blob fails on config digest; an image with layers but no diff_ids returns an error instead of panicking.Verified against a real BuildKit-published image:
crane validate --fast --remote docker.io/arizephoenix/phoenix:version-20.2.0-nonroot@sha256:b20fc0…now reportsPASS.