hcsv2: allowlist NVIDIA GPU capability annotation values - #2915
Merged
Conversation
The guest-side NVIDIA device hook comma-split the untrusted io.microsoft.container.gpu.capabilities annotation and appended every token verbatim as a --<token> argument to nvidia-container-cli configure. Because the tokens followed the fixed --ldconfig=@/sbin/ldconfig, a value-bearing token such as ldconfig=@<path> produced a second --ldconfig that won under the tool's last-flag-wins argument parsing, allowing an attacker-controlled executable path to be resolved before the target container's confinement was applied. Validate capability values against a fail-closed allowlist of the NVIDIA driver-capability vocabulary (all, compat32, compute, display, graphics, ngx, utility, video). Unknown, empty, and value-bearing tokens now abort hook creation before any argument reaches the tool. Omitting every non-listed option also blocks bare isolation-weakening flags such as no-cgroups. Valid capability sets are unchanged. Extract the injection-prone argv prefix into nvidiaConfigureArgs so it can be unit tested, and add regression tests covering the ldconfig injection payload, a valued option, unknown/empty tokens, and the legitimate capability set. Signed-off-by: Maksim An <maksiman@microsoft.com>
Hamza El-Saawy (helsaawy)
approved these changes
Sep 3, 2026
Jie Chen (jiechen0826)
approved these changes
Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The guest-side NVIDIA device hook comma-split the untrusted io.microsoft.container.gpu.capabilities annotation and appended every token verbatim as a -- argument to nvidia-container-cli configure. Because the tokens followed the fixed
--ldconfig=@/sbin/ldconfig, a value-bearing token such as ldconfig=@ produced a second --ldconfig that won under the tool's last-flag-wins argument parsing, allowing an attacker-controlled executable path to be resolved before the target container's confinement was applied.
Validate capability values against a fail-closed allowlist of the NVIDIA driver-capability vocabulary (all, compat32, compute, display, graphics, ngx, utility, video). Unknown, empty, and value-bearing tokens now abort hook creation before any argument reaches the tool. Omitting every non-listed option also blocks bare isolation-weakening flags such as no-cgroups. Valid capability sets are unchanged.
Extract the injection-prone argv prefix into nvidiaConfigureArgs so it can be unit tested, and add regression tests covering the ldconfig injection payload, a valued option, unknown/empty tokens, and the legitimate capability set.