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

libimage: harden lookup by digest #1505

Merged

Conversation

vrothberg
Copy link
Member

@vrothberg vrothberg commented Jun 14, 2023

When looking up an image by digest, make sure that the entire repository
of the specified value is considered. Previously, both the repository
and the tag have been ignored and we looked for some image with a
matching digest.

As outlined in #1248, Docker stopped ignoring the repository with
version v20.10.20 (Oct '22) which is a compelling reason to do the same.

To be clear, previously something@digest would look for any image with
digest while something is entirely ignored. With this change, both
something and digest must match the image.

This change breaks two e2e tests in Podman CI which relied on the
previous behavior. There is a risk of breaking users but there is a
strong security argument to perform this change: if the repository does
not match the (previously) returned image, there is a fair chance of a
user error.

Fixes: #1248
Signed-off-by: Valentin Rothberg [email protected]

vrothberg added a commit to vrothberg/buildah that referenced this pull request Jun 14, 2023
@vrothberg
Copy link
Member Author

OK, this is clearly breaking the fedora@sha256:add2f2878b383c6527a4f692c18f4aca039e7f24f5b24df1a6808f2a95280bbd matching which we need to preserve.

@vrothberg
Copy link
Member Author

@vrothberg vrothberg force-pushed the bye-bye-digest-dance branch from e521403 to adf3807 Compare June 15, 2023 11:16
vrothberg added a commit to vrothberg/buildah that referenced this pull request Jun 15, 2023
@vrothberg vrothberg force-pushed the bye-bye-digest-dance branch from adf3807 to d82579a Compare June 15, 2023 11:36
vrothberg added a commit to vrothberg/buildah that referenced this pull request Jun 15, 2023
@vrothberg vrothberg force-pushed the bye-bye-digest-dance branch 3 times, most recently from dcefac6 to c8c9030 Compare June 15, 2023 12:51
vrothberg added a commit to vrothberg/buildah that referenced this pull request Jun 15, 2023
@vrothberg
Copy link
Member Author

@mtrmac, this is still WIP but I expect it to pass Buildah/Podman CI.

With the current changes, we'd match Docker's behavior (see #1248).

@vrothberg
Copy link
Member Author

Two test cases in Podman broke since they relied on the rather loose digest matching, see https://github.com/containers/podman/pull/18888/files#diff-748a695f7f517f8721b6b3b248f5bb31a5257caaba1f8275dcd43dbb51bb7ea5.

@vrothberg vrothberg force-pushed the bye-bye-digest-dance branch from c8c9030 to dabd8aa Compare June 16, 2023 07:15
@vrothberg vrothberg changed the title DO NOT MERGE: test dropping loose digest lookups libimage: harden lookup by digest Jun 16, 2023
@vrothberg
Copy link
Member Author

vrothberg commented Jun 16, 2023

@mtrmac @nalind @giuseppe @rhatdan @Luap99 PTAL

@containers/podman-maintainers PTAL as well since this change imposes a risk of breaking

vrothberg added a commit to vrothberg/buildah that referenced this pull request Jun 16, 2023
@vrothberg
Copy link
Member Author

libimage/normalize_test.go Outdated Show resolved Hide resolved
@mtrmac
Copy link
Contributor

mtrmac commented Jun 29, 2023

@vrothberg FWIW your comments suggest that there might be some changes that weren’t pushed to this PR so far.

Can you point out which? Apologies in case I missed something.

The last push I see is commit 403bda7 from Jun 27 10am, before my review around Jun 27 10pm.

And review comments like #1505 (comment) (“an entirely new set of tests for LookupImage”) suggest that you have made further changes since.

@vrothberg vrothberg force-pushed the bye-bye-digest-dance branch from 403bda7 to 111402b Compare June 30, 2023 08:07
@openshift-ci openshift-ci bot removed the lgtm label Jun 30, 2023
When looking up an image by digest, make sure that the entire repository
of the specified value is considered.  Previously, both the repository
and the tag have been ignored and we looked for _some_ image with a
matching digest.

As outlined in containers#1248, Docker stopped ignoring the repository with
version v20.10.20 (Oct '22) which is a compelling reason to do the same.

To be clear, previously `something@digest` would look for any image with
`digest` while `something` is entirely ignored.  With this change, both
`something` and `digest` must match the image.

This change breaks two e2e tests in Podman CI which relied on the
previous behavior.  There is a risk of breaking users but there is a
strong security argument to perform this change:  if the repository does
not match the (previously) returned issue, there is a fair chance of a
user error.

Fixes: containers#1248
Signed-off-by: Valentin Rothberg <[email protected]>
@vrothberg vrothberg force-pushed the bye-bye-digest-dance branch from 111402b to ffc7d8e Compare June 30, 2023 08:09
@vrothberg
Copy link
Member Author

vrothberg commented Jun 30, 2023

@mtrmac it's all up now.

PRs pass without further changes:

@vrothberg
Copy link
Member Author

@mtrmac OK with merging?

@vrothberg
Copy link
Member Author

Leaving breadcrumbs here as well: once this PR gets in, we need to backport it to the v0.55 branch, then cut a new .1 release and vendor that into the v4.6 branch in Podman and backport containers/podman#19092.

@vrothberg
Copy link
Member Author

@Luap99 @giuseppe, let's get this in.

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, vrothberg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Luap99
Copy link
Member

Luap99 commented Jul 11, 2023

Shouldn't we wait for a final ack from @mtrmac?

@vrothberg
Copy link
Member Author

vrothberg commented Jul 11, 2023

I am confident the changes are OK as is - for now. We can wait one more day or so but this PR is blocking backports at the moment.

@vrothberg
Copy link
Member Author

Friendly ping, @mtrmac. Apologies for being pushy; I know there's much on your table at the moment.

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

/lgtm

libimage/image.go Show resolved Hide resolved
libimage/runtime.go Show resolved Hide resolved
libimage/runtime.go Show resolved Hide resolved
@mtrmac
Copy link
Contributor

mtrmac commented Jul 12, 2023

/lgtm

@mtrmac
Copy link
Contributor

mtrmac commented Jul 12, 2023

(I have filed #1559 implementing some of the cleanups, so that the time I spent thinking about that pays off.)

@rhatdan
Copy link
Member

rhatdan commented Jul 13, 2023

/hold cancel

@openshift-merge-robot openshift-merge-robot merged commit 5271d40 into containers:main Jul 13, 2023
@vrothberg vrothberg deleted the bye-bye-digest-dance branch July 13, 2023 07:00
openshift-merge-robot added a commit that referenced this pull request Jul 14, 2023
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.

Decide what to do about :tag@digest changes in Docker
8 participants