@@ -1913,7 +1913,7 @@ func getPersistentVolumeClaimVolume(vName string) *Volume {
1913
1913
1914
1914
// getConfigMap returns a new ConfigMap Volume given the name and items
1915
1915
// of the ConfigMap.
1916
- func getConfigMapVolume (vName string , items []map [string ]string , optional bool , defaultMode * int32 ) * Volume { //nolint:unparam
1916
+ func getConfigMapVolume (vName string , items []map [string ]string , optional bool , defaultMode * int32 ) * Volume {
1917
1917
vol := & Volume {
1918
1918
VolumeType : "ConfigMap" ,
1919
1919
Name : defaultVolName ,
@@ -6337,4 +6337,32 @@ spec:
6337
6337
Expect (execArr [len (execArr )- 1 ]).To (Not (ContainSubstring (arr [len (arr )- 1 ])))
6338
6338
})
6339
6339
6340
+ It ("CVE-2025-9566 regression test - ConfigMap mount" , func () {
6341
+ testfile := filepath .Join (podmanTest .TempDir , "testfile" )
6342
+ volumeName := "cm-vol"
6343
+ cm := getConfigMap (withConfigMapName (volumeName ), withConfigMapData ("foo" , "content1" ))
6344
+ cmYaml , err := getKubeYaml ("configmap" , cm )
6345
+ Expect (err ).ToNot (HaveOccurred ())
6346
+
6347
+ ctrName := "ctr1"
6348
+ podName := "pod1"
6349
+ // create a symlink at the volume mount location so we can make sure we don't resolve that to the host location.
6350
+ ctr := getCtr (withName (ctrName ), withVolumeMount ("/test" , "" , false ), withImage (CITEST_IMAGE ), withCmd ([]string {"sh" , "-c" , "ln -sf " + testfile + " /test/foo" }))
6351
+ pod := getPod (withPodName (podName ), withVolume (getConfigMapVolume (volumeName , nil , false , nil )), withCtr (ctr ))
6352
+ podYaml , err := getKubeYaml ("pod" , pod )
6353
+ Expect (err ).ToNot (HaveOccurred ())
6354
+ yamls := []string {cmYaml , podYaml }
6355
+ err = generateMultiDocKubeYaml (yamls , kubeYaml )
6356
+ Expect (err ).ToNot (HaveOccurred ())
6357
+
6358
+ podmanTest .PodmanExitCleanly ("kube" , "play" , kubeYaml )
6359
+ // wait for the container to finish to ensure the symlink was created
6360
+ podmanTest .PodmanExitCleanly ("wait" , podName + "-" + ctrName )
6361
+ podmanTest .PodmanExitCleanly ("kube" , "down" , kubeYaml )
6362
+ kube := podmanTest .Podman ([]string {"kube" , "play" , kubeYaml })
6363
+ kube .WaitWithDefaultTimeout ()
6364
+ Expect (kube ).To (ExitWithError (125 , `cannot create file "foo" at volume mountpoint` ))
6365
+
6366
+ Expect (testfile ).ToNot (BeAnExistingFile (), "file should never be created on the host" )
6367
+ })
6340
6368
})
0 commit comments