Summary
A critical path traversal vulnerability in LXD allows crafted backup archives to influence file system paths during instance or storage volume import and restore operations. If an attacker can provide or cause LXD to process a malicious archive, files outside the intended restore directory may be accessed or overwritten.
Affected context
The vulnerability occurs in LXD backup archive import and restore workflows when archive metadata supplies instance or storage volume names. Risk is present where those names are used to construct file system paths without adequate canonicalization, containment checks, or strict name validation. Exploitation depends on LXD processing an attacker-controlled or tampered backup archive.
Exploit preconditions
- Attack surface: LXD backup import or restore functionality
- Required access: Ability to supply, upload, or otherwise cause processing of a crafted backup archive
- Trigger point: Extraction or restoration of archive contents using instance or storage volume names from archive metadata
- Why exploitation is possible: Malicious path components can influence destination paths when metadata values are not validated and resolved paths are not constrained to the designated restore directory
Why this happens
The underlying bug is improper neutralization of path elements supplied through backup metadata. LXD uses instance and storage volume names in file system path construction without sufficiently enforcing safe naming rules or verifying that the resolved destination remains within the intended restore root. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal.
Potential impact
- An attacker may read files outside the intended restore location
- Crafted archives could overwrite or corrupt files accessible to the LXD process
- Instance, storage, or host configuration data could be modified
- The issue could enable denial of service or disruption of managed workloads
- File changes could contribute to broader host or container compromise depending on process privileges
General mitigation guidance
Mitigation generally focuses on treating archive metadata as untrusted input and enforcing destination containment.
Common defensive patterns include:
- Accepting only strictly validated instance and volume names
- Canonicalizing paths before use and verifying they remain beneath the designated restore directory
- Rejecting absolute paths, parent-directory components, and unexpected separators
- Using extraction APIs that enforce trusted destination boundaries
- Applying least-privilege permissions to LXD and its storage paths
- Isolating backup processing from sensitive host file systems where practical
- Preserving defense-in-depth controls such as read-only mounts and filesystem access policies
How teams detect issues like this
Detection can combine source review, runtime monitoring, and policy enforcement:
- Use static analysis to identify path construction from archive metadata or other external input
- Review archive extraction code for missing canonicalization and containment checks
- Flag direct concatenation of user-controlled names with filesystem paths
- Monitor restore operations for attempts involving parent-directory components, absolute paths, or unusual separators
- Enforce archive validation policies before extraction and record rejected metadata values
- Use automated code review or security scanning tools to identify CWE-22 patterns

