Your message dated Tue, 29 Apr 2025 19:04:35 +0000
with message-id <[email protected]>
and subject line Bug#1100806: fixed in containerd 1.7.24~ds1-6
has caused the Debian Bug report #1100806,
regarding [SECURITY] [PATCH] Fix for CVE-2024-40635 in containerd
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1100806: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1100806
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: containerd
Version: 1.6.20~ds1-1+deb12u1
Severity: important
Tags: security patch
User: [email protected]
Usertags: CVE-2024-40635

Dear Maintainer,

I'm submitting a patch for CVE-2024-40635 in the containerd package.

Vulnerability details:
- CVE ID: CVE-2024-40635
- Description: Integer overflow in UID/GID handling allows containers to run as 
root
- Affected versions: All versions prior to 1.6.38, 1.7.27, and 2.0.4
- Fixed upstream in: 
https://github.com/containerd/containerd/commit/11504c3fc5f45634f2d93d57743a998194430b82

The vulnerability allows containers launched with a User set as a UID:GID 
larger than the maximum 32-bit signed integer to cause an overflow condition 
where the container ultimately runs as root (UID 0) .

My patch adds validation for UID/GID values to prevent integer overflow, 
backported from the upstream fix. I've tested the patch and confirmed it 
correctly rejects values larger than MaxInt32.

The patch has been tested on Debian bookworm and works correctly.

Thank you for considering this contribution.

Best regards,
Mostafa Amin


Description: Fix integer overflow in UID/GID validation
 This patch adds validation to prevent integer overflow when parsing
 user IDs larger than MaxInt32, which could cause containers to run as root.
 .
 Without the fix, values larger than MaxInt32 are accepted and incorrectly
 converted to uint32, potentially allowing containers to run as root (UID 0).
 .
 CVE-2024-40635
Author: Mostafa Amin <[email protected]>
Origin: upstream, https://github.com/containerd/containerd/commit/11504c3fc5f45634f2d93d57743a998194430b82
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1100806
Last-Update: 2025-04-14
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: containerd-1.6.20~ds1/oci/spec_opts.go
===================================================================
--- containerd-1.6.20~ds1.orig/oci/spec_opts.go
+++ containerd-1.6.20~ds1/oci/spec_opts.go
@@ -22,6 +22,7 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
+    "math"
 	"os"
 	"path/filepath"
 	"runtime"
@@ -582,6 +583,20 @@ func WithUser(userstr string) SpecOpts {
 		defer ensureAdditionalGids(s)
 		setProcess(s)
 		s.Process.User.AdditionalGids = nil
+        // While the Linux kernel allows the max UID to be MaxUint32 - 2,
+        // and the OCI Runtime Spec has no definition about the max UID,
+        // the runc implementation is known to require the UID to be <= MaxInt32.
+        //
+        // containerd follows runc's limitation here.
+        //
+        // In future we may relax this limitation to allow MaxUint32 - 2,
+        // or, amend the OCI Runtime Spec to codify the implementation limitation.
+ 		const (
+ 			minUserID  = 0
+ 			maxUserID  = math.MaxInt32
+ 			minGroupID = 0
+ 			maxGroupID = math.MaxInt32
+ 		)
 
 		// For LCOW it's a bit harder to confirm that the user actually exists on the host as a rootfs isn't
 		// mounted on the host and shared into the guest, but rather the rootfs is constructed entirely in the
@@ -598,8 +613,8 @@ func WithUser(userstr string) SpecOpts {
 		switch len(parts) {
 		case 1:
 			v, err := strconv.Atoi(parts[0])
-			if err != nil {
-				// if we cannot parse as a uint they try to see if it is a username
+			if err != nil || v < minUserID || v > maxUserID {
+				// if we cannot parse as an int32 then try to see if it is a username
 				return WithUsername(userstr)(ctx, client, c, s)
 			}
 			return WithUserID(uint32(v))(ctx, client, c, s)
@@ -610,12 +625,13 @@ func WithUser(userstr string) SpecOpts {
 			)
 			var uid, gid uint32
 			v, err := strconv.Atoi(parts[0])
-			if err != nil {
+			if err != nil || v < minUserID || v > maxUserID {
 				username = parts[0]
 			} else {
 				uid = uint32(v)
 			}
-			if v, err = strconv.Atoi(parts[1]); err != nil {
+            v, err = strconv.Atoi(parts[1])
+ 			if err != nil || v < minGroupID || v > maxGroupID {
 				groupname = parts[1]
 			} else {
 				gid = uint32(v)
Index: containerd-1.6.20~ds1/oci/spec_opts_linux_test.go
===================================================================
--- containerd-1.6.20~ds1.orig/oci/spec_opts_linux_test.go
+++ containerd-1.6.20~ds1/oci/spec_opts_linux_test.go
@@ -32,6 +32,97 @@ import (
 )
 
 //nolint:gosec
+func TestWithUser(t *testing.T) {
+ 	t.Parallel()
+
+ 	expectedPasswd := `root:x:0:0:root:/root:/bin/ash
+ guest:x:405:100:guest:/dev/null:/sbin/nologin
+ `
+ 	expectedGroup := `root:x:0:root
+ bin:x:1:root,bin,daemon
+ daemon:x:2:root,bin,daemon
+ sys:x:3:root,bin,adm
+ guest:x:100:guest
+ `
+ 	td := t.TempDir()
+ 	apply := fstest.Apply(
+ 		fstest.CreateDir("/etc", 0777),
+ 		fstest.CreateFile("/etc/passwd", []byte(expectedPasswd), 0777),
+ 		fstest.CreateFile("/etc/group", []byte(expectedGroup), 0777),
+ 	)
+ 	if err := apply.Apply(td); err != nil {
+ 		t.Fatalf("failed to apply: %v", err)
+ 	}
+ 	c := containers.Container{ID: t.Name()}
+ 	testCases := []struct {
+ 		user        string
+ 		expectedUID uint32
+ 		expectedGID uint32
+ 		err         string
+ 	}{
+ 		{
+ 			user:        "0",
+ 			expectedUID: 0,
+ 			expectedGID: 0,
+ 		},
+ 		{
+ 			user:        "root:root",
+ 			expectedUID: 0,
+ 			expectedGID: 0,
+ 		},
+ 		{
+ 			user:        "guest",
+ 			expectedUID: 405,
+ 			expectedGID: 100,
+ 		},
+ 		{
+ 			user:        "guest:guest",
+ 			expectedUID: 405,
+ 			expectedGID: 100,
+ 		},
+ 		{
+ 			user: "guest:nobody",
+ 			err:  "no groups found",
+ 		},
+ 		{
+ 			user:        "405:100",
+ 			expectedUID: 405,
+ 			expectedGID: 100,
+ 		},
+ 		{
+ 			user: "405:2147483648",
+ 			err:  "no groups found",
+ 		},
+ 		{
+ 			user: "-1000",
+ 			err:  "no users found",
+ 		},
+ 		{
+ 			user: "2147483648",
+ 			err:  "no users found",
+ 		},
+ 	}
+ 	for _, testCase := range testCases {
+ 		testCase := testCase
+ 		t.Run(testCase.user, func(t *testing.T) {
+ 			t.Parallel()
+ 			s := Spec{
+ 				Version: specs.Version,
+ 				Root: &specs.Root{
+ 					Path: td,
+ 				},
+ 				Linux: &specs.Linux{},
+ 			}
+ 			err := WithUser(testCase.user)(context.Background(), nil, &c, &s)
+ 			if err != nil {
+ 				assert.EqualError(t, err, testCase.err)
+ 			}
+ 			assert.Equal(t, testCase.expectedUID, s.Process.User.UID)
+ 			assert.Equal(t, testCase.expectedGID, s.Process.User.GID)
+ 		})
+ 	}
+ }
+
 func TestWithUserID(t *testing.T) {
 	t.Parallel()
 

--- End Message ---
--- Begin Message ---
Source: containerd
Source-Version: 1.7.24~ds1-6
Done: Andreas Henriksson <[email protected]>

We believe that the bug you reported is fixed in the latest version of
containerd, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Andreas Henriksson <[email protected]> (supplier of updated containerd package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Tue, 29 Apr 2025 20:55:02 +0200
Source: containerd
Architecture: source
Version: 1.7.24~ds1-6
Distribution: unstable
Urgency: medium
Maintainer: Debian Go Packaging Team <[email protected]>
Changed-By: Andreas Henriksson <[email protected]>
Closes: 1100806
Changes:
 containerd (1.7.24~ds1-6) unstable; urgency=medium
 .
   * Team upload.
   * CVE-2024-40635: large UID:GID (>32bit) can overflow, runs as root
     (Closes: #1100806)
Checksums-Sha1:
 90e1bba90367b8cd96aa8afef092fa71660ba39d 5011 containerd_1.7.24~ds1-6.dsc
 bf7a9e9751bae4fc25c434dc9ff2e12672ac1b95 35184 
containerd_1.7.24~ds1-6.debian.tar.xz
 ba9c047a4c9eb7763ac613ddd5c57cba4a9e39e5 17515 
containerd_1.7.24~ds1-6_arm64.buildinfo
Checksums-Sha256:
 4810a88901dd8b2601b6ef1ea36fe628efe757bca255fc28a1cf0db2f1f72be1 5011 
containerd_1.7.24~ds1-6.dsc
 7a6c27864133963f81dbf05248bfa81a537ec242efb4000e6937bfb556d015f0 35184 
containerd_1.7.24~ds1-6.debian.tar.xz
 f62a6acb1e354dd50eec0f93e817e4b03a0429eab791102eecb902892fc547d1 17515 
containerd_1.7.24~ds1-6_arm64.buildinfo
Files:
 451cdf3ba9f8efb51239b6af78cae0db 5011 admin optional 
containerd_1.7.24~ds1-6.dsc
 85ebe84cc0b5462f9f617811c7db4ce5 35184 admin optional 
containerd_1.7.24~ds1-6.debian.tar.xz
 6b4b3fb38c08504ba8c232cfde6e2f74 17515 admin optional 
containerd_1.7.24~ds1-6_arm64.buildinfo

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE+uHltkZSvnmOJ4zCC8R9xk0TUwYFAmgRIiQACgkQC8R9xk0T
Uwac2A/+NKmEY7Wd/CeSd2zrATp/bbsdD2RT4UNIFAR46N1xKg6ehVuaRshrSXxt
1frwLDbKKKIKuiUOc5o+TffAqcDuKQPCTPy7u/ssQuXZAIN3FMAUfsEY229UBxPt
HGl6tsnImSFHKvp/lbnmTueKyMKvc/WdwbJCrHFQNegncRW+8/TffNawLv4w8bh3
ZAlzToDIHfCA35030ZpTOrmcvt5BL7wQbcg1NzR9yfDdIYnPfrzMhQYK1falfYOs
KLU6esRC6kRBt+MzlEJGoWN2MBHVIAxgC4fahptvr9knp4NhUHcgTeFs1dkudvNF
Nz/28l6KjG4wUBpmrZm52jwrVIbOLjdACrJy4AIPmrI2HzN6PJgH/UvUm8Uz3dsB
HSQohdlGHhJHeaoZ8MP5Y6ukMvNeZlVwqFeZ+Zl7Gdo+GxsHMlDozLdkoABZPk4u
DraFHXCSwnnQHv+LCsWWxwLSdMITWggew3NWBWXmhkKQEeVvxX8my93aJ4RZqtV9
GHqGTfXj4z0Dx+KfMF5hxmT6Oh+C+XdPzlqD9s+j5hUyE17U6wZ0KB/6IqzcL46K
Ji3mf1OOHaWvsJZAhd0gunRhjGwlH5qASuyah37HQFpcxICkRotAkI3eixHBu2Vr
1VfiX9TOsFa0N3Zs8sV6M2V2rAJjTdznopXYbbpI9V+b5W/FrJI=
=uhmU
-----END PGP SIGNATURE-----

Attachment: pgpJvvaH9LdJt.pgp
Description: PGP signature


--- End Message ---

Reply via email to