Skip to content

imagetools: reject manifest JSON passed as descriptor source#3755

Draft
thompson-shaun wants to merge 1 commit intodocker:masterfrom
thompson-shaun:sandbox/8b6c04f5
Draft

imagetools: reject manifest JSON passed as descriptor source#3755
thompson-shaun wants to merge 1 commit intodocker:masterfrom
thompson-shaun:sandbox/8b6c04f5

Conversation

@thompson-shaun
Copy link
Copy Markdown
Collaborator

When a user pipes imagetools inspect --raw output into
imagetools create -f, the manifest/manifest-list JSON was silently
accepted as a descriptor (it starts with '{') but has no 'digest' or
'size' fields. This produced a zero-value descriptor that drove the
push to write 0 bytes and then call Commit() on an un-initialised
containerd pipe writer, causing a nil-pointer panic.

Validate that any JSON-encoded source has a non-empty 'digest' field
and return a clear error otherwise.

Add a table-driven unit test covering valid inputs and both Docker
manifest-list / OCI image-index rejection cases.

Fixes #2091

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Signed-off-by: Shaun Thompson 30006198+thompson-shaun@users.noreply.github.com

When a user pipes `imagetools inspect --raw` output into
`imagetools create -f`, the manifest/manifest-list JSON was silently
accepted as a descriptor (it starts with '{') but has no 'digest' or
'size' fields.  This produced a zero-value descriptor that drove the
push to write 0 bytes and then call Commit() on an un-initialised
containerd pipe writer, causing a nil-pointer panic.

Validate that any JSON-encoded source has a non-empty 'digest' field
and return a clear error otherwise.

Add a table-driven unit test covering valid inputs and both Docker
manifest-list / OCI image-index rejection cases.

Fixes docker#2091

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shaun Thompson <30006198+thompson-shaun@users.noreply.github.com>
@jsternberg
Copy link
Copy Markdown
Collaborator

I'm not sure this is the correct solution to this problem. I think the main issue is that this doesn't work with images that reference a media type of application/vnd.oci.image.index.v1+json. I'll try to take a look into this a bit further.

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.

panic in buildx imagetools create

2 participants