@@ -71,6 +71,7 @@ var allTests = integration.TestFuncs(
71
71
testExportedHistory ,
72
72
testExposeExpansion ,
73
73
testUser ,
74
+ testUserAdditionalGids ,
74
75
testCacheReleased ,
75
76
testDockerignore ,
76
77
testDockerignoreInvalid ,
@@ -3005,6 +3006,43 @@ USER nobody
3005
3006
require .Equal (t , "nobody" , ociimg .Config .User )
3006
3007
}
3007
3008
3009
+ // testUserAdditionalGids ensures that that the primary GID is also included in the additional GID list.
3010
+ // CVE-2023-25173: https://github.com/advisories/GHSA-hmfx-3pcx-653p
3011
+ func testUserAdditionalGids (t * testing.T , sb integration.Sandbox ) {
3012
+ f := getFrontend (t , sb )
3013
+
3014
+ dockerfile := []byte (`
3015
+ # Mimics the tests in https://github.com/containerd/containerd/commit/3eda46af12b1deedab3d0802adb2e81cb3521950
3016
+ FROM busybox
3017
+ SHELL ["/bin/sh", "-euxc"]
3018
+ RUN [ "$(id)" = "uid=0(root) gid=0(root) groups=0(root),10(wheel)" ]
3019
+ USER 1234
3020
+ RUN [ "$(id)" = "uid=1234 gid=0(root) groups=0(root)" ]
3021
+ USER 1234:1234
3022
+ RUN [ "$(id)" = "uid=1234 gid=1234 groups=1234" ]
3023
+ USER daemon
3024
+ RUN [ "$(id)" = "uid=1(daemon) gid=1(daemon) groups=1(daemon)" ]
3025
+ ` )
3026
+
3027
+ dir , err := integration .Tmpdir (
3028
+ t ,
3029
+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
3030
+ )
3031
+ require .NoError (t , err )
3032
+
3033
+ c , err := client .New (sb .Context (), sb .Address ())
3034
+ require .NoError (t , err )
3035
+ defer c .Close ()
3036
+
3037
+ _ , err = f .Solve (sb .Context (), c , client.SolveOpt {
3038
+ LocalDirs : map [string ]string {
3039
+ dockerui .DefaultLocalNameDockerfile : dir ,
3040
+ dockerui .DefaultLocalNameContext : dir ,
3041
+ },
3042
+ }, nil )
3043
+ require .NoError (t , err )
3044
+ }
3045
+
3008
3046
func testCopyChown (t * testing.T , sb integration.Sandbox ) {
3009
3047
f := getFrontend (t , sb )
3010
3048
0 commit comments