Summary
A critical command-injection vulnerability in LXD's NVIDIA instance configuration handling allows an authenticated attacker to inject configuration directives through specially crafted NVIDIA-related values.
If the attacker can create or modify an affected instance configuration, the resulting directives may cause arbitrary code execution on the host with the privileges of the LXD daemon.
Affected context
The vulnerability occurs in LXD deployments that process NVIDIA instance configuration values, including nvidia.driver.capabilities and nvidia.require.*, when generating the instance's lxc.conf file. Risk depends on an authenticated user having sufficient permission to configure instances and on the affected values being incorporated into generated configuration without adequate control-character neutralization.
Exploit preconditions
- Attack surface: LXD instance configuration handling and generated container runtime configuration
- Required access: Authenticated access with permission to create or modify relevant instance configuration
- Trigger point: Processing NVIDIA-related configuration values while generating
lxc.conf - Why exploitation is possible: Special characters in configuration values are not adequately neutralized, allowing attacker-controlled content to alter generated directives and influence privileged host-side processing
Why this happens
The underlying flaw is improper neutralization of special elements in user-controlled configuration data. Newline characters and related delimiters are accepted in NVIDIA configuration values and can change the structure of the generated LXC configuration rather than remaining ordinary data.
This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command or Command Argument, because attacker-controlled input crosses a configuration boundary into a privileged execution-related context without sufficient encoding, validation, or structural separation.
Potential impact
- An attacker may execute arbitrary code on the host
- The attacker could obtain the privileges of the LXD daemon
- Host confidentiality, integrity, and availability may be compromised
- Other containers, workloads, or stored data could be accessed or altered
- The system could be used for lateral movement or persistence
General mitigation guidance
Mitigation generally focuses on treating instance configuration as untrusted input and preventing values from changing the structure of generated runtime configuration.
Common defensive patterns include:
- Rejecting control characters, delimiters, and unexpected line breaks in configuration values
- Applying strict allowlists and type-aware validation for NVIDIA capability and requirement fields
- Building configuration through structured APIs rather than string concatenation
- Separating data values from configuration directives and applying context-appropriate escaping
- Restricting which authenticated roles may modify device and runtime-related settings
- Running the LXD daemon with the minimum practical host privileges and limiting exposed management interfaces
- Auditing existing instance configurations for unexpected directives or embedded control characters
How teams detect issues like this
Detection approaches commonly include:
- Static analysis rules for concatenating user-controlled values into LXC or shell-adjacent configuration files
- Code review checks for newline handling, delimiter validation, and direct generation of privileged configuration text
- Dynamic tests using control characters and malformed values to verify rejection and safe serialization
- Runtime monitoring for unexpected changes to generated
lxc.conffiles or unusual LXD child processes - Policy enforcement requiring schema validation and approved value sets for device-related configuration
- Automated security review tools that flag command-injection sinks and unsafe string-based configuration generation

