@@ -2188,7 +2188,7 @@ func getPersistentVolumeClaimVolume(vName string) *Volume {
2188
2188
2189
2189
// getConfigMapVolume returns a new ConfigMap Volume given the name and items
2190
2190
// of the ConfigMap.
2191
- func getConfigMapVolume (vName string , items []map [string ]string , optional bool , defaultMode * int32 ) * Volume { //nolint:unparam
2191
+ func getConfigMapVolume (vName string , items []map [string ]string , optional bool , defaultMode * int32 ) * Volume {
2192
2192
vol := & Volume {
2193
2193
VolumeType : "ConfigMap" ,
2194
2194
Name : defaultVolName ,
@@ -6391,4 +6391,33 @@ spec:
6391
6391
Expect (appContainerLogDir ).ToNot (BeEmpty (), "Should have found application container log directory" )
6392
6392
Expect (logContent ).To (ContainSubstring (expectedMessage ), "Log file should contain the expected message" )
6393
6393
})
6394
+
6395
+ It ("CVE-2025-9566 regression test - ConfigMap mount" , func () {
6396
+ testfile := filepath .Join (podmanTest .TempDir , "testfile" )
6397
+ volumeName := "cm-vol"
6398
+ cm := getConfigMap (withConfigMapName (volumeName ), withConfigMapData ("foo" , "content1" ))
6399
+ cmYaml , err := getKubeYaml ("configmap" , cm )
6400
+ Expect (err ).ToNot (HaveOccurred ())
6401
+
6402
+ ctrName := "ctr1"
6403
+ podName := "pod1"
6404
+ // create a symlink at the volume mount location so we can make sure we don't resolve that to the host location.
6405
+ ctr := getCtr (withName (ctrName ), withVolumeMount ("/test" , "" , false ), withImage (CITEST_IMAGE ), withCmd ([]string {"sh" , "-c" , "ln -sf " + testfile + " /test/foo" }))
6406
+ pod := getPod (withPodName (podName ), withVolume (getConfigMapVolume (volumeName , nil , false , nil )), withCtr (ctr ))
6407
+ podYaml , err := getKubeYaml ("pod" , pod )
6408
+ Expect (err ).ToNot (HaveOccurred ())
6409
+ yamls := []string {cmYaml , podYaml }
6410
+ err = generateMultiDocKubeYaml (yamls , kubeYaml )
6411
+ Expect (err ).ToNot (HaveOccurred ())
6412
+
6413
+ podmanTest .PodmanExitCleanly ("kube" , "play" , kubeYaml )
6414
+ // wait for the container to finish to ensure the symlink was created
6415
+ podmanTest .PodmanExitCleanly ("wait" , podName + "-" + ctrName )
6416
+ podmanTest .PodmanExitCleanly ("kube" , "down" , kubeYaml )
6417
+ kube := podmanTest .Podman ([]string {"kube" , "play" , kubeYaml })
6418
+ kube .WaitWithDefaultTimeout ()
6419
+ Expect (kube ).To (ExitWithError (125 , `cannot create file "foo" at volume mountpoint` ))
6420
+
6421
+ Expect (testfile ).ToNot (BeAnExistingFile (), "file should never be created on the host" )
6422
+ })
6394
6423
})
0 commit comments