Skip to content

fix: return DIGEST_INVALID for malformed manifest references - #5114

Merged
milosgajdos merged 1 commit into
distribution:mainfrom
perfloop-oss:perfloop-pr-open-ejv4qtvm0g
Nov 29, 2026
Merged

milosgajdos merged 1 commit into
distribution:mainfrom
perfloop-oss:perfloop-pr-open-ejv4qtvm0g

Conversation

@perfloop-agent

@perfloop-agent perfloop-agent commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Manifest uploads with a child digest of the wrong length or an unsupported algorithm currently return HTTP 500 with duplicate UNKNOWN errors. Return HTTP 400 DIGEST_INVALID for these inputs instead, matching the existing handling of malformed digest syntax.

In registry/handlers/manifests.go, handle the three go-digest validation errors together. Keep the accompanying MANIFEST_BLOB_UNKNOWN entries and leave other verification-error mappings unchanged. This changes response translation, not which references are checked: references excluded by validation configuration remain excluded.

Wrap parse errors in readlink in registry/storage/blobstore.go with "invalid digest in stored blob link" and retain the cause. A valid uploaded reference pointing to a damaged registry link then returns HTTP 500 UNKNOWN, rather than blaming the client with DIGEST_INVALID. Driver read errors remain unchanged.

The regression test in registry/handlers/api_test.go covers malformed syntax, invalid length, and an unsupported algorithm across OCI indexes, Docker manifest lists, OCI image manifests, and Docker schema-2 manifests. It checks the HTTP status and limits the returned error codes to DIGEST_INVALID and MANIFEST_BLOB_UNKNOWN, rejecting spurious UNKNOWN entries. A second HTTP test covers malformed stored links across the same media types; registry/storage/blobstore_test.go checks the wrapped cause.

The focused Go tests for manifest responses, link-error wrapping, tag lookups, enumeration, and manifest storage passed. Scoped golangci-lint validation reported no issues.

AI assisted with this change.

Case and evidence


Made by Perfloop. Human sponsor: Tomás Senart.

Comment thread registry/handlers/manifests.go Resolved
@milosgajdos

Copy link
Copy Markdown
Member

@perfloop-agent squash your commits, please

Manifest verification can return invalid-format, invalid-length, and
unsupported-algorithm digest errors. Map all three to DIGEST_INVALID so
malformed references receive HTTP 400 instead of duplicate UNKNOWN
errors and HTTP 500. Preserve the accompanying missing-reference errors.

Wrap parse errors from stored blob links with storage context and retain
their cause, keeping damaged registry metadata on the HTTP 500 path.
Cover all three validation errors across OCI indexes, Docker manifest
lists, OCI image manifests, and Docker schema-2 manifests, and check the
wrapped stored-link cause.

Signed-off-by: Perfloop Agent <[email protected]>
@perfloop
perfloop Bot force-pushed the perfloop-pr-open-ejv4qtvm0g branch from da7f8d0 to dc5b47f Compare November 29, 2026 17:25
@perfloop-agent

Copy link
Copy Markdown
Contributor Author

Squashed the pull request into one commit without changing the code or tests.

@milosgajdos
milosgajdos merged commit d575d3c into distribution:main Nov 29, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants