Summary
Canonical LXD contains an improper sanitization flaw in the compression_algorithm parameter used by image and backup API endpoints. An authenticated, unprivileged user may exploit this issue to execute commands with the privileges of the LXD daemon on the LXD server.
Affected context
The vulnerability occurs in LXD deployments where authenticated users can access image or backup API endpoints and supply the compression_algorithm parameter. Risk exists when that parameter is incorporated into command execution without sufficiently restricting its value to an approved set of compression algorithms.
Exploit preconditions
- Attack surface: LXD image and backup API endpoints
- Required access: An authenticated account with access to the relevant API operations; administrative privileges may not be required
- Trigger point: Processing the
compression_algorithmparameter during an image or backup operation - Why exploitation is possible: Improper sanitization allows attacker-controlled input to reach an operating-system command execution context
Why this happens
The underlying bug is an OS command injection condition mapped to CWE-78. LXD treats a user-controlled compression algorithm value as command-related data without enforcing a strict allowlist or maintaining a safe separation between data and executable arguments. As a result, specially crafted input may alter the intended command behavior when image or backup operations are processed.
Potential impact
- An attacker may execute arbitrary commands on the LXD server
- The LXD daemon account or its associated service context could be compromised
- Host files, container data, images, or backups may be accessed or modified
- Attackers could establish persistence or disrupt LXD-managed workloads
- The compromise could enable lateral movement into connected infrastructure
General mitigation guidance
Mitigation generally focuses on preventing user-controlled values from reaching shell or operating-system command interpreters.
Common defensive patterns include:
- Restricting compression algorithm values to a small, explicit allowlist
- Passing validated arguments through parameterized process APIs rather than shell evaluation
- Separating command construction from input handling and avoiding command-string concatenation
- Applying strict authorization boundaries to image and backup operations
- Running the LXD daemon with only the privileges required for its operational duties
- Limiting access to the LXD API and monitoring authenticated activity involving image and backup endpoints
- Applying vendor-provided security fixes through the organization's normal patch-management process
How teams detect issues like this
Organizations can look for command injection risks through:
- Static analysis rules identifying shell execution APIs, command-string concatenation, and unvalidated parameters
- Code review checks for user-controlled values passed to process-spawning or shell-invocation functions
- Policy enforcement requiring allowlists for enumerated configuration and API parameters
- Runtime monitoring for unexpected child processes launched by the LXD daemon
- Audit analysis of image and backup API requests, including unusual compression algorithm values or anomalous command activity
- Automated security scanning and code review tools that flag unsafe operating-system command construction

