Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: does this library ensures the integrity of an image downloaded by its digest ? #1885

Open
arbll opened this issue Feb 28, 2024 · 0 comments
Labels
question Further information is requested

Comments

@arbll
Copy link

arbll commented Feb 28, 2024

Hey Folks,

I am trying to understand if this library, when asked to grab an image by digest of its manifest/index in the following way:

registry, err := name.NewRegistry("malicious.io", name.StrictValidation)
if err != nil {
	return fmt.Errorf("could not create registry: %w", err)
}
digest := registry.Repo("org", "image").Digest("sha256:32a9fbff2c13d04a369cb9436ccb281068d6c5c11f6ee3880412eaf3564cde1e")
image, err := remote.Image(digest)
if err != nil {
	return fmt.Errorf("could not retrieve image: %w", err)
}

would, even if the registry answering is malicious, properly check that:

  • the initial index/manifest that gets returned has the right hash
  • subsequent manifest / config / layers have the right hash as referenced in previous index / manifest

The following piece of code makes me doubt:

if err == nil && mediaType == types.DockerManifestSchema1Signed {
// If we can parse the digest from the header, and it's a signed schema 1
// manifest, let's use that for the digest to appease older registries.
digest = contentDigest
}

It looks like answering a DockerManifestSchema1Signed could be abused by the remote repo to bypass the digest verification ?
I might be missing something tho

@arbll arbll added the question Further information is requested label Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant