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

Do not include image annotations when building spec #18542

Merged

Conversation

mheon
Copy link
Member

@mheon mheon commented May 11, 2023

These annotations can have security implications - crun, for example, allows rootless containers to preserve the user's groups through an annotation. We absolutely should not include annotations from an untrusted image off the internet by default.

We may consider whitelisting some annotations (e.g. the legacy WASM annotations), but given that there is now a more explicit way of specifying an image uses the WASM runtime in the OCI image spec, I'm just tearing this out entirely for now.

Security: annotations from images are no longer applied to containers.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mheon

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 11, 2023
@mheon
Copy link
Member Author

mheon commented May 11, 2023

@giuseppe @vrothberg @rhatdan PTAL

@mheon
Copy link
Member Author

mheon commented May 11, 2023

Fair, will add test after lunch.

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.

code itself LGTM

@mheon mheon force-pushed the remove_image_annotations branch 2 times, most recently from 2fe907e to 01c98d2 Compare May 11, 2023 18:45
@mheon
Copy link
Member Author

mheon commented May 11, 2023

Test added

@TomSweeneyRedHat
Copy link
Member

Code LGTM, tests are very red though.

These annotations can have security implications - crun, for
example, allows rootless containers to preserve the user's groups
through an annotation. We absolutely should not include
annotations from an untrusted image off the internet by default.

We may consider whitelisting some annotations (e.g. the legacy
WASM annotations), but given that there is now a more explicit
way of specifying an image uses the WASM runtime in the OCI image
spec, I'm just tearing this out entirely for now.

Signed-off-by: Matt Heon <[email protected]>
@mheon mheon force-pushed the remove_image_annotations branch from 01c98d2 to 2c0f404 Compare May 12, 2023 03:48
@mheon
Copy link
Member Author

mheon commented May 12, 2023

Tests should be going green, PTAL

@TomSweeneyRedHat
Copy link
Member

LGTM
and happy green test buttons.

@rhatdan
Copy link
Member

rhatdan commented May 13, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 13, 2023
@openshift-merge-robot openshift-merge-robot merged commit d989c63 into containers:main May 13, 2023
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

inspectData := inspect.InspectContainerToJSON()
Expect(inspectData).To(HaveLen(1))
Expect(inspectData[0].Config.Annotations).To(Not(HaveKey(annoName)))
Expect(inspectData[0].Config.Annotations).To(Not(HaveKey("testlabel")))
Copy link
Member

Choose a reason for hiding this comment

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

Mini nit: testlabel would still be added to .Config.Labels which we could test here as well

@mheon
Copy link
Member Author

mheon commented May 22, 2023

/cherry-pick v4.5

@openshift-cherrypick-robot
Copy link
Collaborator

@mheon: new pull request created: #18654

In response to this:

/cherry-pick v4.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

flouthoc added a commit to flouthoc/crun that referenced this pull request Jun 6, 2023
After containers/podman#18542 , podman does not
propagates annotations while running the image hence use `--platform
wasm/wasi`

Signed-off-by: Aditya R <[email protected]>
flouthoc added a commit to flouthoc/crun that referenced this pull request Jun 6, 2023
After containers/podman#18542 , podman does not
propagates annotations while running the image hence use `--platform
wasi/wasm`

Signed-off-by: Aditya R <[email protected]>
flouthoc added a commit to flouthoc/crun that referenced this pull request Jun 6, 2023
After containers/podman#18542 does not include image annotations
when building spec , podman does not propagates annotations while running the image hence
use `--platform wasi/wasm`.

Signed-off-by: Aditya R <[email protected]>
edsantiago added a commit to edsantiago/libpod that referenced this pull request Jun 26, 2023
Add new _prefetch helper for fetching and caching images.
Use it in a few places, most importantly 120-load.bats
where our teardown() now runs 'rmi -af'.

Reason: in containers#17911 we discovered that podman save + load do
not actually preserve the image: annotations and other metadata
are lost. This means that a test which runs after 120-load.bats
is operating on a different $IMAGE than a test which runs before.

This is not a problem except in very obscure corner cases, like
one fixed in containers#18542, but it seems irresponsible to just handwave
that issue away

The _prefetch function uses skopeo for fetching and saving
images, because skopeo preserves digests and metadata.

[Side note for posterity: I tried amending basic_setup() to
always rmi -a + prefetch, instead of the current images -a +
rmi unwanted ones. That slowed down system tests by 10 minutes,
presumably because loads are much slower than queries. I reverted
that change and am documenting it as a reminder of why we do things
the way we do.]

Signed-off-by: Ed Santiago <[email protected]>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Aug 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants