Summary
A critical path traversal vulnerability in Canonical LXD's Btrfs storage driver allows an authenticated user with instance creation privileges to influence filesystem paths during optimized backup import.
Under affected conditions, crafted backup metadata may enable deletion or replacement of arbitrary files and directories on the Linux host with root-level impact.
Affected context
The vulnerability occurs in LXD deployments that use the Btrfs storage driver and process optimized backup imports. It becomes risky when an authenticated principal who can create instances is also able to submit or import backup content whose metadata is trusted by the volume-unpacking logic. The impact extends beyond the instance because the affected operation runs with host-level privileges.
Exploit preconditions
- Attack surface: LXD instance creation and optimized backup import functionality
- Required access: An authenticated LXD user or tenant with instance creation privileges
- Trigger point: Btrfs volume unpacking while processing backup metadata
- Relevant input: A crafted path value within the backup's volume metadata
- Why exploitation is possible: The storage driver may resolve attacker-controlled paths without sufficiently constraining them to the intended volume directory, allowing privileged filesystem operations outside the expected boundary
Why this happens
The underlying bug is insufficient canonicalization and boundary validation of filesystem paths supplied through backup metadata. A storage operation intended to manipulate files within an isolated Btrfs volume can instead act on paths outside that volume when attacker-controlled path components are accepted without enforcing a trusted destination root.
This maps to CWE-22: Path Traversal, in which externally influenced path data is used to access filesystem locations beyond the authorized directory. Because the operation runs with elevated host privileges, a path-validation failure can become a host-level file deletion or replacement vulnerability.
Potential impact
- An attacker may delete arbitrary files or directories on the host
- An attacker could replace host files with attacker-controlled content
- The vulnerability may enable denial of service through destructive filesystem changes
- Host services, security controls, or configuration may be disrupted
- Confidentiality, integrity, and availability of other workloads could be affected
- In some environments, file replacement could contribute to host or cluster compromise
General mitigation guidance
Mitigation generally focuses on enforcing filesystem containment throughout backup extraction and volume unpacking.
Defensive patterns include:
- Canonicalizing candidate paths before use and verifying that they remain beneath a trusted volume root
- Rejecting absolute paths, parent-directory traversal, and ambiguous path representations
- Applying the same boundary checks after filesystem links, mounts, or Btrfs-specific path resolution are considered
- Treating backup metadata as untrusted input and validating it against a strict schema
- Using secure-by-default extraction routines that permit only explicitly authorized destinations
- Limiting instance-creation identities and separating tenant data from host-sensitive storage
- Running storage operations with the narrowest practical privileges and applying host filesystem protections
How teams detect issues like this
Detection can combine static analysis, code review, runtime monitoring, and policy enforcement.
Useful signals include:
- Static-analysis rules for filesystem APIs that consume user-controlled or archive-controlled paths
- Review findings involving path concatenation without canonicalization and containment checks
- Tests covering absolute paths, parent-directory components, symlink behavior, and alternate path representations
- Audit records for backup imports, volume extraction, and unexpected host filesystem modifications
- Policies requiring trusted-root validation before privileged file operations
- Automated code review tools that flag path traversal patterns and unsafe archive extraction logic

