Skip to content

Commit 2dcc40e

Browse files
Merge pull request #27001 from Luap99/cve-test
test/e2e: add CVE-2025-9566 regression test
2 parents f30567e + 6c4b98c commit 2dcc40e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

test/e2e/play_kube_test.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2188,7 +2188,7 @@ func getPersistentVolumeClaimVolume(vName string) *Volume {
21882188

21892189
// getConfigMapVolume returns a new ConfigMap Volume given the name and items
21902190
// 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 {
21922192
vol := &Volume{
21932193
VolumeType: "ConfigMap",
21942194
Name: defaultVolName,
@@ -6391,4 +6391,33 @@ spec:
63916391
Expect(appContainerLogDir).ToNot(BeEmpty(), "Should have found application container log directory")
63926392
Expect(logContent).To(ContainSubstring(expectedMessage), "Log file should contain the expected message")
63936393
})
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+
})
63946423
})

0 commit comments

Comments
 (0)