Skip to content

hcsv2: allowlist NVIDIA GPU capability annotation values - #2915

Merged
Maksim An (anmaxvl) merged 1 commit into
microsoft:mainfrom
anmaxvl:nvidia-utils-hook-fix
Sep 3, 2026
Merged

hcsv2: allowlist NVIDIA GPU capability annotation values#2915
Maksim An (anmaxvl) merged 1 commit into
microsoft:mainfrom
anmaxvl:nvidia-utils-hook-fix

Conversation

@anmaxvl

Copy link
Copy Markdown
Contributor

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.

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>
@anmaxvl
Maksim An (anmaxvl) merged commit bada12e into microsoft:main Sep 3, 2026
20 checks passed
@anmaxvl
Maksim An (anmaxvl) deleted the nvidia-utils-hook-fix branch September 3, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants