Skip to content

validate: check artifact manifests structurally instead of as images - #2408

Draft
RogerHYang wants to merge 1 commit into
google:mainfrom
RogerHYang:validate-skip-attestation-manifests
Draft

validate: check artifact manifests structurally instead of as images#2408
RogerHYang wants to merge 1 commit into
google:mainfrom
RogerHYang:validate-skip-attestation-manifests

Conversation

@RogerHYang

@RogerHYang RogerHYang commented Aug 14, 2026

Copy link
Copy Markdown

crane validate fails on any multi-arch image published by BuildKit with provenance/SBOM attestations enabled:

$ crane validate --fast --remote docker.io/arizephoenix/phoenix:version-20.2.0-nonroot
Error: validating children: failed to validate image Manifests[2](sha256:158c42…):
validating config: invalid ConfigFile.RootFS.Type: "" != "layers"

BuildKit attaches attestation manifests to the image index, and recent versions give them the OCI empty descriptor ({}) as their config. validate.Index validates every OCIManifestSchema1/DockerManifestSchema2 child as a container image, so the attestation's config fails the ConfigFile.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:

  • the computed-layer slices are appended only for 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 artifactType path surfaced that mutate.AppendManifests silently dropped IndexAddendum.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 descriptor artifactType validates 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 reports PASS.

@google-cla

google-cla Bot commented Aug 14, 2026

Copy link
Copy Markdown

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
RogerHYang force-pushed the validate-skip-attestation-manifests branch from 21ff288 to 622e62f Compare August 14, 2026 17:33
@RogerHYang RogerHYang changed the title validate: skip attestation manifests in index children validate: check artifact manifests structurally instead of as images Aug 14, 2026
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
RogerHYang force-pushed the validate-skip-attestation-manifests branch from 622e62f to 05ef061 Compare August 14, 2026 20:24
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.

1 participant