Skip to content

Make Docker-Content-Digest non-optional - #595

Merged
sudo-bmitch merged 1 commit into
opencontainers:mainfrom
syed:head-requests-digest
Feb 26, 2026
Merged

sudo-bmitch merged 1 commit into
opencontainers:mainfrom
syed:head-requests-digest

Conversation

@syed

@syed syed commented Jan 21, 2026 •

Copy link
Copy Markdown
Contributor

Based on the discussion on the call, we want to have Docker-Content-Digest as a required header when doing a HEAD on a reference. This fixes an issue where given a tag for a manifest, there is no way currently for the client to know which hashing algorithm was used when pushing

Comment thread spec.md Resolved

@tianon tianon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (non-binding, obviously)

@syed
syed force-pushed the head-requests-digest branch 5 times, most recently from 7253851 to 198bc28 Compare January 21, 2026 02:49

@sudo-bmitch sudo-bmitch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the goal from our conversation is to make it possible to verify the digest of a tag to attach referrers and pin references, I'm also looking at other parts of the spec. Specifically, in a few places we have:

The Docker-Content-Digest header, if present on the response, returns the canonical digest ...

Our usage of "canonical digest" references sha256, so I think the language there should be adjusted to reference the pushed digest when available. Though perhaps we want to save that change for once we have a way to push a tagged manifest with a different digest algorithm.

Comment thread spec.md Outdated
Comment on lines +213 to +214
A successful response SHOULD contain the digest of the uploaded blob or manifest in the header `Docker-Content-Digest`.
A successful response SHOULD contain the size in bytes of the uploaded blob or manifest in the header `Content-Length`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the community consider changing this to a MUST? It would only apply to newer versions of the spec, so if we did that, I'd also want an implementers note for clients warning that older versions of the spec did not require the header.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposed to changing it to a MUST

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about the language around the GET. I believe we should also change this to a MUST to be consistent

A GET request to an existing manifest URL MUST provide the expected manifest, with a response code that MUST be `200 OK`.
A successful response SHOULD contain the digest of the uploaded blob in the header `Docker-Content-Digest`.

The `Docker-Content-Digest` header, if present on the response, returns the canonical digest of the uploaded blob which MAY differ from the provided digest.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it would need to be changed throughout to be consistent. Lets get some other maintainers to weigh in before updating the PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think SHOULD is strong enough for the case where the client only expects sha256 default digests, but we need to explain the digest issue in the specification and how/why it MUST be there in the case where the digest is not, for any reason, already known by the client.

@mikebrow mikebrow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the purposes of documenting the issue outside the call..

The originally added text "These headers are OPTIONAL and clients SHOULD NOT depend on them." Appears to have been written in error and only meant to cover the version header and was not meant for the digest.

see suggested changes.

Comment thread spec.md Resolved
Comment thread spec.md Resolved
Comment thread spec.md Outdated
Comment on lines +213 to +214
A successful response SHOULD contain the digest of the uploaded blob or manifest in the header `Docker-Content-Digest`.
A successful response SHOULD contain the size in bytes of the uploaded blob or manifest in the header `Content-Length`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think SHOULD is strong enough for the case where the client only expects sha256 default digests, but we need to explain the digest issue in the specification and how/why it MUST be there in the case where the digest is not, for any reason, already known by the client.

@sudo-bmitch sudo-bmitch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the SHOULD -> MUST changes LGTM. I don't think we ever define "canonical digest" anywhere, perhaps we should have an entry in the definitions.

Comment thread spec.md Resolved
@syed

syed commented Jan 29, 2026

Copy link
Copy Markdown
Contributor Author

Overall, the SHOULD -> MUST changes LGTM. I don't think we ever define "canonical digest" anywhere, perhaps we should have an entry in the definitions.

I am thinking of removing the word canonical completely from the spec. We can add a note saying if no digest is specified or returned, assume sha256

Comment thread spec.md Resolved
dmcgowan
dmcgowan previously approved these changes Jan 29, 2026

@sudo-bmitch sudo-bmitch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One line needs to get added back. And we need to squash the commits. After that, it LGTM.

Comment thread spec.md Resolved
@sudo-bmitch

Copy link
Copy Markdown
Contributor

Thanks. Please squash the commits and I'll give it my 👍🏼 .

@syed
syed force-pushed the head-requests-digest branch from 08b1331 to 8056120 Compare January 29, 2026 20:19
@syed

syed commented Jan 29, 2026

Copy link
Copy Markdown
Contributor Author

squashed

@sudo-bmitch

Copy link
Copy Markdown
Contributor

squashed

Looks like the DCO signoff got lost (or maybe wasn't there). git rebase HEAD~1 --signoff

- Change Docker-Content-Digest from SHOULD to MUST for GET requests
  on manifests and blobs
- Change Docker-Content-Digest and Content-Length from SHOULD to MUST
  for HEAD requests on manifests and blobs
- Add implementers note for clients encountering older registries that
  may not include the header, suggesting sha256 as a reasonable default
- Remove "canonical" qualifier from digest language throughout spec
- Update legacy Docker support section to reference spec documentation

Signed-off-by: Syed <[email protected]>
@syed
syed force-pushed the head-requests-digest branch from 8056120 to c2519f1 Compare January 30, 2026 15:52
@syed

syed commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, must have gotten removed during rebase. Fixed now

@sudo-bmitch sudo-bmitch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@andaaron

andaaron commented Apr 19, 2026 •

Copy link
Copy Markdown

@sudo-bmitch

Copy link
Copy Markdown
Contributor

@andaaron my personal opinion is that clients should be verifying the digest that they requested on a blob pull, which is why we say https://github.com/opencontainers/distribution-spec/blob/main/spec.md?plain=1#L192:

Clients SHOULD verify that the response body matches the requested digest.

So I ignore the registry header, and depend on what I requested instead. This prevents some security vulnerabilities where a client requests one digest and the registry replies with a different one.

The big reason for this PR was that clients need to know the digest algorithm the registry associates with a manifest when pinning content, creating an artifact with a subject, and fetching artifacts with the referrers API. Without that, the workflow for changing the digest algorithm was broken. It also cleaned up other parts of the code for consistency which is what I think you're looking at.

If you're interested in cleaning up some edge cases around partial pulls, feel free to send over a PR for that. I think we all agree the header needs to match the digest of the entire blob, and not of the single partial body response. We had a similar issue on the chunked push that was clarified on https://github.com/opencontainers/distribution-spec/blob/main/spec.md?plain=1#L400:

The closing PUT request MUST include the <digest> of the whole blob (not the final chunk) as a query parameter.

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.

6 participants