Version in base suite: 1.1.15+ds1-2 Base version: runc_1.1.15+ds1-2 Target version: runc_1.1.15+ds1-2+deb13u1 Base file: /srv/ftp-master.debian.org/ftp/pool/main/r/runc/runc_1.1.15+ds1-2.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/r/runc/runc_1.1.15+ds1-2+deb13u1.dsc changelog | 12 patches/CVE-2025-31133/0001-internal-sys-add-VerifyInode-helper.patch | 71 +++ patches/CVE-2025-31133/0002-libct-add-use-isDevNull-verifyDevNull.patch | 188 ++++++++++ patches/CVE-2025-31133/0003-libct-maskPaths-only-ignore-ENOENT-on-mount-dest.patch | 51 ++ patches/CVE-2025-31133/0004-libct-maskPaths-don-t-rely-on-ENOTDIR-for-mount.patch | 65 +++ patches/CVE-2025-52565/0001-internal-linux-add-GetPtyPeer-helper.patch | 49 ++ patches/CVE-2025-52565/0002-console-use-TIOCGPTPEER-and-harden-dev-console-mount.patch | 183 +++++++++ patches/CVE-2026-41579.patch | 85 ++++ patches/series | 13 9 files changed, 717 insertions(+) dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmpgivbekwd/runc_1.1.15+ds1-2.dsc: no acceptable signature found dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmpgivbekwd/runc_1.1.15+ds1-2+deb13u1.dsc: no acceptable signature found diff -Nru runc-1.1.15+ds1/debian/changelog runc-1.1.15+ds1/debian/changelog --- runc-1.1.15+ds1/debian/changelog 2025-02-08 16:15:23.000000000 +0000 +++ runc-1.1.15+ds1/debian/changelog 2026-11-13 14:09:26.000000000 +0000 @@ -1,3 +1,15 @@ +runc (1.1.15+ds1-2+deb13u1) trixie-security; urgency=high + + * Non-maintainer upload by the Security Team. + * Verify the /dev/null bind-mount source for masked paths + (CVE-2025-31133). + * Use TIOCGPTPEER for the console bind-mount source and harden + opening of /dev/console (CVE-2025-52565). + * Constrain pre-pivot /dev setup to directory descriptors + (CVE-2026-41579). + + -- Aron Xu Fri, 13 Nov 2026 22:09:26 +0800 + runc (1.1.15+ds1-2) unstable; urgency=medium * Team upload. diff -Nru runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0001-internal-sys-add-VerifyInode-helper.patch runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0001-internal-sys-add-VerifyInode-helper.patch --- runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0001-internal-sys-add-VerifyInode-helper.patch 1970-01-01 00:00:00.000000000 +0000 +++ runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0001-internal-sys-add-VerifyInode-helper.patch 2026-05-13 11:54:31.000000000 +0000 @@ -0,0 +1,71 @@ +From 7ff4c85be58defab86d8ad8b7efd5ae8fb72d783 Mon Sep 17 00:00:00 2001 +From: Aleksa Sarai +Date: Tue, 22 Jul 2025 16:23:28 +1000 +Subject: [PATCH] internal/sys: add VerifyInode helper + +This will be used for a few security patches in later patches in this +patchset. The need to verify what kind of inode we are operating on in a +race-free way turns out to be quite a common pattern... + +Signed-off-by: Aleksa Sarai + +Origin: backport, https://github.com/opencontainers/runc/commit/7ff4c85be58defab86d8ad8b7efd5ae8fb72d783 +Bug: https://github.com/opencontainers/runc/security/advisories/GHSA-9493-h29p-rfm2 +Forwarded: not-needed +--- + internal/sys/doc.go | 5 +++++ + internal/sys/verify_inode_unix.go | 30 ++++++++++++++++++++++++++++++ + 2 files changed, 35 insertions(+) + create mode 100644 internal/sys/doc.go + create mode 100644 internal/sys/verify_inode_unix.go + +diff --git a/internal/sys/doc.go b/internal/sys/doc.go +new file mode 100644 +index 00000000..075387f7 +--- /dev/null ++++ b/internal/sys/doc.go +@@ -0,0 +1,5 @@ ++// Package sys is an internal package that contains helper methods for dealing ++// with Linux that are more complicated than basic wrappers. Basic wrappers ++// usually belong in internal/linux. If you feel something belongs in ++// libcontainer/utils or libcontainer/system, it probably belongs here instead. ++package sys +diff --git a/internal/sys/verify_inode_unix.go b/internal/sys/verify_inode_unix.go +new file mode 100644 +index 00000000..d5019db5 +--- /dev/null ++++ b/internal/sys/verify_inode_unix.go +@@ -0,0 +1,30 @@ ++package sys ++ ++import ( ++ "fmt" ++ "os" ++ "runtime" ++ ++ "golang.org/x/sys/unix" ++) ++ ++// VerifyInodeFunc is the callback passed to [VerifyInode] to check if the ++// inode is the expected type (and on the correct filesystem type, in the case ++// of filesystem-specific inodes). ++type VerifyInodeFunc func(stat *unix.Stat_t, statfs *unix.Statfs_t) error ++ ++// VerifyInode verifies that the underlying inode for the given file matches an ++// expected inode type (possibly on a particular kind of filesystem). This is ++// mainly a wrapper around [VerifyInodeFunc]. ++func VerifyInode(file *os.File, checkFunc VerifyInodeFunc) error { ++ var stat unix.Stat_t ++ if err := unix.Fstat(int(file.Fd()), &stat); err != nil { ++ return fmt.Errorf("fstat %q: %w", file.Name(), err) ++ } ++ var statfs unix.Statfs_t ++ if err := unix.Fstatfs(int(file.Fd()), &statfs); err != nil { ++ return fmt.Errorf("fstatfs %q: %w", file.Name(), err) ++ } ++ runtime.KeepAlive(file) ++ return checkFunc(&stat, &statfs) ++} +-- +2.47.3 + diff -Nru runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0002-libct-add-use-isDevNull-verifyDevNull.patch runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0002-libct-add-use-isDevNull-verifyDevNull.patch --- runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0002-libct-add-use-isDevNull-verifyDevNull.patch 1970-01-01 00:00:00.000000000 +0000 +++ runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0002-libct-add-use-isDevNull-verifyDevNull.patch 2026-11-13 14:09:26.000000000 +0000 @@ -0,0 +1,188 @@ +From: Kir Kolyshkin +Date: Thu, 6 Mar 2025 08:19:45 -0800 +Subject: libct: add/use isDevNull, verifyDevNull + +The /dev/null in a container should not be trusted, because when /dev +is a bind mount, /dev/null is not created by runc itself. + +1. Add isDevNull which checks the fd minor/major and device type, + and verifyDevNull which does the stat and the check. + +2. Rewrite maskPath to open and check /dev/null, and use its fd to + perform mounts. Move the loop over the MaskPaths into the function, + and rename it to maskPaths. + +3. reOpenDevNull: use verifyDevNull and isDevNull. + +4. fixStdioPermissions: use isDevNull instead of stat. + +Adjusted for runc 1.1.15: upstream commit uses mountViaFds/mountSource +which do not exist. We instead open /dev/null with O_PATH, verify the +inode, and pass its /proc/self/fd/N path as the bind-mount source to +the existing mount() helper. + +Fixes: GHSA-9493-h29p-rfm2 CVE-2025-31133 +Co-authored-by: Rodrigo Campos +Signed-off-by: Kir Kolyshkin +Signed-off-by: Aleksa Sarai + +Origin: backport, https://github.com/opencontainers/runc/commit/11cf22d14e07a7071d9a541e08c0aedede355c21 +Bug: https://github.com/opencontainers/runc/security/advisories/GHSA-9493-h29p-rfm2 +Forwarded: not-needed +Reviewed-by: Aron Xu +--- + libcontainer/init_linux.go | 11 ++--- + libcontainer/rootfs_linux.go | 71 ++++++++++++++++++++++------- + libcontainer/standard_init_linux.go | 7 ++- + 3 files changed, 64 insertions(+), 25 deletions(-) + +--- a/libcontainer/init_linux.go ++++ b/libcontainer/init_linux.go +@@ -437,19 +437,16 @@ + // The ownership needs to match because it is created outside of the container and needs to be + // localized. + func fixStdioPermissions(u *user.ExecUser) error { +- var null unix.Stat_t +- if err := unix.Stat("/dev/null", &null); err != nil { +- return &os.PathError{Op: "stat", Path: "/dev/null", Err: err} +- } + for _, file := range []*os.File{os.Stdin, os.Stdout, os.Stderr} { + var s unix.Stat_t + if err := unix.Fstat(int(file.Fd()), &s); err != nil { + return &os.PathError{Op: "fstat", Path: file.Name(), Err: err} + } + +- // Skip chown if uid is already the one we want or any of the STDIO descriptors +- // were redirected to /dev/null. +- if int(s.Uid) == u.Uid || s.Rdev == null.Rdev { ++ // Skip chown if: ++ // - uid is already the one we want, or ++ // - fd is opened to /dev/null. ++ if int(s.Uid) == u.Uid || isDevNull(&s) { + continue + } + +--- a/libcontainer/rootfs_linux.go ++++ b/libcontainer/rootfs_linux.go +@@ -15,6 +15,7 @@ + securejoin "github.com/cyphar/filepath-securejoin" + "github.com/moby/sys/mountinfo" + "github.com/mrunalp/fileutils" ++ "github.com/opencontainers/runc/internal/sys" + "github.com/opencontainers/runc/libcontainer/cgroups" + "github.com/opencontainers/runc/libcontainer/cgroups/fs2" + "github.com/opencontainers/runc/libcontainer/configs" +@@ -324,7 +325,7 @@ + // Mask `/sys/fs/cgroup` to ensure it is read-only, even when `/sys` is mounted + // with `rbind,ro` (`runc spec --rootless` produces `rbind,ro` for `/sys`). + err = utils.WithProcfd(c.root, m.Destination, func(procfd string) error { +- return maskPath(procfd, c.label) ++ return maskPaths([]string{procfd}, c.label) + }) + } + return err +@@ -687,20 +688,20 @@ + // needs to be called after we chroot/pivot into the container's rootfs so that any + // symlinks are resolved locally. + func reOpenDevNull() error { +- var stat, devNullStat unix.Stat_t + file, err := os.OpenFile("/dev/null", os.O_RDWR, 0) + if err != nil { + return err + } +- defer file.Close() //nolint: errcheck +- if err := unix.Fstat(int(file.Fd()), &devNullStat); err != nil { +- return &os.PathError{Op: "fstat", Path: file.Name(), Err: err} ++ defer file.Close() ++ if err := verifyDevNull(file); err != nil { ++ return fmt.Errorf("can't reopen /dev/null: %w", err) + } + for fd := 0; fd < 3; fd++ { ++ var stat unix.Stat_t + if err := unix.Fstat(fd, &stat); err != nil { + return &os.PathError{Op: "fstat", Path: "fd " + strconv.Itoa(fd), Err: err} + } +- if stat.Rdev == devNullStat.Rdev { ++ if isDevNull(&stat) { + // Close and re-open the fd. + if err := unix.Dup3(int(file.Fd()), fd, 0); err != nil { + return &os.PathError{ +@@ -1052,17 +1053,53 @@ + return fmt.Errorf("unable to mount %s as readonly max retries reached", dest) + } + +-// maskPath masks the top of the specified path inside a container to avoid ++func isDevNull(st *unix.Stat_t) bool { ++ return st.Mode&unix.S_IFMT == unix.S_IFCHR && st.Rdev == unix.Mkdev(1, 3) ++} ++ ++func verifyDevNull(f *os.File) error { ++ return sys.VerifyInode(f, func(st *unix.Stat_t, _ *unix.Statfs_t) error { ++ if !isDevNull(st) { ++ return errors.New("container's /dev/null is invalid") ++ } ++ return nil ++ }) ++} ++ ++// maskPaths masks the top of the specified paths inside a container to avoid + // security issues from processes reading information from non-namespace aware + // mounts ( proc/kcore ). +-// For files, maskPath bind mounts /dev/null over the top of the specified path. +-// For directories, maskPath mounts read-only tmpfs over the top of the specified path. +-func maskPath(path string, mountLabel string) error { +- if err := mount("/dev/null", path, "", "", unix.MS_BIND, ""); err != nil && !errors.Is(err, os.ErrNotExist) { +- if errors.Is(err, unix.ENOTDIR) { +- return mount("tmpfs", path, "", "tmpfs", unix.MS_RDONLY, label.FormatMountLabel("", mountLabel)) +- } +- return err ++// For files, maskPaths bind mounts /dev/null over the top of the specified path. ++// For directories, maskPaths mounts read-only tmpfs over the top of the specified path. ++// ++// To avoid being tricked into bind-mounting an attacker-controlled inode in ++// place of the real /dev/null (CVE-2025-31133), we open /dev/null with O_PATH, ++// verify the inode via fstat/fstatfs, and then pass its /proc/self/fd/N path ++// as the bind-mount source. Even if the path "/dev/null" inside the container ++// is swapped after verification, the file descriptor still refers to the ++// verified inode. ++func maskPaths(paths []string, mountLabel string) error { ++ devNull, err := os.OpenFile("/dev/null", unix.O_PATH|unix.O_CLOEXEC, 0) ++ if err != nil { ++ return fmt.Errorf("can't mask paths: %w", err) ++ } ++ defer devNull.Close() ++ if err := verifyDevNull(devNull); err != nil { ++ return fmt.Errorf("can't mask paths: %w", err) ++ } ++ devNullFdPath := "/proc/self/fd/" + strconv.Itoa(int(devNull.Fd())) ++ ++ for _, path := range paths { ++ err := mount(devNullFdPath, path, "", "", unix.MS_BIND, "") ++ if err != nil && !errors.Is(err, os.ErrNotExist) { ++ if !errors.Is(err, unix.ENOTDIR) { ++ return fmt.Errorf("can't mask path %q: %w", path, err) ++ } ++ // Destination is a directory: bind mount a ro tmpfs over it. ++ if err := mount("tmpfs", path, "", "tmpfs", unix.MS_RDONLY, label.FormatMountLabel("", mountLabel)); err != nil { ++ return fmt.Errorf("can't mask dir %q: %w", path, err) ++ } ++ } + } + return nil + } +--- a/libcontainer/standard_init_linux.go ++++ b/libcontainer/standard_init_linux.go +@@ -141,10 +141,9 @@ + return fmt.Errorf("can't make %q read-only: %w", path, err) + } + } +- for _, path := range l.config.Config.MaskPaths { +- if err := maskPath(path, l.config.Config.MountLabel); err != nil { +- return fmt.Errorf("can't mask path %s: %w", path, err) +- } ++ ++ if err := maskPaths(l.config.Config.MaskPaths, l.config.Config.MountLabel); err != nil { ++ return err + } + pdeath, err := system.GetParentDeathSignal() + if err != nil { diff -Nru runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0003-libct-maskPaths-only-ignore-ENOENT-on-mount-dest.patch runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0003-libct-maskPaths-only-ignore-ENOENT-on-mount-dest.patch --- runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0003-libct-maskPaths-only-ignore-ENOENT-on-mount-dest.patch 1970-01-01 00:00:00.000000000 +0000 +++ runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0003-libct-maskPaths-only-ignore-ENOENT-on-mount-dest.patch 2026-05-13 12:04:02.000000000 +0000 @@ -0,0 +1,51 @@ +From: Kir Kolyshkin +Date: Mon, 21 Apr 2025 15:33:52 -0700 +Subject: libct: maskPaths: only ignore ENOENT on mount dest + +When mounting a path being masked, the /dev/null might disappear from +under us, and mount (even on an opened /dev/null file descriptor) will +return ENOENT, which we deliberately ignore, as there's no need to mask +non-existent paths. + +Let's open the destination path and ignore ENOENT during open, then +mount via the destination file descriptor, not ignoring ENOENT. + +Adjusted for runc 1.1.15 to match the local maskPaths() introduced in +the previous patch (mount() takes a procfd argument rather than going +through mountViaFds()). + +Reported-by: lifubang +Signed-off-by: Kir Kolyshkin + +Origin: backport, https://github.com/opencontainers/runc/commit/7ea4eb02e4f03acf4015b898de68718474e415c4 +Bug: https://github.com/opencontainers/runc/security/advisories/GHSA-9493-h29p-rfm2 +Forwarded: not-needed +--- + libcontainer/rootfs_linux.go | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +--- a/libcontainer/rootfs_linux.go ++++ b/libcontainer/rootfs_linux.go +@@ -1092,6 +1092,20 @@ func maskPaths(paths []string, mountLabel string) error { + for _, path := range paths { +- err := mount(devNullFdPath, path, "", "", unix.MS_BIND, "") +- if err != nil && !errors.Is(err, os.ErrNotExist) { ++ // Open the target path; skip if it doesn't exist. Unlike the ++ // previous version we only treat ENOENT on the destination ++ // open as "skip" -- ENOENT on the mount itself indicates a ++ // real problem (e.g. our /dev/null fd disappeared) and must ++ // not be silently ignored. ++ dstFh, err := os.OpenFile(path, unix.O_PATH|unix.O_CLOEXEC, 0) ++ if err != nil { ++ if errors.Is(err, os.ErrNotExist) { ++ continue ++ } ++ return fmt.Errorf("can't mask path %q: %w", path, err) ++ } ++ dstFdPath := "/proc/self/fd/" + strconv.Itoa(int(dstFh.Fd())) ++ err = mount(devNullFdPath, path, dstFdPath, "", unix.MS_BIND, "") ++ dstFh.Close() ++ if err != nil { + if !errors.Is(err, unix.ENOTDIR) { + return fmt.Errorf("can't mask path %q: %w", path, err) + } diff -Nru runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0004-libct-maskPaths-don-t-rely-on-ENOTDIR-for-mount.patch runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0004-libct-maskPaths-don-t-rely-on-ENOTDIR-for-mount.patch --- runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0004-libct-maskPaths-don-t-rely-on-ENOTDIR-for-mount.patch 1970-01-01 00:00:00.000000000 +0000 +++ runc-1.1.15+ds1/debian/patches/CVE-2025-31133/0004-libct-maskPaths-don-t-rely-on-ENOTDIR-for-mount.patch 2026-11-13 12:55:39.000000000 +0000 @@ -0,0 +1,65 @@ +From: Kir Kolyshkin +Date: Tue, 22 Apr 2025 18:02:13 -0700 +Subject: libct: maskPaths: don't rely on ENOTDIR for mount + +Currently, we rely on mount returning ENOTDIR when the destination is a +directory (and so mount tells us that the source is not), and fall back +to read-only tmpfs bind mount for such cases. + +Theoretically, ENOTDIR can also be returned in some other cases, +resulting in the wrong type of mount being used. + +Let's be more straightforward here -- call fstat on destination file +descriptor, and use the proper mount depending on whether it is a +directory. + +Adjusted for runc 1.1.15 to use the local maskPaths() introduced in the +previous patches. + +Reported-by: Rodrigo Campos +Signed-off-by: Kir Kolyshkin + +Origin: backport, https://github.com/opencontainers/runc/commit/faa67dfff6368f69772f6bc949d5950cdff77328 +Bug: https://github.com/opencontainers/runc/security/advisories/GHSA-9493-h29p-rfm2 +Forwarded: not-needed +--- + libcontainer/rootfs_linux.go | 23 +++++++++++++---------- + 1 file changed, 13 insertions(+), 10 deletions(-) + +--- a/libcontainer/rootfs_linux.go ++++ b/libcontainer/rootfs_linux.go +@@ -1102,17 +1102,25 @@ + } + return fmt.Errorf("can't mask path %q: %w", path, err) + } +- dstFdPath := "/proc/self/fd/" + strconv.Itoa(int(dstFh.Fd())) +- err = mount(devNullFdPath, path, dstFdPath, "", unix.MS_BIND, "") ++ st, err := dstFh.Stat() ++ if err != nil { ++ dstFh.Close() ++ return fmt.Errorf("can't mask path %q: %w", path, err) ++ } ++ var dstType string ++ if st.IsDir() { ++ // Destination is a directory: bind mount a ro tmpfs over it. ++ dstType = "dir" ++ err = mount("tmpfs", path, "", "tmpfs", unix.MS_RDONLY, label.FormatMountLabel("", mountLabel)) ++ } else { ++ // Destination is a file: mount it to /dev/null. ++ dstType = "path" ++ dstFdPath := "/proc/self/fd/" + strconv.Itoa(int(dstFh.Fd())) ++ err = mount(devNullFdPath, path, dstFdPath, "", unix.MS_BIND, "") ++ } + dstFh.Close() + if err != nil { +- if !errors.Is(err, unix.ENOTDIR) { +- return fmt.Errorf("can't mask path %q: %w", path, err) +- } +- // Destination is a directory: bind mount a ro tmpfs over it. +- if err := mount("tmpfs", path, "", "tmpfs", unix.MS_RDONLY, label.FormatMountLabel("", mountLabel)); err != nil { +- return fmt.Errorf("can't mask dir %q: %w", path, err) +- } ++ return fmt.Errorf("can't mask %s %q: %w", dstType, path, err) + } + } + return nil diff -Nru runc-1.1.15+ds1/debian/patches/CVE-2025-52565/0001-internal-linux-add-GetPtyPeer-helper.patch runc-1.1.15+ds1/debian/patches/CVE-2025-52565/0001-internal-linux-add-GetPtyPeer-helper.patch --- runc-1.1.15+ds1/debian/patches/CVE-2025-52565/0001-internal-linux-add-GetPtyPeer-helper.patch 1970-01-01 00:00:00.000000000 +0000 +++ runc-1.1.15+ds1/debian/patches/CVE-2025-52565/0001-internal-linux-add-GetPtyPeer-helper.patch 2026-05-13 12:06:47.000000000 +0000 @@ -0,0 +1,49 @@ +From: Aleksa Sarai +Date: Thu, 15 May 2025 16:12:21 +1000 +Subject: internal/linux: add GetPtyPeer (TIOCGPTPEER) helper + +Extracted from upstream commit cc08a1d4 ("console: use TIOCGPTPEER when +allocating peer PTY"). The original commit creates a new internal/linux +package containing this helper; this backport keeps that structure so +that the following console patch can simply import it. + +Signed-off-by: Aleksa Sarai + +Origin: backport, https://github.com/opencontainers/runc/commit/cc08a1d4f93e02760aa9b411883297f4e0080e5f +Bug: https://github.com/opencontainers/runc/security/advisories/GHSA-qw9x-cqr3-wc7r +Forwarded: not-needed +--- + internal/linux/linux.go | 27 +++++++++++++++++++++++++++ + 1 file changed, 27 insertions(+) + create mode 100644 internal/linux/linux.go + +--- /dev/null ++++ b/internal/linux/linux.go +@@ -0,0 +1,27 @@ ++package linux ++ ++import ( ++ "os" ++ ++ "golang.org/x/sys/unix" ++) ++ ++// GetPtyPeer is a wrapper for ioctl(TIOCGPTPEER). ++func GetPtyPeer(ptyFd uintptr, unsafePeerPath string, flags int) (*os.File, error) { ++ // Make sure O_NOCTTY is always set -- otherwise runc might accidentally ++ // gain it as a controlling terminal. O_CLOEXEC also needs to be set to ++ // make sure we don't leak the handle either. ++ flags |= unix.O_NOCTTY | unix.O_CLOEXEC ++ ++ // There is no nice wrapper for this kind of ioctl in unix. ++ peerFd, _, errno := unix.Syscall( ++ unix.SYS_IOCTL, ++ ptyFd, ++ uintptr(unix.TIOCGPTPEER), ++ uintptr(flags), ++ ) ++ if errno != 0 { ++ return nil, os.NewSyscallError("ioctl TIOCGPTPEER", errno) ++ } ++ return os.NewFile(peerFd, unsafePeerPath), nil ++} diff -Nru runc-1.1.15+ds1/debian/patches/CVE-2025-52565/0002-console-use-TIOCGPTPEER-and-harden-dev-console-mount.patch runc-1.1.15+ds1/debian/patches/CVE-2025-52565/0002-console-use-TIOCGPTPEER-and-harden-dev-console-mount.patch --- runc-1.1.15+ds1/debian/patches/CVE-2025-52565/0002-console-use-TIOCGPTPEER-and-harden-dev-console-mount.patch 1970-01-01 00:00:00.000000000 +0000 +++ runc-1.1.15+ds1/debian/patches/CVE-2025-52565/0002-console-use-TIOCGPTPEER-and-harden-dev-console-mount.patch 2026-11-13 14:09:26.000000000 +0000 @@ -0,0 +1,183 @@ +From: Aleksa Sarai +Date: Thu, 15 May 2025 16:12:21 +1000 +Subject: console: use TIOCGPTPEER + harden /dev/console bind-mount + +This is a combined backport of upstream commits cc08a1d4 ("console: use +TIOCGPTPEER when allocating peer PTY") and 0c3e7c1b ("console: avoid +trivial symlink attacks for /dev/console"), adapted for runc 1.1.15. + +The core fix for CVE-2025-52565 is to never resolve /dev/pts/$num inside +the (untrusted) container when allocating the peer PTY. The container +can replace that path with an attacker-controlled symlink so that runc +bind-mounts the symlink target on top of /dev/console. We instead use +the TIOCGPTPEER ioctl (Linux 4.13+, May 2017) which returns a file +descriptor for the peer end of the PTY pair without touching any path +in the container. The resulting fd is then used as the source of the +bind mount over /dev/console (via /proc/self/fd/N) and is dup'd over +stdio. + +For additional hardening (upstream commit 0c3e7c1b), the /dev/console +mount target is opened with O_NOFOLLOW|O_CREAT to prevent an attacker +from replacing /dev/console with a symlink that would either be +followed by os.Create or be passed as a path to mount(2). The bind +mount destination is referenced through the fd's /proc/self/fd/N path +so that even if the symlink swap happens between open and mount, runc +only mounts onto the verified inode. + +Upstream commits 804001a6 (pre-TIOCGPTPEER fallback) and 6763c0b7 +(verify /dev/pts/ptmx) are NOT backported: 804001a6 depends on +filepath-securejoin >= 0.4.x (pathrs.Reopen), and 6763c0b7 depends on +containerd/console >= v1.0.5 (NewPtyFromFile). Both are unavailable in +trixie. TIOCGPTPEER has been available since Linux 4.13 (2017), which +is older than every kernel shipped in any supported Debian release; +runc will return an error from GetPtyPeer rather than silently fall +through if the ioctl is unavailable. + +Fixes: GHSA-qw9x-cqr3-wc7r CVE-2025-52565 +Reported-by: Lei Wang +Reported-by: lfbzhm +Signed-off-by: Aleksa Sarai + +Origin: backport, https://github.com/opencontainers/runc/commit/cc08a1d4f93e02760aa9b411883297f4e0080e5f +Origin: backport, https://github.com/opencontainers/runc/commit/0c3e7c1b4b194ee920e6d52f3ea1cf181b799e54 +Bug: https://github.com/opencontainers/runc/security/advisories/GHSA-qw9x-cqr3-wc7r +Forwarded: not-needed +--- + libcontainer/console_linux.go | 67 ++++++++++++++++++++++++++++-------------- + libcontainer/init_linux.go | 15 +++++++-- + 2 files changed, 58 insertions(+), 24 deletions(-) + +--- a/libcontainer/console_linux.go ++++ b/libcontainer/console_linux.go +@@ -1,41 +1,66 @@ + package libcontainer + + import ( ++ "fmt" + "os" ++ "runtime" ++ "strconv" + + "golang.org/x/sys/unix" ++ ++ "github.com/opencontainers/runc/internal/linux" + ) + +-// mount initializes the console inside the rootfs mounting with the specified mount label +-// and applying the correct ownership of the console. +-func mountConsole(slavePath string) error { ++// safeAllocPty returns a new (ptmx, peer pty) allocation for use inside a ++// container. The peer fd is obtained via the TIOCGPTPEER ioctl so that we ++// never have to resolve /dev/pts/$num inside the (untrusted) container -- ++// see CVE-2025-52565. ++func safeAllocPty(ptmxFd uintptr, unsafePeerPath string) (*os.File, error) { ++ peer, err := linux.GetPtyPeer(ptmxFd, unsafePeerPath, unix.O_RDWR|unix.O_NOCTTY) ++ if err != nil { ++ return nil, fmt.Errorf("failed to get peer end of newly-allocated console: %w", err) ++ } ++ return peer, nil ++} ++ ++// mountConsole bind-mounts the provided pty peer on top of /dev/console so ++// programs that operate on /dev/console operate on the correct container ++// pty. To avoid symlink attacks against /dev/console itself the target is ++// opened with O_NOFOLLOW|O_CREAT and the bind mount is performed via the ++// resulting /proc/self/fd/N path (see CVE-2025-52565 and the upstream ++// 0c3e7c1b commit). ++func mountConsole(peerPty *os.File) error { + oldMask := unix.Umask(0o000) + defer unix.Umask(oldMask) +- f, err := os.Create("/dev/console") +- if err != nil && !os.IsExist(err) { +- return err ++ console, err := os.OpenFile("/dev/console", unix.O_NOFOLLOW|unix.O_CREAT|unix.O_CLOEXEC, 0o666) ++ if err != nil { ++ return fmt.Errorf("create /dev/console mount target: %w", err) + } +- if f != nil { +- f.Close() ++ defer console.Close() ++ ++ // Bind mount the peer pty onto /dev/console via fd paths so that: ++ // - the source is the kernel-allocated peer fd (immune to swap), and ++ // - the destination is the fd we just opened with O_NOFOLLOW. ++ srcFdPath := "/proc/self/fd/" + strconv.Itoa(int(peerPty.Fd())) ++ dstFdPath := "/proc/self/fd/" + strconv.Itoa(int(console.Fd())) ++ if err := mount(srcFdPath, "/dev/console", dstFdPath, "bind", unix.MS_BIND, ""); err != nil { ++ return err + } +- return mount(slavePath, "/dev/console", "", "bind", unix.MS_BIND, "") ++ runtime.KeepAlive(peerPty) ++ runtime.KeepAlive(console) ++ return nil + } + +-// dupStdio opens the slavePath for the console and dups the fds to the current +-// processes stdio, fd 0,1,2. +-func dupStdio(slavePath string) error { +- fd, err := unix.Open(slavePath, unix.O_RDWR, 0) +- if err != nil { +- return &os.PathError{ +- Op: "open", +- Path: slavePath, +- Err: err, +- } +- } ++// dupStdio replaces stdio (fds 0,1,2) with the given peer pty file ++// descriptor. Unlike the previous implementation which re-opened the peer ++// pty by path (and was therefore vulnerable to symlink swaps within the ++// container's /dev/pts), this dup3()s the verified peer fd directly. ++func dupStdio(peerPty *os.File) error { + for _, i := range []int{0, 1, 2} { +- if err := unix.Dup3(fd, i, 0); err != nil { ++ if err := unix.Dup3(int(peerPty.Fd()), i, 0); err != nil { + return err + } + } ++ runtime.KeepAlive(peerPty) + return nil + } +--- a/libcontainer/init_linux.go ++++ b/libcontainer/init_linux.go +@@ -254,13 +254,22 @@ + // the UID owner of the console to be the user the process will run as (so + // they can actually control their console). + +- pty, slavePath, err := console.NewPty() ++ pty, unsafePeerPath, err := console.NewPty() + if err != nil { + return err + } ++ // Get the peer pty fd directly via TIOCGPTPEER rather than re-opening ++ // /dev/pts/$num inside the (possibly hostile) container. See ++ // CVE-2025-52565. ++ peerPty, err := safeAllocPty(pty.Fd(), unsafePeerPath) ++ if err != nil { ++ _ = pty.Close() ++ return err ++ } + + // After we return from here, we don't need the console anymore. + defer pty.Close() ++ defer peerPty.Close() + + if config.ConsoleHeight != 0 && config.ConsoleWidth != 0 { + err = pty.Resize(console.WinSize{ +@@ -274,7 +283,7 @@ + + // Mount the console inside our rootfs. + if mount { +- if err := mountConsole(slavePath); err != nil { ++ if err := mountConsole(peerPty); err != nil { + return err + } + } +@@ -283,7 +292,7 @@ + return err + } + // Now, dup over all the things. +- return dupStdio(slavePath) ++ return dupStdio(peerPty) + } + + // syncParentReady sends to the given pipe a JSON payload which indicates that diff -Nru runc-1.1.15+ds1/debian/patches/CVE-2026-41579.patch runc-1.1.15+ds1/debian/patches/CVE-2026-41579.patch --- runc-1.1.15+ds1/debian/patches/CVE-2026-41579.patch 1970-01-01 00:00:00.000000000 +0000 +++ runc-1.1.15+ds1/debian/patches/CVE-2026-41579.patch 2026-11-13 13:31:21.000000000 +0000 @@ -0,0 +1,85 @@ +Description: Constrain pre-pivot /dev setup to securely opened directory descriptors + Backport the fd-based setupPtmx and setupDevSymlinks fix to runc 1.1.15. + Use securejoin.OpenInRoot (available in trixie's securejoin 0.3.4) to resolve + /dev within the container root, then use unlinkat and symlinkat with fixed + single-component names. Each setup function pins its /dev descriptor, so + replacing a /dev symlink cannot redirect the subsequent mutations. + . + Unlike current upstream, this branch has no pathrs layer. The existing + call sequence already requires /dev to exist after createDevices, so no + generic parent-directory creation helpers are needed. Keep the existing + function interfaces and do not change device creation or console setup. +Author: Aleksa Sarai +Origin: backport, https://github.com/opencontainers/runc/commit/864db8042dbb191028676f80addf8c35f348aee2 +Bug: https://github.com/opencontainers/runc/security/advisories/GHSA-xjvp-4fhw-gc47 +Forwarded: not-needed +Last-Update: 2026-11-13 + +--- a/libcontainer/rootfs_linux.go ++++ b/libcontainer/rootfs_linux.go +@@ -660,24 +660,28 @@ + } + + func setupDevSymlinks(rootfs string) error { ++ // Resolve /dev inside the container and pin it before changing any entries. ++ // A path-based operation before pivot_root could follow a symlink onto the host. ++ dev, err := securejoin.OpenInRoot(rootfs, "/dev") ++ if err != nil { ++ return err ++ } ++ defer dev.Close() ++ + links := [][2]string{ +- {"/proc/self/fd", "/dev/fd"}, +- {"/proc/self/fd/0", "/dev/stdin"}, +- {"/proc/self/fd/1", "/dev/stdout"}, +- {"/proc/self/fd/2", "/dev/stderr"}, ++ {"/proc/self/fd", "fd"}, ++ {"/proc/self/fd/0", "stdin"}, ++ {"/proc/self/fd/1", "stdout"}, ++ {"/proc/self/fd/2", "stderr"}, + } + // kcore support can be toggled with CONFIG_PROC_KCORE; only create a symlink + // in /dev if it exists in /proc. + if _, err := os.Stat("/proc/kcore"); err == nil { +- links = append(links, [2]string{"/proc/kcore", "/dev/core"}) ++ links = append(links, [2]string{"/proc/kcore", "core"}) + } + for _, link := range links { +- var ( +- src = link[0] +- dst = filepath.Join(rootfs, link[1]) +- ) +- if err := os.Symlink(src, dst); err != nil && !os.IsExist(err) { +- return err ++ if err := unix.Symlinkat(link[0], int(dev.Fd()), link[1]); err != nil && !errors.Is(err, unix.EEXIST) { ++ return &os.PathError{Op: "symlinkat", Path: dev.Name() + "/" + link[1], Err: err} + } + } + return nil +@@ -863,12 +867,19 @@ + } + + func setupPtmx(config *configs.Config) error { +- ptmx := filepath.Join(config.Rootfs, "dev/ptmx") +- if err := os.Remove(ptmx); err != nil && !os.IsNotExist(err) { +- return err +- } +- if err := os.Symlink("pts/ptmx", ptmx); err != nil { +- return err ++ // Keep both operations relative to the same securely resolved directory. ++ // In particular, never re-resolve /dev between unlinkat and symlinkat. ++ dev, err := securejoin.OpenInRoot(config.Rootfs, "/dev") ++ if err != nil { ++ return err ++ } ++ defer dev.Close() ++ ++ if err := unix.Unlinkat(int(dev.Fd()), "ptmx", 0); err != nil && !errors.Is(err, unix.ENOENT) { ++ return &os.PathError{Op: "unlinkat", Path: dev.Name() + "/ptmx", Err: err} ++ } ++ if err := unix.Symlinkat("pts/ptmx", int(dev.Fd()), "ptmx"); err != nil { ++ return &os.PathError{Op: "symlinkat", Path: dev.Name() + "/ptmx", Err: err} + } + return nil + } diff -Nru runc-1.1.15+ds1/debian/patches/series runc-1.1.15+ds1/debian/patches/series --- runc-1.1.15+ds1/debian/patches/series 2025-02-08 16:10:01.000000000 +0000 +++ runc-1.1.15+ds1/debian/patches/series 2026-11-13 12:59:18.000000000 +0000 @@ -12,3 +12,16 @@ 0012-TestDevicesSetAllow-Skip-test-when-cgroup-file-is-em.patch 0013-loong64-support.patch 0014-update-loongarch64-support.patch + +# CVE-2025-31133: /dev/null source not verified during maskedPaths bind-mount +CVE-2025-31133/0001-internal-sys-add-VerifyInode-helper.patch +CVE-2025-31133/0002-libct-add-use-isDevNull-verifyDevNull.patch +CVE-2025-31133/0003-libct-maskPaths-only-ignore-ENOENT-on-mount-dest.patch +CVE-2025-31133/0004-libct-maskPaths-don-t-rely-on-ENOTDIR-for-mount.patch + +# CVE-2025-52565: /dev/console bind-mount source not properly verified +CVE-2025-52565/0001-internal-linux-add-GetPtyPeer-helper.patch +CVE-2025-52565/0002-console-use-TIOCGPTPEER-and-harden-dev-console-mount.patch + +# CVE-2026-41579: /dev symlinks redirect pre-pivot filesystem mutations +CVE-2026-41579.patch