-
Notifications
You must be signed in to change notification settings - Fork 365
[no-relnote] Add e2e test for firmware path traversal #1169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pull Request Test Coverage Report for Build 16054009949Details
💛 - Coveralls |
80b5ea1
to
13ca3e3
Compare
8778e11
to
f47a6be
Compare
f47a6be
to
c2fa0b3
Compare
c2fa0b3
to
1499ac2
Compare
1499ac2
to
18138b8
Compare
49f57d6
to
244939c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the test runner to propagate stderr on failures and adds an end-to-end test validating firmware file creation under CDI vs. legacy runtimes.
- Propagate actual stderr from
runner.Run
when a script fails - Add new E2E tests to ensure CDI injection prevents host-side firmware file creation
- Import
fmt
to support formatted commands in tests
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
tests/e2e/runner.go | Return stderr.String() as the second value on errors |
tests/e2e/nvidia-container-toolkit_test.go | Introduce firmware-file-creation tests with setup and cleanup |
Comments suppressed due to low confidence (2)
tests/e2e/nvidia-container-toolkit_test.go:307
- This ignores the
err
return fromls
; adding_, _, err := runner.Run(...)
followed byExpect(err).ToNot(HaveOccurred())
will ensure any unexpected failures are caught.
output, _, _ := runner.Run(fmt.Sprintf("ls -A %s", outputDir))
tests/e2e/nvidia-container-toolkit_test.go:277
- [nitpick] The variable
dockerBuildDockerfile
holds the Dockerfile content; renaming it to something likedockerfileContent
could improve clarity.
FROM ubuntu
244939c
to
e885760
Compare
e885760
to
d06c4f6
Compare
d06c4f6
to
e1bf318
Compare
e1bf318
to
f49e17c
Compare
output, _, err := runner.Run("docker run --rm --runtime=nvidia --gpus=all firmware-test") | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(output).To(BeEmpty()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our other CDI tests we use:
output, _, err := runner.Run("docker run --rm --runtime=nvidia --gpus=runtime.nvidia.com/gpu=all firmware-test") |
It("should fail when using the nvidia-container-runtime-hook", Label("legacy"), func(ctx context.Context) { | ||
_, stderr, err := runner.Run("docker run --rm --runtime=runc --gpus=all firmware-test") | ||
Expect(err).To(HaveOccurred()) | ||
Expect(stderr).To(ContainSubstring("nvidia-container-cli.real: mount error: path error:")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a test for the nvidia-container-runtime
too:
Expect(stderr).To(ContainSubstring("nvidia-container-cli.real: mount error: path error:")) | |
It("should not fail when using the nvidia-container-runtime-hook", func(ctx context.Context) { | |
_, _, err := runner.Run("docker run --rm --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all firmware-test") | |
Expect(err).ToNot(HaveOccurred()) | |
output, _, _ := runner.Run(fmt.Sprintf("ls -A %s", outputDir)) | |
Expect(output).To(BeEmpty()) | |
} | |
It("should fail when using the nvidia-container-runtime-hook", Label("legacy"), func(ctx context.Context) { |
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to move the check for empty output folders to an AfterEach so that we don't have to repeat it for every test (and also don't forget to add it to new tests).
f49e17c
to
214aa82
Compare
Expect(output).To(BeEmpty()) | ||
}) | ||
|
||
It("should not fail when using the nvidia-container-runtime-hook", func(ctx context.Context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might have been a typo in my suggestion:
It("should not fail when using the nvidia-container-runtime-hook", func(ctx context.Context) { | |
It("should not fail when using the nvidia-container-runtime", func(ctx context.Context) { |
output, _, _ := runner.Run(fmt.Sprintf("ls -A %s", outputDir)) | ||
Expect(output).To(BeEmpty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(the string concatenation is a nit)
output, _, _ := runner.Run(fmt.Sprintf("ls -A %s", outputDir)) | |
Expect(output).To(BeEmpty()) | |
output, _, err := runner.Run("ls -A " + outputDir) | |
Expect(err).ToNot(HaveOccurred()) | |
Expect(output).To(BeEmpty()) |
214aa82
to
d496c73
Compare
A container image could be crafted with a symbolic link in /lib/firmware/nvidia/ that points to a location outside of the container's root filesystem. When running such a container with the NVIDIA Container Toolkit, this could potentially lead to files being created on the host filesystem. This change adds an end-to-end test to ensure that the toolkit is not vulnerable to this kind of path traversal attack. Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
d496c73
to
b701eaf
Compare
A container image could be crafted with a symbolic link in
/lib/firmware/nvidia/ that points to a location outside of the
container's root filesystem. When running such a container with the
NVIDIA Container Toolkit, this could potentially lead to files being
created on the host filesystem.
This change adds an end-to-end test to ensure that the toolkit is not
vulnerable to this kind of path traversal attack.
The test case covers two scenarios:
container runs without error and no files are created on the host.
ensures that the operation fails with a specific path error,
preventing any file creation on the host.