-
Notifications
You must be signed in to change notification settings - Fork 107
Description
The distribution-spec v1.1.1 defines the behavior of the Docker-Content-Digest header for pulling manifests as follows:
The
Docker-Content-Digestheader, if present on the response, returns the canonical digest of the uploaded blob which MAY differ from the provided digest.
If the digest does differ, it MAY be the case that the hashing algorithms used do not match.
See Content Digests apdx-3 for information on how to detect the hashing algorithm in use.
Most clients MAY ignore the value, but if it is used, the client MUST verify the value matches the returned manifest.
If the<reference>part of a manifest request is a digest, clients SHOULD verify the returned manifest matches this digest.
This means that a registry may accept a HEAD or GET request with a digest using sha512, yet return a Docker-Content-Digest header computed with canonical digest algorithm sha256. Currently, oras-go v2 does not support this scenario and fails validation if the algorithms do not match.
We see two potential solutions:
- If the algorithm used in the
Docker-Content-Digestheader differs from the one in the request, simply ignore the header for digest verification. - If the response includes content, validate it using the algorithm specified in the
Docker-Content-Digestheader. This approach introduces extra compute cost in addition to the validation between the content and the requested digest.