Skip to content

Patches - #13626

Merged
samuelkarp merged 10 commits into
containerd:mainfrom
samuelkarp:june-18-combined-main
Jun 18, 2026
Merged

Patches#13626
samuelkarp merged 10 commits into
containerd:mainfrom
samuelkarp:june-18-combined-main

Conversation

@samuelkarp

Copy link
Copy Markdown
Member

These have already been reviewed and tested in the private fork.

Security Updates

chrishenzie and others added 10 commits May 16, 2026 01:04
openUserFile now stats the opened file, refuses anything that is not a
regular file, and wraps the returned fs.File so reads are capped at
maxUserFileBytes (10 MiB). All callers of openUserFile read either
etc/passwd or etc/group; both are regular files on real systems, well
under the cap.

The cap and the regular-file check together bound parser memory use
when reading user-database files of unexpected shape or size.

Adds tests for the cap and for the non-regular file rejection. The cap
test covers three boundary points: a small pad (trailing entry parsed),
a pad placing the entry's last byte exactly on the cap (still parsed),
and a pad past the cap (read returns an "exceeds" error).

Assisted-by: Antigravity
Signed-off-by: Chris Henzie <[email protected]>
Google-Bug-Id: 508657842
Signed-off-by: Samuel Karp <[email protected]>
Filter out any annotations on the checkpointed container matching
`cdi.k8s.io/` or exactly `cdi.k8s.io` during restore to prevent
unauthorized device restoration. When an annotation is denied, a warning
log is generated.

Tested by:
* Unit tests for exact matching, prefix boundaries, and metadata merging
* Complete CRI integration and checkpoint restore suite

Assisted-by: Antigravity
Signed-off-by: Samuel Karp <[email protected]>
Image config labels are copied onto the container by both the CRI
plugin (BuildLabels) and the client's WithImageConfigLabels option
used by `ctr run`. Labels in the containerd.io/* namespace are
interpreted by containerd itself and labels in the io.cri-containerd*
namespace are interpreted by the CRI plugin. An image config is not a
trusted source for labels in either namespace.

Skip labels in both reserved namespaces when copying labels from an
image config to a container, and warn about each label skipped: an
image that tries to set them may be attempting to alter containerd
behavior. Oversized image labels are already skipped this way by
the CRI plugin.

Labels set explicitly by clients, for example via `ctr run --label`
or in the CRI request, are unaffected.

Verified with the CRI plugin and with `ctr run` against an image
whose config carries labels like these: the labels are no longer
present on the created container and a warning is logged for each.

Assisted-by: Claude Code
Signed-off-by: Ben Cressey <[email protected]>
Signed-off-by: Samuel Karp <[email protected]>
The CRI checkpoint restore path unpacked checkpoint archive/OCI image content
directly into the container's persistent state directory and read files such as
container.log back from it with a symlink-following copy. Checkpoint content is
externally provided, so make restore more defensive about what it unpacks and
how it reads those files back.

Behavior changes:

- Only unpack regular files and directories from the checkpoint archive.

- Unpack checkpoint content into a dedicated <state>/ctrd-restore
  subdirectory created fresh rather than into the state dir itself, so
  checkpoint content cannot collide with containerd's own files (e.g.
  the "status" blob). Restore and cleanup operate on that subdir;
  cleanup is now a single RemoveAll of it.

Signed-off-by: Brian Goff <[email protected]>
@k8s-ci-robot

Copy link
Copy Markdown

Adding label do-not-merge/contains-merge-commits because PR contains merge commits, which are not allowed in this repository.
Use git rebase to reapply your commits on top of the target branch. Detailed instructions for doing so can be found here.

Details

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-sigs/prow repository.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR applies a set of security hardening patches across containerd’s OCI spec helpers, label handling, and CRI checkpoint/restore flows, aligned with the CVE advisories referenced in the PR description.

Changes:

  • Harden user/group database file reads in pkg/oci by rejecting non-regular files and enforcing a maximum read size, with new tests.
  • Introduce a reserved label namespace check in pkg/labels, and use it to prevent copying reserved image-config labels into containers (CRI and client paths), with tests.
  • Harden CRI checkpoint import/restore by confining extracted content to a dedicated subdirectory, filtering unsafe archive entries, and avoiding symlink-following reads for restored/copied files, with new tests and script updates.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/oci/spec_opts.go Wraps /etc/passwd//etc/group opens to reject non-regular sources and cap reads.
pkg/oci/spec_opts_user_bounds_test.go Adds tests for read caps and non-regular-file rejection.
pkg/labels/validate.go Adds IsReserved helper for reserved label namespaces.
pkg/labels/validate_test.go Adds unit coverage for IsReserved.
pkg/labels/labels.go Defines reserved label namespace prefixes.
internal/cri/util/util.go Skips reserved image-config labels when building container labels.
internal/cri/util/util_test.go Updates label-building tests for reserved label filtering.
internal/cri/server/container_start.go Restores checkpoints from confined restore dir and simplifies cleanup to remove the confined dir.
internal/cri/server/container_checkpoint_linux.go Hardens checkpoint import/restore: tar entry filtering, confined restore dir, no-symlink copy, directory safety validation, annotation filtering.
internal/cri/server/container_checkpoint_linux_test.go Adds tests for copyNoFollow, tar entry filtering, dir safety validation, and annotation filtering.
internal/cri/labels/labels.go Reuses the shared CRI reserved prefix constant from pkg/labels.
contrib/checkpoint/checkpoint-restore-cri-test.sh Updates the CRI checkpoint/restore test script to exercise CDI annotation filtering and improve cleanup robustness.
client/container_opts.go Filters reserved image-config labels during WithImageConfigLabels, with warnings.
client/container_opts_test.go Adds unit test ensuring reserved image-config labels are not copied.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Jun 18, 2026
@samuelkarp
samuelkarp enabled auto-merge June 18, 2026 22:02
@samuelkarp
samuelkarp disabled auto-merge June 18, 2026 22:35
@samuelkarp
samuelkarp merged commit 5558f3a into containerd:main Jun 18, 2026
82 of 90 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

8 participants